From f94af4c467126bb5123db7ad41ae3081dfecf621 Mon Sep 17 00:00:00 2001 From: Guillaume Loulier Date: Mon, 4 Apr 2022 15:33:35 +0200 Subject: [PATCH 1/3] refactor(ci): Dagger introduced --- .cloud/dagger/scheduler_bundle.cue | 56 ++++++++++++++++++++++++++++++ .github/workflows/dagger_style.yml | 26 ++++++++++++++ .gitignore | 3 ++ .symfony.insight.yaml | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .cloud/dagger/scheduler_bundle.cue create mode 100644 .github/workflows/dagger_style.yml diff --git a/.cloud/dagger/scheduler_bundle.cue b/.cloud/dagger/scheduler_bundle.cue new file mode 100644 index 00000000..12602a57 --- /dev/null +++ b/.cloud/dagger/scheduler_bundle.cue @@ -0,0 +1,56 @@ +package scheduler_bundle + +import ( + "dagger.io/dagger" + "universe.dagger.io/docker" +) + +dagger.#Plan & { + _vendorMount: "/srv/app/vendor": { + dest: "/srv/app/vendor", + type: "cache", + contents: id: "vendor-cache" + } + + client: { + filesystem: "./": read: exclude: [".cloud/dagger", ".github", ".changelog", ".gitattributes", ".gitignore", "doc", "CONTRIBUTING.md", "README.md", "vendor"] + env: APP_ENV: "test" + } + + actions: { + build: docker.#Build & { + #Run: docker.#Run & { + command: name: "composer" + } + steps: [ + docker.#Dockerfile & { + source: client.filesystem."./".read.contents + dockerfile: path: ".cloud/docker/Dockerfile" + }, + #Run & { + command: args: ["update", "--prefer-stable"] + mounts: _vendorMount + }, + #Run & { + command: args: ["dump-autoload", "--optimize", "--classmap-authoritative"] + }, + ] + } + #Run: docker.#Run & { + input: build.output + mounts: _vendorMount + } + php_cs_fixer: #Run & { + command: { + name: "vendor/bin/php-cs-fixer" + args: ["fix", "--allow-risky=yes", "--dry-run"] + } + } + phpstan: #Run & { + command: { + name: "vendor/bin/phpstan" + args: ["analyze", "--xdebug"] + } + } + } +} diff --git a/.github/workflows/dagger_style.yml b/.github/workflows/dagger_style.yml new file mode 100644 index 00000000..1b03e5dc --- /dev/null +++ b/.github/workflows/dagger_style.yml @@ -0,0 +1,26 @@ +name: Dagger - Style +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: "0 0 * * *" + +env: + DAGGER_LOG_FORMAT: plain + +jobs: + dagger: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: PHP-CS-Fixer + uses: dagger/dagger-for-github@v2 + with: + workdir: pkg/universe.dagger.io/examples/todoapp + args: do php_cs_fixer --plan .cloud/dagger/scheduler_bundle.cue diff --git a/.gitignore b/.gitignore index 4fd8718f..4bae85a1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ tests/.assets/**/*.json # Docker docker-compose.override.yaml + +# Dagger +cue.mod diff --git a/.symfony.insight.yaml b/.symfony.insight.yaml index c2582f25..3d41ec5f 100644 --- a/.symfony.insight.yaml +++ b/.symfony.insight.yaml @@ -1,4 +1,4 @@ -php_version: 7.4 +php_version: 8.0 global_exclude_dirs: - .github From 56a74add15855ca96dd0faf7ce5450a14d43a3ab Mon Sep 17 00:00:00 2001 From: Guillaume Loulier Date: Mon, 4 Apr 2022 15:35:16 +0200 Subject: [PATCH 2/3] refactor(ci): Dagger introduced --- .github/workflows/dagger_style.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dagger_style.yml b/.github/workflows/dagger_style.yml index 1b03e5dc..7dd1121c 100644 --- a/.github/workflows/dagger_style.yml +++ b/.github/workflows/dagger_style.yml @@ -22,5 +22,4 @@ jobs: - name: PHP-CS-Fixer uses: dagger/dagger-for-github@v2 with: - workdir: pkg/universe.dagger.io/examples/todoapp args: do php_cs_fixer --plan .cloud/dagger/scheduler_bundle.cue From 48b1e20b4098f92bfc241b366955c354e167f324 Mon Sep 17 00:00:00 2001 From: Guillaume Loulier Date: Thu, 14 Apr 2022 08:52:09 +0200 Subject: [PATCH 3/3] ci(dagger): improvements --- .cloud/dagger/scheduler_bundle.cue | 61 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/.cloud/dagger/scheduler_bundle.cue b/.cloud/dagger/scheduler_bundle.cue index 12602a57..99ab85a9 100644 --- a/.cloud/dagger/scheduler_bundle.cue +++ b/.cloud/dagger/scheduler_bundle.cue @@ -18,38 +18,39 @@ dagger.#Plan & { } actions: { - build: docker.#Build & { - #Run: docker.#Run & { - command: name: "composer" - } - steps: [ - docker.#Dockerfile & { - source: client.filesystem."./".read.contents - dockerfile: path: ".cloud/docker/Dockerfile" - }, - #Run & { - command: args: ["update", "--prefer-stable"] - mounts: _vendorMount - }, - #Run & { - command: args: ["dump-autoload", "--optimize", "--classmap-authoritative"] - }, - ] - } - #Run: docker.#Run & { - input: build.output - mounts: _vendorMount + #Composer: docker.#Run & { + command: name: "composer" } - php_cs_fixer: #Run & { - command: { - name: "vendor/bin/php-cs-fixer" - args: ["fix", "--allow-risky=yes", "--dry-run"] - } + composer: docker.#Pull & { + source: "composer" } - phpstan: #Run & { - command: { - name: "vendor/bin/phpstan" - args: ["analyze", "--xdebug"] + [tag=string]: { + versions: { + "8.0": _, + "8.1": _, + build: docker.#Build & { + #Run: docker.#Run & { + input: build.output + mounts: _vendorMount + } + steps: [ + docker.#Pull & { + source: "php:\(tag)" + }, + docker.#Copy & { + input: composer.output + contents: build.output + path: "/usr/bin/composer" + }, + #Composer & { + command: args: ["update", "--prefer-stable"] + mounts: _vendorMount + }, + #Composer & { + command: args: ["dump-autoload", "--optimize", "--classmap-authoritative"] + }, + ] + } } } }