From ef7351087e959f6b8cda80d0be93849f8c31df07 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 10:30:13 +0200 Subject: [PATCH 01/50] chore: add `ghawac` scripts --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 14d44646ec5..dc5e983a9c3 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,8 @@ "scripts": { "awp": "yarn add-webiny-package", "add-webiny-package": "node scripts/addWebinyPackage.js", + "ci-workflows:build": "yarn ghawac build", + "ci-workflows:watch": "yarn ghawac watch", "check-ts-configs": "node scripts/checkTsConfigs.js", "check-package-dependencies": "node scripts/checkPackageNodeModules.js", "deploy": "yarn webiny deploy", From 859ba3f925d3dc4ebee7d1825dee60cd216dd4fa Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 10:31:24 +0200 Subject: [PATCH 02/50] ci: try blacksmith --- .github/workflows/pushDev.yml | 4 ++-- .github/workflows/pushNext.yml | 4 ++-- .github/workflows/wac/push.wac.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 62b6bd4c49b..796786c6feb 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -50,7 +50,7 @@ jobs: build: name: Build needs: init - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -114,7 +114,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index e924e57c179..d4f78312c31 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -50,7 +50,7 @@ jobs: build: name: Build needs: init - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -114,7 +114,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 30ae1cd84e7..e11494b142b 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -264,7 +264,7 @@ const createPushWorkflow = (branchName: string) => { build: createJob({ name: "Build", needs: "init", - "runs-on": "webiny-build-packages", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ { uses: "actions/cache@v4", @@ -342,7 +342,7 @@ const createPushWorkflow = (branchName: string) => { }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", - "runs-on": "webiny-build-packages", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ { uses: "actions/cache@v4", From 06c542932eaca2e02373c67b464bd15af6c7a95f Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 10:42:04 +0200 Subject: [PATCH 03/50] ci:jest jobs need build job [no ci] --- .github/workflows/pullRequests.yml | 24 +++++++++++++++-------- .github/workflows/wac/pullRequests.wac.ts | 10 +++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 33d3cb747d7..2481f96e9bd 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -72,8 +72,8 @@ jobs: run: >- echo "is-fork-pr=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_OUTPUT - init: - name: Init + build: + name: Build needs: constants runs-on: webiny-build-packages steps: @@ -103,7 +103,7 @@ jobs: staticCodeAnalysis: needs: - constants - - init + - build name: Static code analysis steps: - uses: actions/setup-node@v4 @@ -154,7 +154,9 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false jestTestsNoStorage: - needs: constants + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -191,7 +193,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdb: - needs: constants + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -243,7 +247,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdbEs: - needs: constants + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -303,7 +309,9 @@ jobs: id-token: write if: needs.constants.outputs.is-fork-pr != 'true' jestTestsDdbOs: - needs: constants + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -366,7 +374,7 @@ jobs: name: Publish to Verdaccio needs: - constants - - init + - build if: needs.constants.outputs.is-fork-pr != 'true' steps: - uses: actions/setup-node@v4 diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index ed0e206cc03..9ec98b92a24 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -54,7 +54,7 @@ const createJestTestsJob = (storage: string | null) => { }); const job: NormalJob = createJob({ - needs: "constants", + needs: ["constants", "build"], name: "${{ matrix.package.cmd }}", strategy: { "fail-fast": false, @@ -145,8 +145,8 @@ export const pullRequests = createWorkflow({ } ] }, - init: createJob({ - name: "Init", + build: createJob({ + name: "Build", needs: "constants", "runs-on": "webiny-build-packages", steps: [ @@ -166,7 +166,7 @@ export const pullRequests = createWorkflow({ ] }), staticCodeAnalysis: createJob({ - needs: ["constants", "init"], + needs: ["constants", "build"], name: "Static code analysis", steps: [ ...yarnCacheSteps, @@ -224,7 +224,7 @@ export const pullRequests = createWorkflow({ verdaccioPublish: createJob({ name: "Publish to Verdaccio", - needs: ["constants", "init"], + needs: ["constants", "build"], if: "needs.constants.outputs.is-fork-pr != 'true'", checkout: { "fetch-depth": 0, From dd6b6d99e954e26a93a1e2e75a5c106348759dce Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 10:54:14 +0200 Subject: [PATCH 04/50] ci: try blacksmith [no ci] --- .github/workflows/pullRequests.yml | 4 ++-- .github/workflows/wac/pullRequests.wac.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 2481f96e9bd..450a2e4eb1d 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -75,7 +75,7 @@ jobs: build: name: Build needs: constants - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -134,7 +134,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: webiny-build-packages + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index 9ec98b92a24..5596c322649 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -148,7 +148,7 @@ export const pullRequests = createWorkflow({ build: createJob({ name: "Build", needs: "constants", - "runs-on": "webiny-build-packages", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, ...buildGlobalCacheSteps, @@ -195,7 +195,7 @@ export const pullRequests = createWorkflow({ }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", - "runs-on": "webiny-build-packages", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, From 9cecab19a3d80ed4bfa52033dfb20f192ff94fe0 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 12:57:05 +0200 Subject: [PATCH 05/50] ci: try blacksmith [no ci] --- .github/workflows/pullRequests.yml | 4 ++-- .github/workflows/wac/pullRequests.wac.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 450a2e4eb1d..af54d1a569d 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -75,7 +75,7 @@ jobs: build: name: Build needs: constants - runs-on: blacksmith-4vcpu-ubuntu-2204 + runs-on: blacksmith-8vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -134,7 +134,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: blacksmith-4vcpu-ubuntu-2204 + runs-on: blacksmith-8vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index 5596c322649..6b988bf034c 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -148,7 +148,7 @@ export const pullRequests = createWorkflow({ build: createJob({ name: "Build", needs: "constants", - "runs-on": "blacksmith-4vcpu-ubuntu-2204", + "runs-on": "blacksmith-8vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, ...buildGlobalCacheSteps, @@ -195,7 +195,7 @@ export const pullRequests = createWorkflow({ }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", - "runs-on": "blacksmith-4vcpu-ubuntu-2204", + "runs-on": "blacksmith-8vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, From f9334e396773ec989cb7c446dd353bdaf2900c9c Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:02:18 +0200 Subject: [PATCH 06/50] ci:jest jobs need build job --- .../workflows/pullRequestsCommandCypress.yml | 6 +- .github/workflows/pushDev.yml | 449 ++++++++--------- .github/workflows/pushNext.yml | 457 ++++++++---------- .../workflows/wac/jobs/createJestTestsJob.ts | 77 --- .github/workflows/wac/jobs/index.ts | 1 - .../wac/pullRequestsCommandCypress.wac.ts | 2 +- .github/workflows/wac/push.wac.ts | 399 ++++++++------- 7 files changed, 584 insertions(+), 807 deletions(-) delete mode 100644 .github/workflows/wac/jobs/createJestTestsJob.ts diff --git a/.github/workflows/pullRequestsCommandCypress.yml b/.github/workflows/pullRequestsCommandCypress.yml index 5569af32e82..0d78e311bc3 100644 --- a/.github/workflows/pullRequestsCommandCypress.yml +++ b/.github/workflows/pullRequestsCommandCypress.yml @@ -171,7 +171,7 @@ jobs: with: name: verdaccio-files-ddb retention-days: 1 - path: | + path: |- checked-out-pr/.verdaccio/ checked-out-pr/.verdaccio.yaml - name: Disable Webiny telemetry @@ -412,7 +412,7 @@ jobs: with: name: verdaccio-files-ddb-es retention-days: 1 - path: | + path: |- checked-out-pr/.verdaccio/ checked-out-pr/.verdaccio.yaml - name: Disable Webiny telemetry @@ -658,7 +658,7 @@ jobs: with: name: verdaccio-files-ddb-os retention-days: 1 - path: | + path: |- checked-out-pr/.verdaccio/ checked-out-pr/.verdaccio.yaml - name: Disable Webiny telemetry diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 796786c6feb..6b3a1fd1960 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -23,33 +23,34 @@ jobs: env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false - init: - name: Init + constants: + name: Create constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} + run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day + - name: Create global cache key + id: global-cache-key run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> + echo "global-cache-key=${{ github.base_ref }}-${{ runner.os + }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp + - name: Create workflow run cache key + id: run-cache-key run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT + echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ + vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build - needs: init + needs: constants runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 @@ -57,26 +58,21 @@ jobs: node-version: 18 - uses: actions/checkout@v4 - uses: actions/cache@v4 - id: yarn-cache with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: global-daily-packages-cache with: - path: .webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages run: yarn build:quick - uses: actions/cache@v4 - id: packages-cache with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -92,12 +88,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Check code formatting @@ -122,7 +118,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable @@ -134,7 +130,9 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false jestTestsNoStorage: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -158,12 +156,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -171,7 +169,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdb: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -210,12 +210,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -223,7 +223,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdbEs: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -267,12 +269,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -281,9 +283,10 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - if: needs.init.outputs.is-fork-pr != 'true' jestTestsDdbOs: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -327,12 +330,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -341,39 +344,35 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - if: needs.init.outputs.is-fork-pr != 'true' e2eTestsDdb-init: - name: E2E (DDB) - Init + name: Constants - DDB + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-setup: - needs: e2eTestsDdb-init + needs: + - build + - e2eTestsDdb-init name: E2E (DDB) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -384,9 +383,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -401,30 +398,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -435,71 +423,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -526,9 +513,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -538,62 +523,53 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2eTestsDdb-es-init: - name: E2E (DDB-ES) - Init + name: Constants - DDB-ES + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-es" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-es-setup: - needs: e2eTestsDdb-es-init + needs: + - build + - e2eTestsDdb-es-init name: E2E (DDB-ES) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -604,12 +580,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-es-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-es-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -624,30 +598,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-es-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-es-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -658,71 +623,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb-es"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb-es retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -749,12 +713,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-es-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-es-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -764,62 +726,53 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-es-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2eTestsDdb-os-init: - name: E2E (DDB-OS) - Init + name: Constants - DDB-OS + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-os" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-os-setup: - needs: e2eTestsDdb-os-init + needs: + - build + - e2eTestsDdb-os-init name: E2E (DDB-OS) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -830,12 +783,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-os-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-os-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -850,30 +801,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-os-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-os-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -884,71 +826,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb-os"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb-os retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -975,12 +916,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-os-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-os-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -990,27 +929,21 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-os-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index d4f78312c31..973be746059 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -23,33 +23,34 @@ jobs: env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false - init: - name: Init + constants: + name: Create constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} + run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day + - name: Create global cache key + id: global-cache-key run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> + echo "global-cache-key=${{ github.base_ref }}-${{ runner.os + }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp + - name: Create workflow run cache key + id: run-cache-key run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT + echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ + vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build - needs: init + needs: constants runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 @@ -57,26 +58,21 @@ jobs: node-version: 18 - uses: actions/checkout@v4 - uses: actions/cache@v4 - id: yarn-cache with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: global-daily-packages-cache with: - path: .webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages run: yarn build:quick - uses: actions/cache@v4 - id: packages-cache with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -92,12 +88,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Check code formatting @@ -122,7 +118,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable @@ -134,7 +130,9 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false jestTestsNoStorage: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -158,12 +156,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -171,7 +169,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdb: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -210,12 +210,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -223,7 +223,9 @@ jobs: - name: Run tests run: yarn test ${{ matrix.package.cmd }} jestTestsDdbEs: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -267,12 +269,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -281,9 +283,10 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - if: needs.init.outputs.is-fork-pr != 'true' jestTestsDdbOs: - needs: init + needs: + - constants + - build name: ${{ matrix.package.cmd }} strategy: fail-fast: false @@ -327,12 +330,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages @@ -341,39 +344,35 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - if: needs.init.outputs.is-fork-pr != 'true' e2eTestsDdb-init: - name: E2E (DDB) - Init + name: Constants - DDB + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-setup: - needs: e2eTestsDdb-init + needs: + - build + - e2eTestsDdb-init name: E2E (DDB) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -384,9 +383,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -401,30 +398,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -435,71 +423,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -526,9 +513,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -538,62 +523,53 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2eTestsDdb-es-init: - name: E2E (DDB-ES) - Init + name: Constants - DDB-ES + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-es" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-es-setup: - needs: e2eTestsDdb-es-init + needs: + - build + - e2eTestsDdb-es-init name: E2E (DDB-ES) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -604,12 +580,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-es-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-es-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -624,30 +598,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-es-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-es-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -658,71 +623,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb-es"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb-es retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -749,12 +713,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-es-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-es-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -764,62 +726,53 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-es-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2eTestsDdb-os-init: - name: E2E (DDB-OS) - Init + name: Constants - DDB-OS + needs: constants outputs: - day: ${{ steps.get-day.outputs.day }} - ts: ${{ steps.get-timestamp.outputs.ts }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - uses: actions/checkout@v4 - - name: Get day of the month - id: get-day - run: >- - echo "day=$(node --eval "console.log(new Date().getDate())")" >> - $GITHUB_OUTPUT - - name: Get timestamp - id: get-timestamp - run: >- - echo "ts=$(node --eval "console.log(new Date().getTime())")" >> - $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-os" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-os-setup: - needs: e2eTestsDdb-os-init + needs: + - build + - e2eTestsDdb-os-init name: E2E (DDB-OS) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -830,12 +783,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-os-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-os-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -850,30 +801,21 @@ jobs: fetch-depth: 0 path: dev - uses: actions/cache@v4 - id: yarn-cache with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: cloned-repo/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 - id: cached-packages with: - path: dev/.webiny/cached-packages - key: >- - ${{ runner.os }}-${{ needs.e2eTestsDdb-os-init.outputs.day }}-${{ - secrets.RANDOM_CACHE_KEY_SUFFIX }} + path: cloned-repo/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev + working-directory: cloned-repo run: yarn --immutable - name: Build packages - working-directory: dev + working-directory: cloned-repo run: yarn build:quick - - uses: actions/cache@v4 - id: packages-cache - with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-os-init.outputs.ts }} - name: Start Verdaccio local server - working-directory: dev + working-directory: cloned-repo run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -884,71 +826,70 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: dev + working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: dev + working-directory: cloned-repo run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 - path: | - dev/.verdaccio/ - dev/.verdaccio.yaml - - name: Create directory - run: mkdir xyz + path: |- + cloned-repo/.verdaccio/ + cloned-repo/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config + - name: Create directory + run: mkdir xyz - name: Create a new Webiny project - working-directory: xyz run: > - npx create-webiny-project@local-npm test-project --tag local-npm + npx create-webiny-project@local-npm new-webiny-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"${{ env.AWS_REGION }}","storageOperations":"ddb-os"}' - name: Print CLI version - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny --version - name: Create project-files artifact uses: actions/upload-artifact@v4 with: name: project-files-ddb-os retention-days: 1 - path: | - xyz/test-project/ - !xyz/test-project/node_modules/**/* - !xyz/test-project/**/node_modules/**/* - !xyz/test-project/.yarn/cache/**/* + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* - name: Deploy Core - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/core --env dev - name: Deploy API - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/api --env dev - name: Deploy Admin Area - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/admin --env dev - name: Deploy Website - working-directory: xyz/test-project + working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: dev + working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../xyz/test-project - name: Save Cypress config id: save-cypress-config - working-directory: dev + working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: dev/cypress-tests + working-directory: cloned-repo run: >- - yarn cypress run --browser chrome --spec + yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" runs-on: ubuntu-latest permissions: @@ -975,12 +916,10 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: >- - ${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - needs.e2eTestsDdb-os-init.outputs.ts }}_ddb + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ needs.e2eTestsDdb-os-init.outputs.ts }}_ + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ steps: - uses: actions/setup-node@v4 with: @@ -990,33 +929,27 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: dev/.webiny/cached-packages - key: packages-cache-${{ needs.e2eTestsDdb-os-init.outputs.ts }} + path: /.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: dev run: yarn --immutable - name: Build packages - working-directory: dev run: yarn build:quick - name: Set up Cypress config - working-directory: dev run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests - working-directory: dev/cypress-tests timeout-minutes: 40 - run: >- - yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder - }}" + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest npmReleaseUnstable: needs: - - init + - constants - codeAnalysis - jestTestsNoStorage - jestTestsDdb @@ -1041,12 +974,12 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - path: .yarn/cache + path: /.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages - key: packages-cache-${{ needs.init.outputs.ts }} + path: /.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - name: Build packages diff --git a/.github/workflows/wac/jobs/createJestTestsJob.ts b/.github/workflows/wac/jobs/createJestTestsJob.ts deleted file mode 100644 index 3651497c542..00000000000 --- a/.github/workflows/wac/jobs/createJestTestsJob.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { listPackagesWithJestTests, NODE_VERSION } from "../utils"; -import { NormalJob } from "github-actions-wac"; -import { createJob } from "./createJob"; - -export const createJestTestsJob = (storage: string | null) => { - const env: Record = {}; - - if (storage) { - if (storage === "ddb-es") { - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; - env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; - } else if (storage === "ddb-os") { - // We still use the same environment variables as for "ddb-es" setup, it's - // just that the values are read from different secrets. - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; - env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; - } - } - - const packages = listPackagesWithJestTests({ - storage - }); - - const job: NormalJob = createJob({ - needs: "init", - name: "${{ matrix.package.cmd }}", - strategy: { - "fail-fast": false, - matrix: { - os: ["ubuntu-latest"], - node: [NODE_VERSION], - package: "${{ fromJson('" + JSON.stringify(packages) + "') }}" - } - }, - "runs-on": "${{ matrix.os }}", - env, - awsAuth: storage === "ddb-es" || storage === "ddb-os", - steps: [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - }, - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "packages-cache-${{ needs.init.outputs.ts }}" - } - }, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, - { - name: "Run tests", - run: "yarn test ${{ matrix.package.cmd }}" - } - ] - }); - - // We prevent running of Jest tests if a PR was created from a fork. - // This is because we don't want to expose our AWS credentials to forks. - if (storage === "ddb-es" || storage === "ddb-os") { - job.if = "needs.init.outputs.is-fork-pr != 'true'"; - } - - return job; -}; diff --git a/.github/workflows/wac/jobs/index.ts b/.github/workflows/wac/jobs/index.ts index 1baa4fd33ff..0d800a8d821 100644 --- a/.github/workflows/wac/jobs/index.ts +++ b/.github/workflows/wac/jobs/index.ts @@ -1,3 +1,2 @@ export * from "./createJob"; export * from "./createValidateWorkflowsJob"; -export * from "./createJestTestsJob"; diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index f4a116a932b..5e92fb74c7c 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -152,7 +152,7 @@ const createJobs = (dbSetup: string) => { with: { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, - path: [DIR_PR + "/.verdaccio/", DIR_PR + "/.verdaccio.yaml\n"].join("\n") + path: [DIR_PR + "/.verdaccio/", DIR_PR + "/.verdaccio.yaml"].join("\n") } }, { diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index e11494b142b..5c99bd36158 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -1,39 +1,86 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; -import { createJestTestsJob, createJob, createValidateWorkflowsJob } from "./jobs"; +import { createJob, createValidateWorkflowsJob } from "./jobs"; import { createDeployWebinySteps, createSetupVerdaccioSteps } from "./steps"; -import { NODE_VERSION } from "./utils"; +import { listPackagesWithJestTests, NODE_VERSION } from "./utils"; + +const DIR_CLONED_REPO = "cloned-repo"; +const DIR_TEST_PROJECT = "new-webiny-project"; + +interface CacheStepsFactoryParams { + workingDirectory?: string; +} + +const createYarnCacheSteps = ( + params: CacheStepsFactoryParams = {} +): NonNullable => { + const workingDirectory = params.workingDirectory || ""; + return [ + { + uses: "actions/cache@v4", + with: { + path: [workingDirectory, ".yarn/cache"].join("/"), + key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" + } + } + ]; +}; + +const createBuildGlobalCacheSteps = ( + params: CacheStepsFactoryParams = {} +): NonNullable => { + const workingDirectory = params.workingDirectory || ""; + return [ + { + uses: "actions/cache@v4", + with: { + path: [workingDirectory, ".webiny/cached-packages"].join("/"), + key: "${{ needs.constants.outputs.global-cache-key }}" + } + } + ]; +}; + +const createBuildRunCacheSteps = ( + params: CacheStepsFactoryParams = {} +): NonNullable => { + const workingDirectory = params.workingDirectory || ""; + return [ + { + uses: "actions/cache@v4", + with: { + path: [workingDirectory, ".webiny/cached-packages"].join("/"), + key: "${{ needs.constants.outputs.run-cache-key }}" + } + } + ]; +}; const createCypressJobs = (dbSetup: string) => { const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); const jobNames = { - init: `e2eTests${ucFirstDbSetup}-init`, + constants: `e2eTests${ucFirstDbSetup}-init`, projectSetup: `e2eTests${ucFirstDbSetup}-setup`, cypressTests: `e2eTests${ucFirstDbSetup}-cypress` }; const initJob: NormalJob = createJob({ - name: `E2E (${dbSetup.toUpperCase()}) - Init`, + name: `Constants - ${dbSetup.toUpperCase()}`, + needs: "constants", outputs: { - day: "${{ steps.get-day.outputs.day }}", - ts: "${{ steps.get-timestamp.outputs.ts }}", - "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}" + "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", + "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, steps: [ - { - name: "Get day of the month", - id: "get-day", - run: 'echo "day=$(node --eval "console.log(new Date().getDate())")" >> $GITHUB_OUTPUT' - }, - { - name: "Get timestamp", - id: "get-timestamp", - run: 'echo "ts=$(node --eval "console.log(new Date().getTime())")" >> $GITHUB_OUTPUT' - }, { name: "List Cypress tests folders", id: "list-cypress-folders", run: 'echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT' + }, + { + name: "Get Pulumi backend URL", + id: "get-pulumi-backend-url", + run: `echo "pulumi-backend-url=\${{ secrets.WEBINY_PULUMI_BACKEND }}\${{ github.run_id }}_${dbSetup}" >> $GITHUB_OUTPUT` } ] }); @@ -42,24 +89,24 @@ const createCypressJobs = (dbSetup: string) => { CYPRESS_MAILOSAUR_API_KEY: "${{ secrets.CYPRESS_MAILOSAUR_API_KEY }}", PULUMI_CONFIG_PASSPHRASE: "${{ secrets.PULUMI_CONFIG_PASSPHRASE }}", PULUMI_SECRETS_PROVIDER: "${{ secrets.PULUMI_SECRETS_PROVIDER }}", - WEBINY_PULUMI_BACKEND: `$\{{ secrets.WEBINY_PULUMI_BACKEND }}$\{{ needs.${jobNames.init}.outputs.ts }}_ddb`, + WEBINY_PULUMI_BACKEND: `\${{ needs.${jobNames.constants}.outputs.pulumi-backend-url }}`, YARN_ENABLE_IMMUTABLE_INSTALLS: "false" }; if (dbSetup === "ddb-es") { env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = `$\{{ needs.${jobNames.init}.outputs.ts }}_`; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; } else if (dbSetup === "ddb-os") { // We still use the same environment variables as for "ddb-es" setup, it's // just that the values are read from different secrets. env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = `$\{{ needs.${jobNames.init}.outputs.ts }}_`; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; } const projectSetupJob: NormalJob = createJob({ - needs: jobNames.init, + needs: ["build", jobNames.constants], name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, outputs: { "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" @@ -72,49 +119,27 @@ const createCypressJobs = (dbSetup: string) => { }, awsAuth: true, steps: [ - { - uses: "actions/cache@v4", - id: "yarn-cache", - with: { - path: "dev/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }}" - } - }, - { - uses: "actions/cache@v4", - id: "cached-packages", - with: { - path: "dev/.webiny/cached-packages", - key: `$\{{ runner.os }}-$\{{ needs.${jobNames.init}.outputs.day }}-$\{{ secrets.RANDOM_CACHE_KEY_SUFFIX }}` - } - }, + ...createYarnCacheSteps({ workingDirectory: DIR_CLONED_REPO }), + ...createBuildRunCacheSteps({ workingDirectory: DIR_CLONED_REPO }), { name: "Install dependencies", - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "yarn --immutable" }, { name: "Build packages", - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "yarn build:quick" }, - { - uses: "actions/cache@v4", - id: "packages-cache", - with: { - path: "dev/.webiny/cached-packages", - key: `packages-cache-$\{{ needs.${jobNames.init}.outputs.ts }}` - } - }, - ...createSetupVerdaccioSteps({ workingDirectory: "dev" }), + ...createSetupVerdaccioSteps({ workingDirectory: DIR_CLONED_REPO }), { name: 'Create ".npmrc" file in the project root, with a dummy auth token', - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" }, { name: "Version and publish to Verdaccio", - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "yarn release --type=verdaccio" }, { @@ -123,26 +148,29 @@ const createCypressJobs = (dbSetup: string) => { with: { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, - path: "dev/.verdaccio/\ndev/.verdaccio.yaml\n" + path: [ + DIR_CLONED_REPO + "/.verdaccio/", + DIR_CLONED_REPO + "/.verdaccio.yaml" + ].join("\n") } }, - { - name: "Create directory", - run: "mkdir xyz" - }, { name: "Disable Webiny telemetry", run: 'mkdir ~/.webiny && echo \'{ "id": "ci", "telemetry": false }\' > ~/.webiny/config\n' }, + { + name: "Create directory", + run: "mkdir xyz" + }, + { name: "Create a new Webiny project", - "working-directory": "xyz", - run: `npx create-webiny-project@local-npm test-project --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"$\{{ env.AWS_REGION }}","storageOperations":"${dbSetup}"}' + run: `npx create-webiny-project@local-npm ${DIR_TEST_PROJECT} --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"$\{{ env.AWS_REGION }}","storageOperations":"${dbSetup}"}' ` }, { name: "Print CLI version", - "working-directory": "xyz/test-project", + "working-directory": DIR_TEST_PROJECT, run: "yarn webiny --version" }, { @@ -151,89 +179,127 @@ const createCypressJobs = (dbSetup: string) => { with: { name: `project-files-${dbSetup}`, "retention-days": 1, - path: "xyz/test-project/\n!xyz/test-project/node_modules/**/*\n!xyz/test-project/**/node_modules/**/*\n!xyz/test-project/.yarn/cache/**/*\n" + path: [ + `${DIR_TEST_PROJECT}/`, + `!${DIR_TEST_PROJECT}/node_modules/**/*`, + `!${DIR_TEST_PROJECT}/**/node_modules/**/*`, + `!${DIR_TEST_PROJECT}/.yarn/cache/**/*` + ].join("\n") } }, - ...createDeployWebinySteps({ workingDirectory: "xyz/test-project" }), + ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), + { name: "Create Cypress config", - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "yarn setup-cypress --projectFolder ../xyz/test-project" }, { name: "Save Cypress config", id: "save-cypress-config", - "working-directory": "dev", + "working-directory": DIR_CLONED_REPO, run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" }, { name: "Cypress - run installation wizard test", - "working-directory": "dev/cypress-tests", - run: 'yarn cypress run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' + "working-directory": DIR_CLONED_REPO, + run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' } ] }); const cypressTestsJob = createJob({ name: `$\{{ matrix.cypress-folder }} (${dbSetup}, $\{{ matrix.os }}, Node v$\{{ matrix.node }})`, - needs: [jobNames.init, jobNames.projectSetup], + needs: [jobNames.constants, jobNames.projectSetup], strategy: { "fail-fast": false, matrix: { os: ["ubuntu-latest"], node: [NODE_VERSION], - "cypress-folder": `$\{{ fromJson(needs.${jobNames.init}.outputs.cypress-folders) }}` + "cypress-folder": `$\{{ fromJson(needs.${jobNames.constants}.outputs.cypress-folders) }}` } }, environment: "next", env, checkout: { path: "dev" }, steps: [ - { - uses: "actions/cache@v4", - with: { - path: "dev/.webiny/cached-packages", - key: `packages-cache-$\{{ needs.${jobNames.init}.outputs.ts }}` - } - }, - { - uses: "actions/cache@v4", - with: { - path: "dev/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('dev/**/yarn.lock') }}" - } - }, - { - name: "Install dependencies", - "working-directory": "dev", - run: "yarn --immutable" - }, - { - name: "Build packages", - "working-directory": "dev", - run: "yarn build:quick" - }, + ...createYarnCacheSteps(), + ...createBuildRunCacheSteps(), + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages", run: "yarn build:quick" }, { name: "Set up Cypress config", - "working-directory": "dev", run: `echo '$\{{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` }, { name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', - "working-directory": "dev/cypress-tests", "timeout-minutes": 40, - run: 'yarn cypress run --browser chrome --spec "${{ matrix.cypress-folder }}"' + run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' } ] }); return { - [jobNames.init]: initJob, + [jobNames.constants]: initJob, [jobNames.projectSetup]: projectSetupJob, [jobNames.cypressTests]: cypressTestsJob }; }; +const createJestTestsJob = (storage: string | null) => { + const env: Record = {}; + + if (storage) { + if (storage === "ddb-es") { + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; + env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; + } else if (storage === "ddb-os") { + // We still use the same environment variables as for "ddb-es" setup, it's + // just that the values are read from different secrets. + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; + env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; + } + } + + const packages = listPackagesWithJestTests({ + storage + }); + + return createJob({ + needs: ["constants", "build"], + name: "${{ matrix.package.cmd }}", + strategy: { + "fail-fast": false, + matrix: { + os: ["ubuntu-latest"], + node: [NODE_VERSION], + package: "${{ fromJson('" + JSON.stringify(packages) + "') }}" + } + }, + "runs-on": "${{ matrix.os }}", + env, + awsAuth: storage === "ddb-es" || storage === "ddb-os", + steps: [ + ...createYarnCacheSteps(), + ...createBuildRunCacheSteps(), + { + name: "Install dependencies", + run: "yarn --immutable" + }, + { + name: "Build packages", + run: "yarn build:quick" + }, + { + name: "Run tests", + run: "yarn test ${{ matrix.package.cmd }}" + } + ] + }); +}; + const createPushWorkflow = (branchName: string) => { const ucFirstBranchName = branchName.charAt(0).toUpperCase() + branchName.slice(1); @@ -242,127 +308,62 @@ const createPushWorkflow = (branchName: string) => { on: { push: { branches: [branchName] } }, jobs: { validateWorkflows: createValidateWorkflowsJob(), - init: createJob({ - name: "Init", + constants: createJob({ + name: "Create constants", outputs: { - day: "${{ steps.get-day.outputs.day }}", - ts: "${{ steps.get-timestamp.outputs.ts }}" + "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", + "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" }, steps: [ { - name: "Get day of the month", - id: "get-day", - run: 'echo "day=$(node --eval "console.log(new Date().getDate())")" >> $GITHUB_OUTPUT' + name: "Create global cache key", + id: "global-cache-key", + run: 'echo "global-cache-key=${{ github.base_ref }}-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' }, { - name: "Get timestamp", - id: "get-timestamp", - run: 'echo "ts=$(node --eval "console.log(new Date().getTime())")" >> $GITHUB_OUTPUT' + name: "Create workflow run cache key", + id: "run-cache-key", + run: 'echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' } ] }), build: createJob({ name: "Build", - needs: "init", + needs: "constants", "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ - { - uses: "actions/cache@v4", - id: "yarn-cache", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - }, - { - uses: "actions/cache@v4", - id: "global-daily-packages-cache", - with: { - path: ".webiny/cached-packages", - key: "${{ runner.os }}-${{ needs.init.outputs.day }}-${{ secrets.RANDOM_CACHE_KEY_SUFFIX }}" - } - }, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, - { - uses: "actions/cache@v4", - id: "packages-cache", - with: { - path: ".webiny/cached-packages", - key: "packages-cache-${{ needs.init.outputs.ts }}" - } - } + ...createYarnCacheSteps(), + ...createBuildGlobalCacheSteps(), + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages", run: "yarn build:quick" }, + ...createBuildRunCacheSteps() ] }), codeAnalysis: createJob({ name: "Static code analysis", needs: ["init", "build"], steps: [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - }, - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "packages-cache-${{ needs.init.outputs.ts }}" - } - }, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Check code formatting", - run: "yarn prettier:check" - }, - { - name: "Check dependencies", - run: "yarn adio" - }, - { - name: "Check TS configs", - run: "yarn check-ts-configs" - }, - { - name: "ESLint", - run: "yarn eslint" - } + ...createYarnCacheSteps(), + ...createBuildRunCacheSteps(), + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Check code formatting", run: "yarn prettier:check" }, + { name: "Check dependencies", run: "yarn adio" }, + { name: "Check TS configs", run: "yarn check-ts-configs" }, + { name: "ESLint", run: "yarn eslint" } ] }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - }, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages (full)", - run: "yarn build" - }, - { - name: "Check types for Cypress tests", - run: "yarn cy:ts" - } + ...createYarnCacheSteps(), + + // We're not using run cache here. We want to build all packages + // with TypeScript, to ensure there are no TypeScript errors. + // ...createBuildRunCacheSteps, + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages (full)", run: "yarn build" }, + { name: "Check types for Cypress tests", run: "yarn cy:ts" } ] }), jestTestsNoStorage: createJestTestsJob(null), @@ -380,7 +381,7 @@ const createPushWorkflow = (branchName: string) => { const e2eJobsNames = Object.keys(workflow.jobs).filter(name => name.endsWith("cypress")); workflow.jobs.npmReleaseUnstable = createJob({ - needs: ["init", "codeAnalysis", ...jestJobsNames, ...e2eJobsNames], + needs: ["constants", "codeAnalysis", ...jestJobsNames, ...e2eJobsNames], name: 'NPM release ("unstable" tag)', environment: "release", env: { @@ -389,20 +390,8 @@ const createPushWorkflow = (branchName: string) => { }, checkout: { "fetch-depth": 0 }, steps: [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - }, - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "packages-cache-${{ needs.init.outputs.ts }}" - } - }, + ...createYarnCacheSteps(), + ...createBuildRunCacheSteps(), { name: "Install dependencies", run: "yarn --immutable" From b4c9873077defdda70b0b7825eca631bc58404ea Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:03:11 +0200 Subject: [PATCH 07/50] ci:jest jobs need build job --- .github/workflows/pushDev.yml | 42 +++++++++++++++++-------------- .github/workflows/pushNext.yml | 42 +++++++++++++++++-------------- .github/workflows/wac/push.wac.ts | 8 +++--- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 6b3a1fd1960..6403621ca86 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -79,7 +79,7 @@ jobs: codeAnalysis: name: Static code analysis needs: - - init + - constants - build steps: - uses: actions/setup-node@v4 @@ -344,7 +344,7 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - e2eTestsDdb-init: + e2eTestsDdb-constants: name: Constants - DDB needs: constants outputs: @@ -372,7 +372,7 @@ jobs: e2eTestsDdb-setup: needs: - build - - e2eTestsDdb-init + - e2eTestsDdb-constants name: E2E (DDB) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -383,7 +383,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-constants.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -496,7 +496,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-init + - e2eTestsDdb-constants - e2eTestsDdb-setup strategy: fail-fast: false @@ -505,7 +505,7 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-init.outputs.cypress-folders) }} + cypress-folder: ${{ fromJson(needs.e2eTestsDdb-constants.outputs.cypress-folders) }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -513,7 +513,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-constants.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -541,7 +541,7 @@ jobs: timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest - e2eTestsDdb-es-init: + e2eTestsDdb-es-constants: name: Constants - DDB-ES needs: constants outputs: @@ -569,7 +569,7 @@ jobs: e2eTestsDdb-es-setup: needs: - build - - e2eTestsDdb-es-init + - e2eTestsDdb-es-constants name: E2E (DDB-ES) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -580,7 +580,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -696,7 +696,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-es-init + - e2eTestsDdb-es-constants - e2eTestsDdb-es-setup strategy: fail-fast: false @@ -705,7 +705,9 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-es-init.outputs.cypress-folders) }} + cypress-folder: >- + ${{ fromJson(needs.e2eTestsDdb-es-constants.outputs.cypress-folders) + }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -713,7 +715,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -744,7 +746,7 @@ jobs: timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest - e2eTestsDdb-os-init: + e2eTestsDdb-os-constants: name: Constants - DDB-OS needs: constants outputs: @@ -772,7 +774,7 @@ jobs: e2eTestsDdb-os-setup: needs: - build - - e2eTestsDdb-os-init + - e2eTestsDdb-os-constants name: E2E (DDB-OS) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -783,7 +785,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -899,7 +901,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-os-init + - e2eTestsDdb-os-constants - e2eTestsDdb-os-setup strategy: fail-fast: false @@ -908,7 +910,9 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-os-init.outputs.cypress-folders) }} + cypress-folder: >- + ${{ fromJson(needs.e2eTestsDdb-os-constants.outputs.cypress-folders) + }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -916,7 +920,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 973be746059..63ab3552a1d 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -79,7 +79,7 @@ jobs: codeAnalysis: name: Static code analysis needs: - - init + - constants - build steps: - uses: actions/setup-node@v4 @@ -344,7 +344,7 @@ jobs: run: yarn test ${{ matrix.package.cmd }} permissions: id-token: write - e2eTestsDdb-init: + e2eTestsDdb-constants: name: Constants - DDB needs: constants outputs: @@ -372,7 +372,7 @@ jobs: e2eTestsDdb-setup: needs: - build - - e2eTestsDdb-init + - e2eTestsDdb-constants name: E2E (DDB) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -383,7 +383,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-constants.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -496,7 +496,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-init + - e2eTestsDdb-constants - e2eTestsDdb-setup strategy: fail-fast: false @@ -505,7 +505,7 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-init.outputs.cypress-folders) }} + cypress-folder: ${{ fromJson(needs.e2eTestsDdb-constants.outputs.cypress-folders) }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -513,7 +513,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-constants.outputs.pulumi-backend-url }} steps: - uses: actions/setup-node@v4 with: @@ -541,7 +541,7 @@ jobs: timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest - e2eTestsDdb-es-init: + e2eTestsDdb-es-constants: name: Constants - DDB-ES needs: constants outputs: @@ -569,7 +569,7 @@ jobs: e2eTestsDdb-es-setup: needs: - build - - e2eTestsDdb-es-init + - e2eTestsDdb-es-constants name: E2E (DDB-ES) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -580,7 +580,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -696,7 +696,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-es-init + - e2eTestsDdb-es-constants - e2eTestsDdb-es-setup strategy: fail-fast: false @@ -705,7 +705,9 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-es-init.outputs.cypress-folders) }} + cypress-folder: >- + ${{ fromJson(needs.e2eTestsDdb-es-constants.outputs.cypress-folders) + }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -713,7 +715,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-es-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -744,7 +746,7 @@ jobs: timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest - e2eTestsDdb-os-init: + e2eTestsDdb-os-constants: name: Constants - DDB-OS needs: constants outputs: @@ -772,7 +774,7 @@ jobs: e2eTestsDdb-os-setup: needs: - build - - e2eTestsDdb-os-init + - e2eTestsDdb-os-constants name: E2E (DDB-OS) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -783,7 +785,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ @@ -899,7 +901,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: - - e2eTestsDdb-os-init + - e2eTestsDdb-os-constants - e2eTestsDdb-os-setup strategy: fail-fast: false @@ -908,7 +910,9 @@ jobs: - ubuntu-latest node: - 18 - cypress-folder: ${{ fromJson(needs.e2eTestsDdb-os-init.outputs.cypress-folders) }} + cypress-folder: >- + ${{ fromJson(needs.e2eTestsDdb-os-constants.outputs.cypress-folders) + }} environment: next env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -916,7 +920,7 @@ jobs: CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-init.outputs.pulumi-backend-url }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2eTestsDdb-os-constants.outputs.pulumi-backend-url }} AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 5c99bd36158..2f92409456f 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -59,12 +59,12 @@ const createCypressJobs = (dbSetup: string) => { const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); const jobNames = { - constants: `e2eTests${ucFirstDbSetup}-init`, + constants: `e2eTests${ucFirstDbSetup}-constants`, projectSetup: `e2eTests${ucFirstDbSetup}-setup`, cypressTests: `e2eTests${ucFirstDbSetup}-cypress` }; - const initJob: NormalJob = createJob({ + const constantsJob: NormalJob = createJob({ name: `Constants - ${dbSetup.toUpperCase()}`, needs: "constants", outputs: { @@ -240,7 +240,7 @@ const createCypressJobs = (dbSetup: string) => { }); return { - [jobNames.constants]: initJob, + [jobNames.constants]: constantsJob, [jobNames.projectSetup]: projectSetupJob, [jobNames.cypressTests]: cypressTestsJob }; @@ -341,7 +341,7 @@ const createPushWorkflow = (branchName: string) => { }), codeAnalysis: createJob({ name: "Static code analysis", - needs: ["init", "build"], + needs: ["constants", "build"], steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), From dde16179136efd3db676ab79642cb07e9dcee221 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:08:56 +0200 Subject: [PATCH 08/50] ci:jest jobs need build job --- .github/workflows/pushDev.yml | 3 --- .github/workflows/pushNext.yml | 3 --- .github/workflows/wac/push.wac.ts | 1 - 3 files changed, 7 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 6403621ca86..5e1be0343c6 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -346,7 +346,6 @@ jobs: id-token: write e2eTestsDdb-constants: name: Constants - DDB - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -543,7 +542,6 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -748,7 +746,6 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 63ab3552a1d..96a02b3c156 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -346,7 +346,6 @@ jobs: id-token: write e2eTestsDdb-constants: name: Constants - DDB - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -543,7 +542,6 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -748,7 +746,6 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS - needs: constants outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 2f92409456f..40f18f705c0 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -66,7 +66,6 @@ const createCypressJobs = (dbSetup: string) => { const constantsJob: NormalJob = createJob({ name: `Constants - ${dbSetup.toUpperCase()}`, - needs: "constants", outputs: { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" From a285ee0fb09c197b8424895ae96a1dac396f774c Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:11:48 +0200 Subject: [PATCH 09/50] ci:jest jobs need build job --- .github/workflows/pushDev.yml | 6 ++++++ .github/workflows/pushNext.yml | 6 ++++++ .github/workflows/wac/push.wac.ts | 1 + 3 files changed, 13 insertions(+) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 5e1be0343c6..62eab6542b6 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -346,6 +346,8 @@ jobs: id-token: write e2eTestsDdb-constants: name: Constants - DDB + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -542,6 +544,8 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -746,6 +750,8 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 96a02b3c156..a8b59588090 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -346,6 +346,8 @@ jobs: id-token: write e2eTestsDdb-constants: name: Constants - DDB + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -542,6 +544,8 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} @@ -746,6 +750,8 @@ jobs: runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS + needs: + - build outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 40f18f705c0..f68cf4af345 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -66,6 +66,7 @@ const createCypressJobs = (dbSetup: string) => { const constantsJob: NormalJob = createJob({ name: `Constants - ${dbSetup.toUpperCase()}`, + needs: ["build"], outputs: { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" From 5ab21ba6a11cb730e92be27f52c96988dc67318d Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:14:59 +0200 Subject: [PATCH 10/50] ci:jest jobs need build job --- .github/workflows/pushDev.yml | 5 ++--- .github/workflows/pushNext.yml | 5 ++--- .github/workflows/wac/push.wac.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 62eab6542b6..7483ba0a2ff 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -36,9 +36,8 @@ jobs: - name: Create global cache key id: global-cache-key run: >- - echo "global-cache-key=${{ github.base_ref }}-${{ runner.os - }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> - $GITHUB_OUTPUT + echo "global-cache-key=dev-${{ runner.os }}-$(/bin/date -u + "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - name: Create workflow run cache key id: run-cache-key run: >- diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index a8b59588090..85cba95e54e 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -36,9 +36,8 @@ jobs: - name: Create global cache key id: global-cache-key run: >- - echo "global-cache-key=${{ github.base_ref }}-${{ runner.os - }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> - $GITHUB_OUTPUT + echo "global-cache-key=next-${{ runner.os }}-$(/bin/date -u + "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - name: Create workflow run cache key id: run-cache-key run: >- diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index f68cf4af345..d1239d74197 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -318,7 +318,7 @@ const createPushWorkflow = (branchName: string) => { { name: "Create global cache key", id: "global-cache-key", - run: 'echo "global-cache-key=${{ github.base_ref }}-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' + run: `echo "global-cache-key=${branchName}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT` }, { name: "Create workflow run cache key", From f40eb0a9ba33b7bccc3d1fb082467c93a993bd7b Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 15:46:26 +0200 Subject: [PATCH 11/50] ci:jest jobs need build job --- .github/workflows/pushDev.yml | 40 ++++++++++++++-------------- .github/workflows/pushNext.yml | 44 +++++++++++++++---------------- .github/workflows/wac/push.wac.ts | 6 ++--- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 7483ba0a2ff..f2d28260e94 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -58,11 +58,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable @@ -70,7 +70,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -87,11 +87,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -117,7 +117,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable @@ -155,11 +155,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -209,11 +209,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -268,11 +268,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -329,11 +329,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -523,11 +523,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -729,11 +729,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -935,11 +935,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 85cba95e54e..d7761e678d8 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -58,11 +58,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable @@ -70,7 +70,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -87,11 +87,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -117,7 +117,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable @@ -155,11 +155,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -209,11 +209,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -268,11 +268,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -329,11 +329,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -523,11 +523,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -729,11 +729,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -935,11 +935,11 @@ jobs: path: dev - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable @@ -980,11 +980,11 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - path: /.yarn/cache + path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: /.webiny/cached-packages + path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index d1239d74197..6b5b870ff5a 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -18,7 +18,7 @@ const createYarnCacheSteps = ( { uses: "actions/cache@v4", with: { - path: [workingDirectory, ".yarn/cache"].join("/"), + path: [workingDirectory, ".yarn/cache"].filter(Boolean).join("/"), key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" } } @@ -33,7 +33,7 @@ const createBuildGlobalCacheSteps = ( { uses: "actions/cache@v4", with: { - path: [workingDirectory, ".webiny/cached-packages"].join("/"), + path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.global-cache-key }}" } } @@ -48,7 +48,7 @@ const createBuildRunCacheSteps = ( { uses: "actions/cache@v4", with: { - path: [workingDirectory, ".webiny/cached-packages"].join("/"), + path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.run-cache-key }}" } } From 7d95ecf85eff883173b4d321bab1ac85598ac7dc Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 16:32:09 +0200 Subject: [PATCH 12/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 3 +++ .github/workflows/pushNext.yml | 3 +++ .github/workflows/wac/push.wac.ts | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index f2d28260e94..b4347cb1e24 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -371,6 +371,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-setup: needs: + - constants - build - e2eTestsDdb-constants name: E2E (DDB) - Project setup @@ -569,6 +570,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-es-setup: needs: + - constants - build - e2eTestsDdb-es-constants name: E2E (DDB-ES) - Project setup @@ -775,6 +777,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-os-setup: needs: + - constants - build - e2eTestsDdb-os-constants name: E2E (DDB-OS) - Project setup diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index d7761e678d8..e79778cfc4f 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -371,6 +371,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-setup: needs: + - constants - build - e2eTestsDdb-constants name: E2E (DDB) - Project setup @@ -569,6 +570,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-es-setup: needs: + - constants - build - e2eTestsDdb-es-constants name: E2E (DDB-ES) - Project setup @@ -775,6 +777,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2eTestsDdb-os-setup: needs: + - constants - build - e2eTestsDdb-os-constants name: E2E (DDB-OS) - Project setup diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 6b5b870ff5a..e962fe13e43 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -106,7 +106,7 @@ const createCypressJobs = (dbSetup: string) => { } const projectSetupJob: NormalJob = createJob({ - needs: ["build", jobNames.constants], + needs: ["constants", "build", jobNames.constants], name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, outputs: { "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" From 6d6b3763dacb337e7998280c24ce0a7c5637646b Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 17:07:02 +0200 Subject: [PATCH 13/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 12 +++--------- .github/workflows/pushNext.yml | 12 +++--------- .github/workflows/wac/push.wac.ts | 3 +-- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index b4347cb1e24..8028a71be6a 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -397,7 +397,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -520,8 +520,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache @@ -599,7 +597,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -727,8 +725,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache @@ -806,7 +802,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -934,8 +930,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index e79778cfc4f..ee1922c4fa2 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -397,7 +397,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -520,8 +520,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache @@ -599,7 +597,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -727,8 +725,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache @@ -806,7 +802,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: dev + path: cloned-repo - uses: actions/cache@v4 with: path: cloned-repo/.yarn/cache @@ -934,8 +930,6 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 - with: - path: dev - uses: actions/cache@v4 with: path: .yarn/cache diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index e962fe13e43..c2d81d7594a 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -115,7 +115,7 @@ const createCypressJobs = (dbSetup: string) => { env, checkout: { "fetch-depth": 0, - path: "dev" + path: DIR_CLONED_REPO }, awsAuth: true, steps: [ @@ -221,7 +221,6 @@ const createCypressJobs = (dbSetup: string) => { }, environment: "next", env, - checkout: { path: "dev" }, steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), From a75db8656d41eace5bd7a0663cb44cf51388a98c Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 17:31:13 +0200 Subject: [PATCH 14/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 26 ++++++++++++++++++++++++++ .github/workflows/pushNext.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/wac/push.wac.ts | 3 +++ 3 files changed, 57 insertions(+) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 8028a71be6a..c8f81d6cbf2 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -58,10 +58,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies @@ -70,6 +72,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: @@ -87,10 +90,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -117,6 +122,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies @@ -155,10 +161,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -209,10 +217,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -268,10 +278,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -329,10 +341,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -400,10 +414,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -522,10 +538,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -600,10 +618,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -727,10 +747,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -805,10 +827,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -932,10 +956,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index ee1922c4fa2..678993faad9 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -58,10 +58,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies @@ -70,6 +72,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: @@ -87,10 +90,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -117,6 +122,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies @@ -155,10 +161,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -209,10 +217,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -268,10 +278,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -329,10 +341,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -400,10 +414,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -522,10 +538,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -600,10 +618,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -727,10 +747,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -805,10 +827,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -932,10 +956,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -977,10 +1003,12 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: + enableCrossOs: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: + enableCrossOs: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index c2d81d7594a..9d3f22430ce 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -18,6 +18,7 @@ const createYarnCacheSteps = ( { uses: "actions/cache@v4", with: { + enableCrossOs: true, path: [workingDirectory, ".yarn/cache"].filter(Boolean).join("/"), key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" } @@ -33,6 +34,7 @@ const createBuildGlobalCacheSteps = ( { uses: "actions/cache@v4", with: { + enableCrossOs: true, path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.global-cache-key }}" } @@ -48,6 +50,7 @@ const createBuildRunCacheSteps = ( { uses: "actions/cache@v4", with: { + enableCrossOs: true, path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.run-cache-key }}" } From 84845c6f5357b39d4cbdef7b9b0644a09ddd96b5 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 17:34:09 +0200 Subject: [PATCH 15/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 52 ++++++++++++++-------------- .github/workflows/pushNext.yml | 56 +++++++++++++++---------------- .github/workflows/wac/push.wac.ts | 6 ++-- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index c8f81d6cbf2..839b6d78d82 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -58,12 +58,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies @@ -72,7 +72,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: @@ -90,12 +90,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -122,7 +122,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies @@ -161,12 +161,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -217,12 +217,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -278,12 +278,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -341,12 +341,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -414,12 +414,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -538,12 +538,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -618,12 +618,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -747,12 +747,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -827,12 +827,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -956,12 +956,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 678993faad9..a7e359f89e1 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -58,12 +58,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies @@ -72,7 +72,7 @@ jobs: run: yarn build:quick - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: @@ -90,12 +90,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -122,7 +122,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies @@ -161,12 +161,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -217,12 +217,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -278,12 +278,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -341,12 +341,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -414,12 +414,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -538,12 +538,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -618,12 +618,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -747,12 +747,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -827,12 +827,12 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -956,12 +956,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies @@ -1003,12 +1003,12 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOs: true + enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 9d3f22430ce..54ae768c4b2 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -18,7 +18,7 @@ const createYarnCacheSteps = ( { uses: "actions/cache@v4", with: { - enableCrossOs: true, + enableCrossOsArchive: true, path: [workingDirectory, ".yarn/cache"].filter(Boolean).join("/"), key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" } @@ -34,7 +34,7 @@ const createBuildGlobalCacheSteps = ( { uses: "actions/cache@v4", with: { - enableCrossOs: true, + enableCrossOsArchive: true, path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.global-cache-key }}" } @@ -50,7 +50,7 @@ const createBuildRunCacheSteps = ( { uses: "actions/cache@v4", with: { - enableCrossOs: true, + enableCrossOsArchive: true, path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), key: "${{ needs.constants.outputs.run-cache-key }}" } From b7d41205f53ed8deb12d99ffe611555f19efdeb4 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 18:40:16 +0200 Subject: [PATCH 16/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 6 +++--- .github/workflows/pushNext.yml | 6 +++--- .github/workflows/wac/push.wac.ts | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 839b6d78d82..4850d805f34 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -493,7 +493,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo @@ -697,7 +697,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo @@ -906,7 +906,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index a7e359f89e1..fcf132b2a27 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -493,7 +493,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo @@ -697,7 +697,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo @@ -906,7 +906,7 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config working-directory: cloned-repo - run: yarn setup-cypress --projectFolder ../xyz/test-project + run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config working-directory: cloned-repo diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 54ae768c4b2..26adf1671c1 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -191,11 +191,10 @@ const createCypressJobs = (dbSetup: string) => { } }, ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), - { name: "Create Cypress config", "working-directory": DIR_CLONED_REPO, - run: "yarn setup-cypress --projectFolder ../xyz/test-project" + run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` }, { name: "Save Cypress config", From 7e8d30a27237a8085e83601d4347e1847b98c207 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 20:03:30 +0200 Subject: [PATCH 17/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 3 +++ .github/workflows/pushNext.yml | 3 +++ .github/workflows/wac/push.wac.ts | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 4850d805f34..4d427dc338d 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -513,6 +513,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-constants - e2eTestsDdb-setup strategy: @@ -717,6 +718,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-es-constants - e2eTestsDdb-es-setup strategy: @@ -926,6 +928,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-os-constants - e2eTestsDdb-os-setup strategy: diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index fcf132b2a27..c20402b8bfc 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -513,6 +513,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-constants - e2eTestsDdb-setup strategy: @@ -717,6 +718,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-es-constants - e2eTestsDdb-es-setup strategy: @@ -926,6 +928,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - constants - e2eTestsDdb-os-constants - e2eTestsDdb-os-setup strategy: diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 26adf1671c1..70d2c7ba13d 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -212,7 +212,7 @@ const createCypressJobs = (dbSetup: string) => { const cypressTestsJob = createJob({ name: `$\{{ matrix.cypress-folder }} (${dbSetup}, $\{{ matrix.os }}, Node v$\{{ matrix.node }})`, - needs: [jobNames.constants, jobNames.projectSetup], + needs: ["constants", jobNames.constants, jobNames.projectSetup], strategy: { "fail-fast": false, matrix: { From a7254eec399c2803e60a0ce3b4b7e2dfe88ad8a1 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 22:35:19 +0200 Subject: [PATCH 18/50] ci: improve pushDev/pushNext workflows (def) --- .github/workflows/pushDev.yml | 4 ++-- .github/workflows/pushNext.yml | 4 ++-- .github/workflows/wac/push.wac.ts | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 4d427dc338d..ba0bd81c064 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -50,7 +50,6 @@ jobs: build: name: Build needs: constants - runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -75,6 +74,7 @@ jobs: enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} + runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -114,7 +114,6 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -131,6 +130,7 @@ jobs: run: yarn build - name: Check types for Cypress tests run: yarn cy:ts + runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index c20402b8bfc..8f79022029b 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -50,7 +50,6 @@ jobs: build: name: Build needs: constants - runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -75,6 +74,7 @@ jobs: enableCrossOsArchive: true path: .webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} + runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -114,7 +114,6 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) - runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -131,6 +130,7 @@ jobs: run: yarn build - name: Check types for Cypress tests run: yarn cy:ts + runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 70d2c7ba13d..ece5f8e1e84 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -331,7 +331,6 @@ const createPushWorkflow = (branchName: string) => { build: createJob({ name: "Build", needs: "constants", - "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createYarnCacheSteps(), ...createBuildGlobalCacheSteps(), @@ -355,7 +354,6 @@ const createPushWorkflow = (branchName: string) => { }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", - "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createYarnCacheSteps(), From cca6a3b21fca79a56d0ca45e40c7d5d2a021452a Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 23:18:59 +0200 Subject: [PATCH 19/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 152 +++++++++---------- .github/workflows/pushNext.yml | 165 ++++++++++---------- .github/workflows/wac/push.wac.ts | 241 ++++++++++++++---------------- 3 files changed, 277 insertions(+), 281 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index ba0bd81c064..32e62330145 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -50,6 +50,7 @@ jobs: build: name: Build needs: constants + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -57,24 +58,22 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -90,30 +89,34 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Check code formatting run: yarn prettier:check + working-directory: cloned-repo - name: Check dependencies run: yarn adio + working-directory: cloned-repo - name: Check TS configs run: yarn check-ts-configs + working-directory: cloned-repo - name: ESLint run: yarn eslint + working-directory: cloned-repo runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -121,16 +124,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages (full) run: yarn build + working-directory: cloned-repo - name: Check types for Cypress tests run: yarn cy:ts - runs-on: ubuntu-latest + working-directory: cloned-repo env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -161,20 +165,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo jestTestsDdb: needs: - constants @@ -217,20 +222,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo jestTestsDdbEs: needs: - constants @@ -278,20 +284,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo permissions: id-token: write jestTestsDdbOs: @@ -341,20 +348,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo permissions: id-token: write e2eTestsDdb-constants: @@ -414,20 +422,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -440,11 +446,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -457,8 +463,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -492,19 +496,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -539,25 +543,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -619,20 +625,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -645,11 +649,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -662,8 +666,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -697,19 +699,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -749,25 +751,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -829,20 +833,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -855,11 +857,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -872,8 +874,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -907,19 +907,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -959,23 +959,25 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 8f79022029b..103dbc70862 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -50,6 +50,7 @@ jobs: build: name: Build needs: constants + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -57,24 +58,22 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -90,30 +89,34 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Check code formatting run: yarn prettier:check + working-directory: cloned-repo - name: Check dependencies run: yarn adio + working-directory: cloned-repo - name: Check TS configs run: yarn check-ts-configs + working-directory: cloned-repo - name: ESLint run: yarn eslint + working-directory: cloned-repo runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false staticCodeAnalysisTs: name: Static code analysis (TypeScript) + runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: @@ -121,16 +124,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages (full) run: yarn build + working-directory: cloned-repo - name: Check types for Cypress tests run: yarn cy:ts - runs-on: ubuntu-latest + working-directory: cloned-repo env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -161,20 +165,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo jestTestsDdb: needs: - constants @@ -217,20 +222,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo jestTestsDdbEs: needs: - constants @@ -278,20 +284,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo permissions: id-token: write jestTestsDdbOs: @@ -341,20 +348,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: cloned-repo permissions: id-token: write e2eTestsDdb-constants: @@ -414,20 +422,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -440,11 +446,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -457,8 +463,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -492,19 +496,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -539,25 +543,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -619,20 +625,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -645,11 +649,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -662,8 +666,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -697,19 +699,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -749,25 +751,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -829,20 +833,18 @@ jobs: path: cloned-repo - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: cloned-repo run: yarn --immutable - - name: Build packages working-directory: cloned-repo + - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Start Verdaccio local server working-directory: cloned-repo run: >- @@ -855,11 +857,11 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: cloned-repo run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio working-directory: cloned-repo + - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: cloned-repo - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: @@ -872,8 +874,6 @@ jobs: run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > ~/.webiny/config - - name: Create directory - run: mkdir xyz - name: Create a new Webiny project run: > npx create-webiny-project@local-npm new-webiny-project --tag local-npm @@ -907,19 +907,19 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: cloned-repo run: yarn setup-cypress --projectFolder ../new-webiny-project + working-directory: cloned-repo - name: Save Cypress config id: save-cypress-config - working-directory: cloned-repo run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test working-directory: cloned-repo + - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" + working-directory: cloned-repo runs-on: ubuntu-latest permissions: id-token: write @@ -959,25 +959,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages run: yarn build:quick + working-directory: cloned-repo - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts + working-directory: cloned-repo - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + working-directory: cloned-repo runs-on: ubuntu-latest npmReleaseUnstable: needs: @@ -1006,24 +1008,27 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .yarn/cache + path: cloned-repo/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - enableCrossOsArchive: true - path: .webiny/cached-packages + path: cloned-repo/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: cloned-repo - name: Build packages - run: yarn build + run: yarn build:quick + working-directory: cloned-repo - name: Create ".npmrc" file in the project root run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc + working-directory: cloned-repo - name: Set git info run: | git config --global user.email "webiny-bot@webiny.com" git config --global user.name "webiny-bot" + working-directory: cloned-repo - name: Version and publish to NPM run: yarn release --type=unstable + working-directory: cloned-repo runs-on: ubuntu-latest diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index ece5f8e1e84..ee8d2fedbfd 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -3,55 +3,52 @@ import { createJob, createValidateWorkflowsJob } from "./jobs"; import { createDeployWebinySteps, createSetupVerdaccioSteps } from "./steps"; import { listPackagesWithJestTests, NODE_VERSION } from "./utils"; -const DIR_CLONED_REPO = "cloned-repo"; +const DIR_WEBINY_JS = "webiny-js"; const DIR_TEST_PROJECT = "new-webiny-project"; -interface CacheStepsFactoryParams { - workingDirectory?: string; -} +const withCommonParams = ( + steps: NonNullable, + commonParams: Record +) => steps.map(step => ({ ...step, ...commonParams })); -const createYarnCacheSteps = ( - params: CacheStepsFactoryParams = {} -): NonNullable => { - const workingDirectory = params.workingDirectory || ""; +const yarnInstallBuildSteps = withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages", run: "yarn build:quick" } + ], + { "working-directory": DIR_WEBINY_JS } +); + +const createYarnCacheSteps = (): NonNullable => { return [ { uses: "actions/cache@v4", with: { - enableCrossOsArchive: true, - path: [workingDirectory, ".yarn/cache"].filter(Boolean).join("/"), + path: DIR_WEBINY_JS + "/.yarn/cache", key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" } } ]; }; -const createBuildGlobalCacheSteps = ( - params: CacheStepsFactoryParams = {} -): NonNullable => { - const workingDirectory = params.workingDirectory || ""; +const createBuildGlobalCacheSteps = (): NonNullable => { return [ { uses: "actions/cache@v4", with: { - enableCrossOsArchive: true, - path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), + path: DIR_WEBINY_JS + "/.webiny/cached-packages", key: "${{ needs.constants.outputs.global-cache-key }}" } } ]; }; -const createBuildRunCacheSteps = ( - params: CacheStepsFactoryParams = {} -): NonNullable => { - const workingDirectory = params.workingDirectory || ""; +const createBuildRunCacheSteps = (): NonNullable => { return [ { uses: "actions/cache@v4", with: { - enableCrossOsArchive: true, - path: [workingDirectory, ".webiny/cached-packages"].filter(Boolean).join("/"), + path: DIR_WEBINY_JS + "/.webiny/cached-packages", key: "${{ needs.constants.outputs.run-cache-key }}" } } @@ -118,33 +115,27 @@ const createCypressJobs = (dbSetup: string) => { env, checkout: { "fetch-depth": 0, - path: DIR_CLONED_REPO + path: DIR_WEBINY_JS }, awsAuth: true, steps: [ - ...createYarnCacheSteps({ workingDirectory: DIR_CLONED_REPO }), - ...createBuildRunCacheSteps({ workingDirectory: DIR_CLONED_REPO }), - { - name: "Install dependencies", - "working-directory": DIR_CLONED_REPO, - run: "yarn --immutable" - }, - { - name: "Build packages", - "working-directory": DIR_CLONED_REPO, - run: "yarn build:quick" - }, - ...createSetupVerdaccioSteps({ workingDirectory: DIR_CLONED_REPO }), - { - name: 'Create ".npmrc" file in the project root, with a dummy auth token', - "working-directory": DIR_CLONED_REPO, - run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" - }, - { - name: "Version and publish to Verdaccio", - "working-directory": DIR_CLONED_REPO, - run: "yarn release --type=verdaccio" - }, + ...createYarnCacheSteps(), + ...createBuildRunCacheSteps(), + ...yarnInstallBuildSteps, + ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), + ...withCommonParams( + [ + { + name: 'Create ".npmrc" file in the project root, with a dummy auth token', + run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" + }, + { + name: "Version and publish to Verdaccio", + run: "yarn release --type=verdaccio" + } + ], + { "working-directory": DIR_WEBINY_JS } + ), { name: "Create verdaccio-files artifact", uses: "actions/upload-artifact@v4", @@ -152,8 +143,8 @@ const createCypressJobs = (dbSetup: string) => { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, path: [ - DIR_CLONED_REPO + "/.verdaccio/", - DIR_CLONED_REPO + "/.verdaccio.yaml" + DIR_WEBINY_JS + "/.verdaccio/", + DIR_WEBINY_JS + "/.verdaccio.yaml" ].join("\n") } }, @@ -161,11 +152,6 @@ const createCypressJobs = (dbSetup: string) => { name: "Disable Webiny telemetry", run: 'mkdir ~/.webiny && echo \'{ "id": "ci", "telemetry": false }\' > ~/.webiny/config\n' }, - { - name: "Create directory", - run: "mkdir xyz" - }, - { name: "Create a new Webiny project", run: `npx create-webiny-project@local-npm ${DIR_TEST_PROJECT} --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"$\{{ env.AWS_REGION }}","storageOperations":"${dbSetup}"}' @@ -191,22 +177,24 @@ const createCypressJobs = (dbSetup: string) => { } }, ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), - { - name: "Create Cypress config", - "working-directory": DIR_CLONED_REPO, - run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` - }, - { - name: "Save Cypress config", - id: "save-cypress-config", - "working-directory": DIR_CLONED_REPO, - run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" - }, - { - name: "Cypress - run installation wizard test", - "working-directory": DIR_CLONED_REPO, - run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' - } + ...withCommonParams( + [ + { + name: "Create Cypress config", + run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` + }, + { + name: "Save Cypress config", + id: "save-cypress-config", + run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" + }, + { + name: "Cypress - run installation wizard test", + run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' + } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }); @@ -226,17 +214,21 @@ const createCypressJobs = (dbSetup: string) => { steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Build packages", run: "yarn build:quick" }, - { - name: "Set up Cypress config", - run: `echo '$\{{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` - }, - { - name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', - "timeout-minutes": 40, - run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' - } + ...yarnInstallBuildSteps, + ...withCommonParams( + [ + { + name: "Set up Cypress config", + run: `echo '$\{{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` + }, + { + name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', + "timeout-minutes": 40, + run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' + } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }); @@ -264,9 +256,7 @@ const createJestTestsJob = (storage: string | null) => { } } - const packages = listPackagesWithJestTests({ - storage - }); + const packages = listPackagesWithJestTests({ storage }); return createJob({ needs: ["constants", "build"], @@ -285,18 +275,11 @@ const createJestTestsJob = (storage: string | null) => { steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, - { - name: "Run tests", - run: "yarn test ${{ matrix.package.cmd }}" - } + ...yarnInstallBuildSteps, + ...withCommonParams( + [{ name: "Run tests", run: "yarn test ${{ matrix.package.cmd }}" }], + { "working-directory": DIR_WEBINY_JS } + ) ] }); }; @@ -331,11 +314,11 @@ const createPushWorkflow = (branchName: string) => { build: createJob({ name: "Build", needs: "constants", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createYarnCacheSteps(), ...createBuildGlobalCacheSteps(), - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Build packages", run: "yarn build:quick" }, + ...yarnInstallBuildSteps, ...createBuildRunCacheSteps() ] }), @@ -345,24 +328,36 @@ const createPushWorkflow = (branchName: string) => { steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Check code formatting", run: "yarn prettier:check" }, - { name: "Check dependencies", run: "yarn adio" }, - { name: "Check TS configs", run: "yarn check-ts-configs" }, - { name: "ESLint", run: "yarn eslint" } + ...withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Check code formatting", run: "yarn prettier:check" }, + { name: "Check dependencies", run: "yarn adio" }, + { name: "Check TS configs", run: "yarn check-ts-configs" }, + { name: "ESLint", run: "yarn eslint" } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }), staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", + "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createYarnCacheSteps(), // We're not using run cache here. We want to build all packages // with TypeScript, to ensure there are no TypeScript errors. // ...createBuildRunCacheSteps, - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Build packages (full)", run: "yarn build" }, - { name: "Check types for Cypress tests", run: "yarn cy:ts" } + + ...withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages (full)", run: "yarn build" }, + { name: "Check types for Cypress tests", run: "yarn cy:ts" } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }), jestTestsNoStorage: createJestTestsJob(null), @@ -391,32 +386,26 @@ const createPushWorkflow = (branchName: string) => { steps: [ ...createYarnCacheSteps(), ...createBuildRunCacheSteps(), - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build" - }, - { - name: 'Create ".npmrc" file in the project root', - run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc' - }, - { - name: "Set git info", - run: 'git config --global user.email "webiny-bot@webiny.com"\ngit config --global user.name "webiny-bot"\n' - }, - { - name: "Version and publish to NPM", - run: "yarn release --type=unstable" - } + ...yarnInstallBuildSteps, + ...withCommonParams( + [ + { + name: 'Create ".npmrc" file in the project root', + run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc' + }, + { + name: "Set git info", + run: 'git config --global user.email "webiny-bot@webiny.com"\ngit config --global user.name "webiny-bot"\n' + }, + { name: "Version and publish to NPM", run: "yarn release --type=unstable" } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }); } return workflow; }; - export const pushDev = createPushWorkflow("dev"); export const pushNext = createPushWorkflow("next"); From ec1bdeef2987fd349af7c076d31aac1dd545786a Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 23:22:24 +0200 Subject: [PATCH 20/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 186 +++++++++++++-------------- .github/workflows/pushNext.yml | 200 +++++++++++++++--------------- .github/workflows/wac/push.wac.ts | 91 +++++++------- 3 files changed, 235 insertions(+), 242 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 32e62330145..0bab9b9488c 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -58,21 +58,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -89,27 +89,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Check code formatting run: yarn prettier:check - working-directory: cloned-repo + working-directory: webiny-js - name: Check dependencies run: yarn adio - working-directory: cloned-repo + working-directory: webiny-js - name: Check TS configs run: yarn check-ts-configs - working-directory: cloned-repo + working-directory: webiny-js - name: ESLint run: yarn eslint - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -124,17 +124,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages (full) run: yarn build - working-directory: cloned-repo + working-directory: webiny-js - name: Check types for Cypress tests run: yarn cy:ts - working-directory: cloned-repo + working-directory: webiny-js env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -165,21 +165,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js jestTestsDdb: needs: - constants @@ -222,21 +222,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js jestTestsDdbEs: needs: - constants @@ -284,21 +284,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js permissions: id-token: write jestTestsDdbOs: @@ -348,21 +348,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js permissions: id-token: write e2eTestsDdb-constants: @@ -419,23 +419,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -447,18 +447,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -497,18 +497,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -543,27 +543,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -622,23 +622,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -650,18 +650,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -700,18 +700,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -751,27 +751,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -830,23 +830,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -858,18 +858,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -908,18 +908,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -959,25 +959,25 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 103dbc70862..5f627071944 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -58,21 +58,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -89,27 +89,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Check code formatting run: yarn prettier:check - working-directory: cloned-repo + working-directory: webiny-js - name: Check dependencies run: yarn adio - working-directory: cloned-repo + working-directory: webiny-js - name: Check TS configs run: yarn check-ts-configs - working-directory: cloned-repo + working-directory: webiny-js - name: ESLint run: yarn eslint - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -124,17 +124,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages (full) run: yarn build - working-directory: cloned-repo + working-directory: webiny-js - name: Check types for Cypress tests run: yarn cy:ts - working-directory: cloned-repo + working-directory: webiny-js env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -165,21 +165,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js jestTestsDdb: needs: - constants @@ -222,21 +222,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js jestTestsDdbEs: needs: - constants @@ -284,21 +284,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js permissions: id-token: write jestTestsDdbOs: @@ -348,21 +348,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: cloned-repo + working-directory: webiny-js permissions: id-token: write e2eTestsDdb-constants: @@ -419,23 +419,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -447,18 +447,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -497,18 +497,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -543,27 +543,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -622,23 +622,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -650,18 +650,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -700,18 +700,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -751,27 +751,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -830,23 +830,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: cloned-repo + path: webiny-js - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Start Verdaccio local server - working-directory: cloned-repo + working-directory: webiny-js run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -858,18 +858,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: cloned-repo + working-directory: webiny-js - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 path: |- - cloned-repo/.verdaccio/ - cloned-repo/.verdaccio.yaml + webiny-js/.verdaccio/ + webiny-js/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -908,18 +908,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: cloned-repo + working-directory: webiny-js - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest permissions: id-token: write @@ -959,27 +959,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: cloned-repo + working-directory: webiny-js - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest npmReleaseUnstable: needs: @@ -1008,27 +1008,27 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - path: cloned-repo/.yarn/cache + path: webiny-js/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: cloned-repo/.webiny/cached-packages + path: webiny-js/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: cloned-repo + working-directory: webiny-js - name: Build packages run: yarn build:quick - working-directory: cloned-repo + working-directory: webiny-js - name: Create ".npmrc" file in the project root run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - working-directory: cloned-repo + working-directory: webiny-js - name: Set git info run: | git config --global user.email "webiny-bot@webiny.com" git config --global user.name "webiny-bot" - working-directory: cloned-repo + working-directory: webiny-js - name: Version and publish to NPM run: yarn release --type=unstable - working-directory: cloned-repo + working-directory: webiny-js runs-on: ubuntu-latest diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index ee8d2fedbfd..ec00d42370a 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -19,41 +19,35 @@ const yarnInstallBuildSteps = withCommonParams( { "working-directory": DIR_WEBINY_JS } ); -const createYarnCacheSteps = (): NonNullable => { - return [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } +const yarnCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.yarn/cache", + key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" } - ]; -}; + } +] as const; -const createBuildGlobalCacheSteps = (): NonNullable => { - return [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.global-cache-key }}" - } +const buildGlobalCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.webiny/cached-packages", + key: "${{ needs.constants.outputs.global-cache-key }}" } - ]; -}; + } +] as const; -const createBuildRunCacheSteps = (): NonNullable => { - return [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.run-cache-key }}" - } +const buildRunCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.webiny/cached-packages", + key: "${{ needs.constants.outputs.run-cache-key }}" } - ]; -}; + } +] as const; const createCypressJobs = (dbSetup: string) => { const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); @@ -119,8 +113,8 @@ const createCypressJobs = (dbSetup: string) => { }, awsAuth: true, steps: [ - ...createYarnCacheSteps(), - ...createBuildRunCacheSteps(), + ...yarnCacheSteps, + ...buildRunCacheSteps, ...yarnInstallBuildSteps, ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), ...withCommonParams( @@ -142,10 +136,9 @@ const createCypressJobs = (dbSetup: string) => { with: { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, - path: [ - DIR_WEBINY_JS + "/.verdaccio/", - DIR_WEBINY_JS + "/.verdaccio.yaml" - ].join("\n") + path: [DIR_WEBINY_JS + "/.verdaccio/", DIR_WEBINY_JS + "/.verdaccio.yaml"].join( + "\n" + ) } }, { @@ -212,8 +205,8 @@ const createCypressJobs = (dbSetup: string) => { environment: "next", env, steps: [ - ...createYarnCacheSteps(), - ...createBuildRunCacheSteps(), + ...yarnCacheSteps, + ...buildRunCacheSteps, ...yarnInstallBuildSteps, ...withCommonParams( [ @@ -273,8 +266,8 @@ const createJestTestsJob = (storage: string | null) => { env, awsAuth: storage === "ddb-es" || storage === "ddb-os", steps: [ - ...createYarnCacheSteps(), - ...createBuildRunCacheSteps(), + ...yarnCacheSteps, + ...buildRunCacheSteps, ...yarnInstallBuildSteps, ...withCommonParams( [{ name: "Run tests", run: "yarn test ${{ matrix.package.cmd }}" }], @@ -316,18 +309,18 @@ const createPushWorkflow = (branchName: string) => { needs: "constants", "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ - ...createYarnCacheSteps(), - ...createBuildGlobalCacheSteps(), + ...yarnCacheSteps, + ...buildGlobalCacheSteps, ...yarnInstallBuildSteps, - ...createBuildRunCacheSteps() + ...buildRunCacheSteps ] }), codeAnalysis: createJob({ name: "Static code analysis", needs: ["constants", "build"], steps: [ - ...createYarnCacheSteps(), - ...createBuildRunCacheSteps(), + ...yarnCacheSteps, + ...buildRunCacheSteps, ...withCommonParams( [ { name: "Install dependencies", run: "yarn --immutable" }, @@ -344,11 +337,11 @@ const createPushWorkflow = (branchName: string) => { name: "Static code analysis (TypeScript)", "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ - ...createYarnCacheSteps(), + ...yarnCacheSteps, // We're not using run cache here. We want to build all packages // with TypeScript, to ensure there are no TypeScript errors. - // ...createBuildRunCacheSteps, + // ...buildRunCacheSteps, ...withCommonParams( [ @@ -384,8 +377,8 @@ const createPushWorkflow = (branchName: string) => { }, checkout: { "fetch-depth": 0 }, steps: [ - ...createYarnCacheSteps(), - ...createBuildRunCacheSteps(), + ...yarnCacheSteps, + ...buildRunCacheSteps, ...yarnInstallBuildSteps, ...withCommonParams( [ From cfbae49a43fc6350fca299b51d5eb1346478fe8f Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 23:25:50 +0200 Subject: [PATCH 21/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 20 ++++++++++++++++++++ .github/workflows/pushNext.yml | 20 ++++++++++++++++++++ .github/workflows/wac/push.wac.ts | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 0bab9b9488c..7dabb708834 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -56,6 +56,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -87,6 +89,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -122,6 +126,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -163,6 +169,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -220,6 +228,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -282,6 +292,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -346,6 +358,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -541,6 +555,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -749,6 +765,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -957,6 +975,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 5f627071944..ae798700015 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -56,6 +56,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -87,6 +89,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -122,6 +126,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -163,6 +169,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -220,6 +228,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -282,6 +292,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -346,6 +358,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -541,6 +555,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -749,6 +765,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache @@ -957,6 +975,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: webiny-js - uses: actions/cache@v4 with: path: webiny-js/.yarn/cache diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index ec00d42370a..0e28e71a4ef 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -204,6 +204,7 @@ const createCypressJobs = (dbSetup: string) => { }, environment: "next", env, + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...buildRunCacheSteps, @@ -265,6 +266,7 @@ const createJestTestsJob = (storage: string | null) => { "runs-on": "${{ matrix.os }}", env, awsAuth: storage === "ddb-es" || storage === "ddb-os", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...buildRunCacheSteps, @@ -307,6 +309,7 @@ const createPushWorkflow = (branchName: string) => { build: createJob({ name: "Build", needs: "constants", + checkout: { path: DIR_WEBINY_JS }, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, @@ -318,6 +321,7 @@ const createPushWorkflow = (branchName: string) => { codeAnalysis: createJob({ name: "Static code analysis", needs: ["constants", "build"], + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...buildRunCacheSteps, @@ -336,6 +340,7 @@ const createPushWorkflow = (branchName: string) => { staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", "runs-on": "blacksmith-4vcpu-ubuntu-2204", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, From 7fecd2477451ab4b76793bae579530898e989024 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Wed, 3 Apr 2024 23:34:17 +0200 Subject: [PATCH 22/50] ci: improve pushDev/pushNext workflows --- .github/workflows/pushDev.yml | 206 ++++++------- .github/workflows/pushNext.yml | 220 ++++++------- .github/workflows/wac/push.wac.ts | 496 +++++++++++++++--------------- 3 files changed, 461 insertions(+), 461 deletions(-) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 7dabb708834..0efe71a93a0 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -57,24 +57,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -90,30 +90,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Check code formatting run: yarn prettier:check - working-directory: webiny-js + working-directory: dev - name: Check dependencies run: yarn adio - working-directory: webiny-js + working-directory: dev - name: Check TS configs run: yarn check-ts-configs - working-directory: webiny-js + working-directory: dev - name: ESLint run: yarn eslint - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -127,20 +127,20 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages (full) run: yarn build - working-directory: webiny-js + working-directory: dev - name: Check types for Cypress tests run: yarn cy:ts - working-directory: webiny-js + working-directory: dev env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -170,24 +170,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: dev jestTestsDdb: needs: - constants @@ -229,24 +229,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: dev jestTestsDdbEs: needs: - constants @@ -293,24 +293,24 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: dev permissions: id-token: write jestTestsDdbOs: @@ -359,24 +359,24 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: dev permissions: id-token: write e2eTestsDdb-constants: @@ -433,23 +433,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: dev run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -461,18 +461,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: dev - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: dev - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + dev/.verdaccio/ + dev/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -511,18 +511,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: dev - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: dev - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest permissions: id-token: write @@ -556,30 +556,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: dev - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -638,23 +638,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: dev run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -666,18 +666,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: dev - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: dev - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + dev/.verdaccio/ + dev/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -716,18 +716,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: dev - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: dev - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest permissions: id-token: write @@ -766,30 +766,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: dev - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -848,23 +848,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: dev run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -876,18 +876,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: dev - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: dev - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + dev/.verdaccio/ + dev/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -926,18 +926,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: dev - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: dev - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest permissions: id-token: write @@ -976,28 +976,28 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: dev - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: dev/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: dev/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: dev - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: dev - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: dev - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: dev runs-on: ubuntu-latest diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index ae798700015..458ff62d574 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -57,24 +57,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -90,30 +90,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Check code formatting run: yarn prettier:check - working-directory: webiny-js + working-directory: next - name: Check dependencies run: yarn adio - working-directory: webiny-js + working-directory: next - name: Check TS configs run: yarn check-ts-configs - working-directory: webiny-js + working-directory: next - name: ESLint run: yarn eslint - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -127,20 +127,20 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages (full) run: yarn build - working-directory: webiny-js + working-directory: next - name: Check types for Cypress tests run: yarn cy:ts - working-directory: webiny-js + working-directory: next env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -170,24 +170,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: next jestTestsDdb: needs: - constants @@ -229,24 +229,24 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: next jestTestsDdbEs: needs: - constants @@ -293,24 +293,24 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: next permissions: id-token: write jestTestsDdbOs: @@ -359,24 +359,24 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Run tests run: yarn test ${{ matrix.package.cmd }} - working-directory: webiny-js + working-directory: next permissions: id-token: write e2eTestsDdb-constants: @@ -433,23 +433,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: next run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -461,18 +461,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: next - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: next - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + next/.verdaccio/ + next/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -511,18 +511,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: next - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: next - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest permissions: id-token: write @@ -556,30 +556,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: next - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest e2eTestsDdb-es-constants: name: Constants - DDB-ES @@ -638,23 +638,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: next run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -666,18 +666,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: next - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: next - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + next/.verdaccio/ + next/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -716,18 +716,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: next - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: next - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest permissions: id-token: write @@ -766,30 +766,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-es-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: next - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest e2eTestsDdb-os-constants: name: Constants - DDB-OS @@ -848,23 +848,23 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Start Verdaccio local server - working-directory: webiny-js + working-directory: next run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -876,18 +876,18 @@ jobs: run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - working-directory: webiny-js + working-directory: next - name: Version and publish to Verdaccio run: yarn release --type=verdaccio - working-directory: webiny-js + working-directory: next - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 path: |- - webiny-js/.verdaccio/ - webiny-js/.verdaccio.yaml + next/.verdaccio/ + next/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -926,18 +926,18 @@ jobs: run: yarn webiny deploy apps/website --env dev - name: Create Cypress config run: yarn setup-cypress --projectFolder ../new-webiny-project - working-directory: webiny-js + working-directory: next - name: Save Cypress config id: save-cypress-config run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - working-directory: webiny-js + working-directory: next - name: Cypress - run installation wizard test run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest permissions: id-token: write @@ -976,30 +976,30 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: webiny-js + path: next - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Set up Cypress config run: >- echo '${{ needs.e2eTestsDdb-os-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - working-directory: webiny-js + working-directory: next - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest npmReleaseUnstable: needs: @@ -1028,27 +1028,27 @@ jobs: fetch-depth: 0 - uses: actions/cache@v4 with: - path: webiny-js/.yarn/cache + path: next/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: webiny-js/.webiny/cached-packages + path: next/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: webiny-js + working-directory: next - name: Build packages run: yarn build:quick - working-directory: webiny-js + working-directory: next - name: Create ".npmrc" file in the project root run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - working-directory: webiny-js + working-directory: next - name: Set git info run: | git config --global user.email "webiny-bot@webiny.com" git config --global user.name "webiny-bot" - working-directory: webiny-js + working-directory: next - name: Version and publish to NPM run: yarn release --type=unstable - working-directory: webiny-js + working-directory: next runs-on: ubuntu-latest diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 0e28e71a4ef..d409439f18c 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -3,284 +3,284 @@ import { createJob, createValidateWorkflowsJob } from "./jobs"; import { createDeployWebinySteps, createSetupVerdaccioSteps } from "./steps"; import { listPackagesWithJestTests, NODE_VERSION } from "./utils"; -const DIR_WEBINY_JS = "webiny-js"; -const DIR_TEST_PROJECT = "new-webiny-project"; - const withCommonParams = ( steps: NonNullable, commonParams: Record ) => steps.map(step => ({ ...step, ...commonParams })); -const yarnInstallBuildSteps = withCommonParams( - [ - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Build packages", run: "yarn build:quick" } - ], - { "working-directory": DIR_WEBINY_JS } -); +const createPushWorkflow = (branchName: string) => { + const ucFirstBranchName = branchName.charAt(0).toUpperCase() + branchName.slice(1); -const yarnCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - } -] as const; + const DIR_WEBINY_JS = branchName; + const DIR_TEST_PROJECT = "new-webiny-project"; -const buildGlobalCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.global-cache-key }}" - } - } -] as const; + const yarnInstallBuildSteps = withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages", run: "yarn build:quick" } + ], + { "working-directory": DIR_WEBINY_JS } + ); -const buildRunCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.run-cache-key }}" + const yarnCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.yarn/cache", + key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" + } } - } -] as const; - -const createCypressJobs = (dbSetup: string) => { - const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); + ] as const; - const jobNames = { - constants: `e2eTests${ucFirstDbSetup}-constants`, - projectSetup: `e2eTests${ucFirstDbSetup}-setup`, - cypressTests: `e2eTests${ucFirstDbSetup}-cypress` - }; + const buildGlobalCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.webiny/cached-packages", + key: "${{ needs.constants.outputs.global-cache-key }}" + } + } + ] as const; - const constantsJob: NormalJob = createJob({ - name: `Constants - ${dbSetup.toUpperCase()}`, - needs: ["build"], - outputs: { - "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", - "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" - }, - steps: [ - { - name: "List Cypress tests folders", - id: "list-cypress-folders", - run: 'echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT' - }, - { - name: "Get Pulumi backend URL", - id: "get-pulumi-backend-url", - run: `echo "pulumi-backend-url=\${{ secrets.WEBINY_PULUMI_BACKEND }}\${{ github.run_id }}_${dbSetup}" >> $GITHUB_OUTPUT` + const buildRunCacheSteps = [ + { + uses: "actions/cache@v4", + with: { + path: DIR_WEBINY_JS + "/.webiny/cached-packages", + key: "${{ needs.constants.outputs.run-cache-key }}" } - ] - }); + } + ] as const; - const env: Record = { - CYPRESS_MAILOSAUR_API_KEY: "${{ secrets.CYPRESS_MAILOSAUR_API_KEY }}", - PULUMI_CONFIG_PASSPHRASE: "${{ secrets.PULUMI_CONFIG_PASSPHRASE }}", - PULUMI_SECRETS_PROVIDER: "${{ secrets.PULUMI_SECRETS_PROVIDER }}", - WEBINY_PULUMI_BACKEND: `\${{ needs.${jobNames.constants}.outputs.pulumi-backend-url }}`, - YARN_ENABLE_IMMUTABLE_INSTALLS: "false" - }; + const createCypressJobs = (dbSetup: string) => { + const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); - if (dbSetup === "ddb-es") { - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; - env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; - } else if (dbSetup === "ddb-os") { - // We still use the same environment variables as for "ddb-es" setup, it's - // just that the values are read from different secrets. - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; - env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; - } + const jobNames = { + constants: `e2eTests${ucFirstDbSetup}-constants`, + projectSetup: `e2eTests${ucFirstDbSetup}-setup`, + cypressTests: `e2eTests${ucFirstDbSetup}-cypress` + }; - const projectSetupJob: NormalJob = createJob({ - needs: ["constants", "build", jobNames.constants], - name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, - outputs: { - "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" - }, - environment: "next", - env, - checkout: { - "fetch-depth": 0, - path: DIR_WEBINY_JS - }, - awsAuth: true, - steps: [ - ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, - ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), - ...withCommonParams( - [ - { - name: 'Create ".npmrc" file in the project root, with a dummy auth token', - run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" - }, - { - name: "Version and publish to Verdaccio", - run: "yarn release --type=verdaccio" - } - ], - { "working-directory": DIR_WEBINY_JS } - ), - { - name: "Create verdaccio-files artifact", - uses: "actions/upload-artifact@v4", - with: { - name: `verdaccio-files-${dbSetup}`, - "retention-days": 1, - path: [DIR_WEBINY_JS + "/.verdaccio/", DIR_WEBINY_JS + "/.verdaccio.yaml"].join( - "\n" - ) - } + const constantsJob: NormalJob = createJob({ + name: `Constants - ${dbSetup.toUpperCase()}`, + needs: ["build"], + outputs: { + "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", + "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, - { - name: "Disable Webiny telemetry", - run: 'mkdir ~/.webiny && echo \'{ "id": "ci", "telemetry": false }\' > ~/.webiny/config\n' - }, - { - name: "Create a new Webiny project", - run: `npx create-webiny-project@local-npm ${DIR_TEST_PROJECT} --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"$\{{ env.AWS_REGION }}","storageOperations":"${dbSetup}"}' -` - }, - { - name: "Print CLI version", - "working-directory": DIR_TEST_PROJECT, - run: "yarn webiny --version" - }, - { - name: "Create project-files artifact", - uses: "actions/upload-artifact@v4", - with: { - name: `project-files-${dbSetup}`, - "retention-days": 1, - path: [ - `${DIR_TEST_PROJECT}/`, - `!${DIR_TEST_PROJECT}/node_modules/**/*`, - `!${DIR_TEST_PROJECT}/**/node_modules/**/*`, - `!${DIR_TEST_PROJECT}/.yarn/cache/**/*` - ].join("\n") + steps: [ + { + name: "List Cypress tests folders", + id: "list-cypress-folders", + run: 'echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT' + }, + { + name: "Get Pulumi backend URL", + id: "get-pulumi-backend-url", + run: `echo "pulumi-backend-url=\${{ secrets.WEBINY_PULUMI_BACKEND }}\${{ github.run_id }}_${dbSetup}" >> $GITHUB_OUTPUT` } - }, - ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), - ...withCommonParams( - [ - { - name: "Create Cypress config", - run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` - }, - { - name: "Save Cypress config", - id: "save-cypress-config", - run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" - }, - { - name: "Cypress - run installation wizard test", - run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' - } - ], - { "working-directory": DIR_WEBINY_JS } - ) - ] - }); - - const cypressTestsJob = createJob({ - name: `$\{{ matrix.cypress-folder }} (${dbSetup}, $\{{ matrix.os }}, Node v$\{{ matrix.node }})`, - needs: ["constants", jobNames.constants, jobNames.projectSetup], - strategy: { - "fail-fast": false, - matrix: { - os: ["ubuntu-latest"], - node: [NODE_VERSION], - "cypress-folder": `$\{{ fromJson(needs.${jobNames.constants}.outputs.cypress-folders) }}` - } - }, - environment: "next", - env, - checkout: { path: DIR_WEBINY_JS }, - steps: [ - ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, - ...withCommonParams( - [ - { - name: "Set up Cypress config", - run: `echo '$\{{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` - }, - { - name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', - "timeout-minutes": 40, - run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' - } - ], - { "working-directory": DIR_WEBINY_JS } - ) - ] - }); - - return { - [jobNames.constants]: constantsJob, - [jobNames.projectSetup]: projectSetupJob, - [jobNames.cypressTests]: cypressTestsJob - }; -}; + ] + }); -const createJestTestsJob = (storage: string | null) => { - const env: Record = {}; + const env: Record = { + CYPRESS_MAILOSAUR_API_KEY: "${{ secrets.CYPRESS_MAILOSAUR_API_KEY }}", + PULUMI_CONFIG_PASSPHRASE: "${{ secrets.PULUMI_CONFIG_PASSPHRASE }}", + PULUMI_SECRETS_PROVIDER: "${{ secrets.PULUMI_SECRETS_PROVIDER }}", + WEBINY_PULUMI_BACKEND: `\${{ needs.${jobNames.constants}.outputs.pulumi-backend-url }}`, + YARN_ENABLE_IMMUTABLE_INSTALLS: "false" + }; - if (storage) { - if (storage === "ddb-es") { + if (dbSetup === "ddb-es") { env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; - } else if (storage === "ddb-os") { + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; + } else if (dbSetup === "ddb-os") { // We still use the same environment variables as for "ddb-es" setup, it's // just that the values are read from different secrets. env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; - env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ github.run_id }}_"; } - } - const packages = listPackagesWithJestTests({ storage }); + const projectSetupJob: NormalJob = createJob({ + needs: ["constants", "build", jobNames.constants], + name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, + outputs: { + "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" + }, + environment: "next", + env, + checkout: { + "fetch-depth": 0, + path: DIR_WEBINY_JS + }, + awsAuth: true, + steps: [ + ...yarnCacheSteps, + ...buildRunCacheSteps, + ...yarnInstallBuildSteps, + ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), + ...withCommonParams( + [ + { + name: 'Create ".npmrc" file in the project root, with a dummy auth token', + run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" + }, + { + name: "Version and publish to Verdaccio", + run: "yarn release --type=verdaccio" + } + ], + { "working-directory": DIR_WEBINY_JS } + ), + { + name: "Create verdaccio-files artifact", + uses: "actions/upload-artifact@v4", + with: { + name: `verdaccio-files-${dbSetup}`, + "retention-days": 1, + path: [DIR_WEBINY_JS + "/.verdaccio/", DIR_WEBINY_JS + "/.verdaccio.yaml"].join( + "\n" + ) + } + }, + { + name: "Disable Webiny telemetry", + run: 'mkdir ~/.webiny && echo \'{ "id": "ci", "telemetry": false }\' > ~/.webiny/config\n' + }, + { + name: "Create a new Webiny project", + run: `npx create-webiny-project@local-npm ${DIR_TEST_PROJECT} --tag local-npm --no-interactive --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' --template-options '{"region":"$\{{ env.AWS_REGION }}","storageOperations":"${dbSetup}"}' +` + }, + { + name: "Print CLI version", + "working-directory": DIR_TEST_PROJECT, + run: "yarn webiny --version" + }, + { + name: "Create project-files artifact", + uses: "actions/upload-artifact@v4", + with: { + name: `project-files-${dbSetup}`, + "retention-days": 1, + path: [ + `${DIR_TEST_PROJECT}/`, + `!${DIR_TEST_PROJECT}/node_modules/**/*`, + `!${DIR_TEST_PROJECT}/**/node_modules/**/*`, + `!${DIR_TEST_PROJECT}/.yarn/cache/**/*` + ].join("\n") + } + }, + ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), + ...withCommonParams( + [ + { + name: "Create Cypress config", + run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` + }, + { + name: "Save Cypress config", + id: "save-cypress-config", + run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" + }, + { + name: "Cypress - run installation wizard test", + run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' + } + ], + { "working-directory": DIR_WEBINY_JS } + ) + ] + }); + + const cypressTestsJob = createJob({ + name: `$\{{ matrix.cypress-folder }} (${dbSetup}, $\{{ matrix.os }}, Node v$\{{ matrix.node }})`, + needs: ["constants", jobNames.constants, jobNames.projectSetup], + strategy: { + "fail-fast": false, + matrix: { + os: ["ubuntu-latest"], + node: [NODE_VERSION], + "cypress-folder": `$\{{ fromJson(needs.${jobNames.constants}.outputs.cypress-folders) }}` + } + }, + environment: "next", + env, + checkout: { path: DIR_WEBINY_JS }, + steps: [ + ...yarnCacheSteps, + ...buildRunCacheSteps, + ...yarnInstallBuildSteps, + ...withCommonParams( + [ + { + name: "Set up Cypress config", + run: `echo '$\{{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` + }, + { + name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', + "timeout-minutes": 40, + run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' + } + ], + { "working-directory": DIR_WEBINY_JS } + ) + ] + }); + + return { + [jobNames.constants]: constantsJob, + [jobNames.projectSetup]: projectSetupJob, + [jobNames.cypressTests]: cypressTestsJob + }; + }; + + const createJestTestsJob = (storage: string | null) => { + const env: Record = {}; - return createJob({ - needs: ["constants", "build"], - name: "${{ matrix.package.cmd }}", - strategy: { - "fail-fast": false, - matrix: { - os: ["ubuntu-latest"], - node: [NODE_VERSION], - package: "${{ fromJson('" + JSON.stringify(packages) + "') }}" + if (storage) { + if (storage === "ddb-es") { + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; + env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; + } else if (storage === "ddb-os") { + // We still use the same environment variables as for "ddb-es" setup, it's + // just that the values are read from different secrets. + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; + env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; + env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; } - }, - "runs-on": "${{ matrix.os }}", - env, - awsAuth: storage === "ddb-es" || storage === "ddb-os", - checkout: { path: DIR_WEBINY_JS }, - steps: [ - ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, - ...withCommonParams( - [{ name: "Run tests", run: "yarn test ${{ matrix.package.cmd }}" }], - { "working-directory": DIR_WEBINY_JS } - ) - ] - }); -}; + } -const createPushWorkflow = (branchName: string) => { - const ucFirstBranchName = branchName.charAt(0).toUpperCase() + branchName.slice(1); + const packages = listPackagesWithJestTests({ storage }); + + return createJob({ + needs: ["constants", "build"], + name: "${{ matrix.package.cmd }}", + strategy: { + "fail-fast": false, + matrix: { + os: ["ubuntu-latest"], + node: [NODE_VERSION], + package: "${{ fromJson('" + JSON.stringify(packages) + "') }}" + } + }, + "runs-on": "${{ matrix.os }}", + env, + awsAuth: storage === "ddb-es" || storage === "ddb-os", + checkout: { path: DIR_WEBINY_JS }, + steps: [ + ...yarnCacheSteps, + ...buildRunCacheSteps, + ...yarnInstallBuildSteps, + ...withCommonParams( + [{ name: "Run tests", run: "yarn test ${{ matrix.package.cmd }}" }], + { "working-directory": DIR_WEBINY_JS } + ) + ] + }); + }; const workflow = createWorkflow({ name: `${ucFirstBranchName} Branch - Push`, From 7cc02eac855146376490a376868c65507548907e Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 08:44:03 +0200 Subject: [PATCH 23/50] ci: improve pushDev/pushNext workflows --- .github/workflows/wac/push.wac.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index d409439f18c..35a7737ae02 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -139,9 +139,10 @@ const createPushWorkflow = (branchName: string) => { with: { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, - path: [DIR_WEBINY_JS + "/.verdaccio/", DIR_WEBINY_JS + "/.verdaccio.yaml"].join( - "\n" - ) + path: [ + DIR_WEBINY_JS + "/.verdaccio/", + DIR_WEBINY_JS + "/.verdaccio.yaml" + ].join("\n") } }, { @@ -241,13 +242,15 @@ const createPushWorkflow = (branchName: string) => { if (storage) { if (storage === "ddb-es") { - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = + "${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.ELASTIC_SEARCH_ENDPOINT }}"; env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; } else if (storage === "ddb-os") { // We still use the same environment variables as for "ddb-es" setup, it's // just that the values are read from different secrets. - env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; + env["AWS_ELASTIC_SEARCH_DOMAIN_NAME"] = + "${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }}"; env["ELASTIC_SEARCH_ENDPOINT"] = "${{ secrets.OPEN_SEARCH_ENDPOINT }}"; env["ELASTIC_SEARCH_INDEX_PREFIX"] = "${{ matrix.package.id }}"; } From c0a1ac328274c354d483f84ed9832252d4fdba21 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:14:28 +0200 Subject: [PATCH 24/50] ci: refactor steps [no ci] --- .github/workflows/pushStable.yml | 9 ++- .github/workflows/wac/push.wac.ts | 78 +++++++------------ .github/workflows/wac/pushStable.wac.ts | 40 +++------- .../wac/steps/createGlobalBuildCacheSteps.ts | 17 ++++ .../wac/steps/createInstallBuildSteps.ts | 15 ++++ .../wac/steps/createRunBuildCacheSteps.ts | 17 ++++ .../wac/steps/createYarnCacheSteps.ts | 15 ++++ .github/workflows/wac/steps/index.ts | 5 ++ .../workflows/wac/steps/withCommonParams.ts | 6 ++ 9 files changed, 120 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/wac/steps/createGlobalBuildCacheSteps.ts create mode 100644 .github/workflows/wac/steps/createInstallBuildSteps.ts create mode 100644 .github/workflows/wac/steps/createRunBuildCacheSteps.ts create mode 100644 .github/workflows/wac/steps/createYarnCacheSteps.ts create mode 100644 .github/workflows/wac/steps/withCommonParams.ts diff --git a/.github/workflows/pushStable.yml b/.github/workflows/pushStable.yml index 988b4886483..cb914ec0375 100644 --- a/.github/workflows/pushStable.yml +++ b/.github/workflows/pushStable.yml @@ -25,15 +25,22 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: name: Create constants - runs-on: ubuntu-latest outputs: run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 - name: Create workflow run cache key id: run-cache-key run: >- echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build needs: constants diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index 35a7737ae02..c257aa94317 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -1,7 +1,14 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; -import { createJob, createValidateWorkflowsJob } from "./jobs"; -import { createDeployWebinySteps, createSetupVerdaccioSteps } from "./steps"; import { listPackagesWithJestTests, NODE_VERSION } from "./utils"; +import { createJob, createValidateWorkflowsJob } from "./jobs"; +import { + createDeployWebinySteps, + createSetupVerdaccioSteps, + createInstallBuildSteps, + createYarnCacheSteps, + createGlobalBuildCacheSteps, + createRunBuildCacheSteps +} from "./steps"; const withCommonParams = ( steps: NonNullable, @@ -14,43 +21,10 @@ const createPushWorkflow = (branchName: string) => { const DIR_WEBINY_JS = branchName; const DIR_TEST_PROJECT = "new-webiny-project"; - const yarnInstallBuildSteps = withCommonParams( - [ - { name: "Install dependencies", run: "yarn --immutable" }, - { name: "Build packages", run: "yarn build:quick" } - ], - { "working-directory": DIR_WEBINY_JS } - ); - - const yarnCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - } - ] as const; - - const buildGlobalCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.global-cache-key }}" - } - } - ] as const; - - const buildRunCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_WEBINY_JS + "/.webiny/cached-packages", - key: "${{ needs.constants.outputs.run-cache-key }}" - } - } - ] as const; + const installBuildSteps = createInstallBuildSteps({ workingDirectory: DIR_WEBINY_JS }); + const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: DIR_WEBINY_JS }); + const globalBuildCacheSteps = createGlobalBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); + const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); const createCypressJobs = (dbSetup: string) => { const ucFirstDbSetup = dbSetup.charAt(0).toUpperCase() + dbSetup.slice(1); @@ -117,8 +91,8 @@ const createPushWorkflow = (branchName: string) => { awsAuth: true, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, + ...runBuildCacheSteps, + ...installBuildSteps, ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), ...withCommonParams( [ @@ -211,8 +185,8 @@ const createPushWorkflow = (branchName: string) => { checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, + ...runBuildCacheSteps, + ...installBuildSteps, ...withCommonParams( [ { @@ -275,8 +249,8 @@ const createPushWorkflow = (branchName: string) => { checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, + ...runBuildCacheSteps, + ...installBuildSteps, ...withCommonParams( [{ name: "Run tests", run: "yarn test ${{ matrix.package.cmd }}" }], { "working-directory": DIR_WEBINY_JS } @@ -316,9 +290,9 @@ const createPushWorkflow = (branchName: string) => { "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, - ...buildGlobalCacheSteps, - ...yarnInstallBuildSteps, - ...buildRunCacheSteps + ...globalBuildCacheSteps, + ...installBuildSteps, + ...runBuildCacheSteps ] }), codeAnalysis: createJob({ @@ -327,7 +301,7 @@ const createPushWorkflow = (branchName: string) => { checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, + ...runBuildCacheSteps, ...withCommonParams( [ { name: "Install dependencies", run: "yarn --immutable" }, @@ -349,7 +323,7 @@ const createPushWorkflow = (branchName: string) => { // We're not using run cache here. We want to build all packages // with TypeScript, to ensure there are no TypeScript errors. - // ...buildRunCacheSteps, + // ...runBuildCacheSteps, ...withCommonParams( [ @@ -386,8 +360,8 @@ const createPushWorkflow = (branchName: string) => { checkout: { "fetch-depth": 0 }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - ...yarnInstallBuildSteps, + ...runBuildCacheSteps, + ...installBuildSteps, ...withCommonParams( [ { diff --git a/.github/workflows/wac/pushStable.wac.ts b/.github/workflows/wac/pushStable.wac.ts index 2614b42ca4f..d4b2c13f8e3 100644 --- a/.github/workflows/wac/pushStable.wac.ts +++ b/.github/workflows/wac/pushStable.wac.ts @@ -1,25 +1,9 @@ -import { createWorkflow, NormalJob } from "github-actions-wac"; +import { createWorkflow } from "github-actions-wac"; import { createJob, createValidateWorkflowsJob } from "./jobs"; +import { createRunBuildCacheSteps, createYarnCacheSteps } from "./steps"; -const yarnCacheSteps: NormalJob["steps"] = [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - } -]; - -const buildRunCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "${{ needs.constants.outputs.run-cache-key }}" - } - } -]; +const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: "" }); +const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: "" }); // Note: we don't use global build cache here because we don't know which cache to use. // Commits from both `dev` and `next` branches can be merged into `stable`, so we need @@ -34,12 +18,10 @@ export const pushStable = createWorkflow({ }, jobs: { validateWorkflows: createValidateWorkflowsJob(), - constants: { + constants: createJob({ name: "Create constants", - "runs-on": "ubuntu-latest", - outputs: { - "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" - }, + outputs: { "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" }, + setupNode: false, steps: [ { name: "Create workflow run cache key", @@ -47,7 +29,7 @@ export const pushStable = createWorkflow({ run: 'echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' } ] - }, + }), build: createJob({ name: "Build", needs: "constants", @@ -65,7 +47,7 @@ export const pushStable = createWorkflow({ // Once we've built packages (without the help of the global cache), we can now cache // the result for this run workflow. All of the following jobs will use this cache. - ...buildRunCacheSteps + ...runBuildCacheSteps ] }), npmReleaseBeta: createJob({ @@ -79,7 +61,7 @@ export const pushStable = createWorkflow({ checkout: { "fetch-depth": 0 }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, + ...runBuildCacheSteps, { name: "Install dependencies", run: "yarn --immutable" @@ -121,7 +103,7 @@ export const pushStable = createWorkflow({ }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, + ...runBuildCacheSteps, { name: "Install dependencies", run: "yarn --immutable" diff --git a/.github/workflows/wac/steps/createGlobalBuildCacheSteps.ts b/.github/workflows/wac/steps/createGlobalBuildCacheSteps.ts new file mode 100644 index 00000000000..e422bdc8002 --- /dev/null +++ b/.github/workflows/wac/steps/createGlobalBuildCacheSteps.ts @@ -0,0 +1,17 @@ +interface CreateGlobalBuildCacheStepsParams { + workingDirectory: string; +} + +export const createGlobalBuildCacheSteps = (params: CreateGlobalBuildCacheStepsParams) => { + return [ + { + uses: "actions/cache@v4", + with: { + path: [params.workingDirectory, ".webiny/cached-packages"] + .filter(Boolean) + .join("/"), + key: "${{ needs.constants.outputs.global-cache-key }}" + } + } + ] as const; +}; diff --git a/.github/workflows/wac/steps/createInstallBuildSteps.ts b/.github/workflows/wac/steps/createInstallBuildSteps.ts new file mode 100644 index 00000000000..54d92db8a29 --- /dev/null +++ b/.github/workflows/wac/steps/createInstallBuildSteps.ts @@ -0,0 +1,15 @@ +import { withCommonParams } from "./withCommonParams"; + +interface CreateInstallBuildStepsParams { + workingDirectory: string; +} + +export const createInstallBuildSteps = (params: CreateInstallBuildStepsParams) => { + return withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages", run: "yarn build:quick" } + ], + { "working-directory": params.workingDirectory } + ); +}; diff --git a/.github/workflows/wac/steps/createRunBuildCacheSteps.ts b/.github/workflows/wac/steps/createRunBuildCacheSteps.ts new file mode 100644 index 00000000000..f8cdfbc511e --- /dev/null +++ b/.github/workflows/wac/steps/createRunBuildCacheSteps.ts @@ -0,0 +1,17 @@ +interface CreateRunBuildCacheStepsParams { + workingDirectory: string; +} + +export const createRunBuildCacheSteps = (params: CreateRunBuildCacheStepsParams) => { + return [ + { + uses: "actions/cache@v4", + with: { + path: [params.workingDirectory, ".webiny/cached-packages"] + .filter(Boolean) + .join("/"), + key: "${{ needs.constants.outputs.run-cache-key }}" + } + } + ] as const; +}; diff --git a/.github/workflows/wac/steps/createYarnCacheSteps.ts b/.github/workflows/wac/steps/createYarnCacheSteps.ts new file mode 100644 index 00000000000..382d7fe1fd6 --- /dev/null +++ b/.github/workflows/wac/steps/createYarnCacheSteps.ts @@ -0,0 +1,15 @@ +interface CreateYarnCacheStepsParams { + workingDirectory: string; +} + +export const createYarnCacheSteps = (params: CreateYarnCacheStepsParams) => { + return [ + { + uses: "actions/cache@v4", + with: { + path: [params.workingDirectory, ".yarn/cache"].filter(Boolean).join("/"), + key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" + } + } + ] as const; +}; diff --git a/.github/workflows/wac/steps/index.ts b/.github/workflows/wac/steps/index.ts index 4df14ef4c04..51df6ee62ab 100644 --- a/.github/workflows/wac/steps/index.ts +++ b/.github/workflows/wac/steps/index.ts @@ -1,2 +1,7 @@ export * from "./createDeployWebinySteps"; export * from "./createSetupVerdaccioSteps"; +export * from "./createInstallBuildSteps"; +export * from "./createGlobalBuildCacheSteps"; +export * from "./createRunBuildCacheSteps"; +export * from "./createYarnCacheSteps"; +export * from "./withCommonParams"; diff --git a/.github/workflows/wac/steps/withCommonParams.ts b/.github/workflows/wac/steps/withCommonParams.ts new file mode 100644 index 00000000000..3ca77bab7aa --- /dev/null +++ b/.github/workflows/wac/steps/withCommonParams.ts @@ -0,0 +1,6 @@ +import { NormalJob } from "github-actions-wac"; + +export const withCommonParams = ( + steps: NonNullable, + commonParams: Record +) => steps.map(step => ({ ...step, ...commonParams })); From 415cb3edb4e4f829495c272d9bc93bac9d6c7b16 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:17:14 +0200 Subject: [PATCH 25/50] ci: refactor steps [no ci] --- .github/workflows/pushStable.yml | 10 +++++++-- .github/workflows/wac/pushStable.wac.ts | 30 +++++-------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pushStable.yml b/.github/workflows/pushStable.yml index cb914ec0375..e8da01b8856 100644 --- a/.github/workflows/pushStable.yml +++ b/.github/workflows/pushStable.yml @@ -56,8 +56,10 @@ jobs: key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable + working-directory: '' - name: Build packages run: yarn build:quick + working-directory: '' - uses: actions/cache@v4 with: path: .webiny/cached-packages @@ -93,8 +95,10 @@ jobs: key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: '' - name: Build packages - run: yarn build + run: yarn build:quick + working-directory: '' - name: Create ".npmrc" file in the project root run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - name: Set git email @@ -134,8 +138,10 @@ jobs: key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: '' - name: Build packages - run: yarn build + run: yarn build:quick + working-directory: '' - name: Create ".npmrc" file in the project root run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - name: Set git email diff --git a/.github/workflows/wac/pushStable.wac.ts b/.github/workflows/wac/pushStable.wac.ts index d4b2c13f8e3..4b3ad52e86a 100644 --- a/.github/workflows/wac/pushStable.wac.ts +++ b/.github/workflows/wac/pushStable.wac.ts @@ -1,7 +1,8 @@ import { createWorkflow } from "github-actions-wac"; import { createJob, createValidateWorkflowsJob } from "./jobs"; -import { createRunBuildCacheSteps, createYarnCacheSteps } from "./steps"; +import { createRunBuildCacheSteps, createYarnCacheSteps, createInstallBuildSteps } from "./steps"; +const installBuildSteps = createInstallBuildSteps({ workingDirectory: "" }); const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: "" }); const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: "" }); @@ -36,14 +37,7 @@ export const pushStable = createWorkflow({ "runs-on": "webiny-build-packages", steps: [ ...yarnCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, + ...installBuildSteps, // Once we've built packages (without the help of the global cache), we can now cache // the result for this run workflow. All of the following jobs will use this cache. @@ -62,14 +56,7 @@ export const pushStable = createWorkflow({ steps: [ ...yarnCacheSteps, ...runBuildCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build" - }, + ...installBuildSteps, { name: 'Create ".npmrc" file in the project root', run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc' @@ -104,14 +91,7 @@ export const pushStable = createWorkflow({ steps: [ ...yarnCacheSteps, ...runBuildCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build" - }, + ...installBuildSteps, { name: 'Create ".npmrc" file in the project root', run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc' From 3134e9b1b6dabf300c5b1790040813f3da22f0a3 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:36:51 +0200 Subject: [PATCH 26/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 834 ++++++++++++++++++ .../wac/pullRequestsCommandCypress.wac.ts | 162 ++-- 2 files changed, 913 insertions(+), 83 deletions(-) create mode 100644 .github/workflows/pullRequestsCommandCypressTest.yml diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml new file mode 100644 index 00000000000..aef47672ebd --- /dev/null +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -0,0 +1,834 @@ +# This file was automatically generated by github-actions-wac. +# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) +# and run "github-actions-wac build" (or "ghawac build") to regenerate this file. +# For more information, run "github-actions-wac --help". +name: Pull Requests Command - Cypress (Test) +'on': issue_comment +env: + NODE_OPTIONS: '--max_old_space_size=4096' + AWS_REGION: eu-central-1 +jobs: + validateWorkflows: + name: Validate workflows + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install dependencies + run: yarn --immutable + - name: Validate + run: npx github-actions-wac validate + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + checkComment: + name: Check comment for /cypress + if: ${{ github.event.issue.pull_request }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Check for Command + id: command + uses: xt0rted/slash-command-action@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + command: cypress + reaction: 'true' + reaction-type: eyes + allow-edits: 'false' + permission-level: write + - name: Create comment + uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ github.event.issue.number }} + body: >- + Cypress E2E tests have been initiated (for more information, click + [here](https://github.com/webiny/webiny-js/actions/runs/${{ + github.run_id }})). :sparkles: + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + constants: + needs: checkComment + name: Create constants + outputs: + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} + run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Create global cache key + id: global-cache-key + run: >- + echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} + -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ + vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + - name: Create workflow run cache key + id: run-cache-key + run: >- + echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ + vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + build: + name: Build + needs: constants + runs-on: blacksmith-4vcpu-ubuntu-2204 + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Build packages + run: yarn build:quick + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + e2e-wby-cms-ddb-constants: + needs: constants + name: Constants - DDB + outputs: + cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: '' + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - name: List Cypress tests folders + id: list-cypress-folders + run: >- + echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> + $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + e2e-wby-cms-ddb-project-setup: + needs: + - constants + - e2e-wby-cms-ddb-constants + name: E2E (DDB) - Project setup + outputs: + cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-constants.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs + aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn --immutable + - name: Build packages + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn build:quick + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Start Verdaccio local server + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c + .verdaccio.yaml + - name: Configure NPM to use local registry + run: npm config set registry http://localhost:4873 + - name: Set git email + run: git config --global user.email "webiny-bot@webiny.com" + - name: Set git username + run: git config --global user.name "webiny-bot" + - name: Create ".npmrc" file in the project root, with a dummy auth token + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc + - name: Version and publish to Verdaccio + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn release --type=verdaccio + - name: Create verdaccio-files artifact + uses: actions/upload-artifact@v4 + with: + name: verdaccio-files-ddb + retention-days: 1 + path: >- + $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ + + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.verdaccio.yaml + - name: Disable Webiny telemetry + run: > + mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > + ~/.webiny/config + - name: Create a new Webiny project + run: > + npx create-webiny-project@local-npm new-webiny-project --tag local-npm + --no-interactive --assign-to-yarnrc + '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' + --template-options '{"region":"${{ env.AWS_REGION + }}","storageOperations":"ddb"}' + - name: Print CLI version + working-directory: new-webiny-project + run: yarn webiny --version + - name: Create project-files artifact + uses: actions/upload-artifact@v4 + with: + name: project-files-ddb + retention-days: 1 + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* + - name: Deploy Core + working-directory: new-webiny-project + run: yarn webiny deploy apps/core --env dev + - name: Deploy API + working-directory: new-webiny-project + run: yarn webiny deploy apps/api --env dev + - name: Deploy Admin Area + working-directory: new-webiny-project + run: yarn webiny deploy apps/admin --env dev + - name: Deploy Website + working-directory: new-webiny-project + run: yarn webiny deploy apps/website --env dev + - name: Create Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn setup-cypress --projectFolder ../new-webiny-project + - name: Save Cypress config + id: save-cypress-config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d + '\t\n\r')" >> $GITHUB_OUTPUT + - name: Cypress - run installation wizard test + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn cy:run --browser chrome --spec + "cypress/e2e/adminInstallation/**/*.cy.js" + runs-on: ubuntu-latest + permissions: + id-token: write + e2e-wby-cms-ddb-cypress-tests: + name: >- + ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node + }}) + needs: + - constants + - e2e-wby-cms-ddb-constants + - e2e-wby-cms-ddb-project-setup + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + node: + - 18 + cypress-folder: >- + ${{ fromJson(needs.e2e-wby-cms-ddb-constants.outputs.cypress-folders) + }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-constants.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Build packages + run: yarn build:quick + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Set up Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo '${{ needs.e2e-wby-cms-ddb-project-setup.outputs.cypress-config + }}' > cypress-tests/cypress.config.ts + - name: Cypress - run "${{ matrix.cypress-folder }}" tests + timeout-minutes: 40 + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + runs-on: ubuntu-latest + e2e-wby-cms-ddb-es-constants: + needs: constants + name: Constants - DDB-ES + outputs: + cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: '' + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - name: List Cypress tests folders + id: list-cypress-folders + run: >- + echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> + $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-es" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + e2e-wby-cms-ddb-es-project-setup: + needs: + - constants + - e2e-wby-cms-ddb-es-constants + name: E2E (DDB-ES) - Project setup + outputs: + cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.pulumi-backend-url }} + AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} + ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs + aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn --immutable + - name: Build packages + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn build:quick + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Start Verdaccio local server + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c + .verdaccio.yaml + - name: Configure NPM to use local registry + run: npm config set registry http://localhost:4873 + - name: Set git email + run: git config --global user.email "webiny-bot@webiny.com" + - name: Set git username + run: git config --global user.name "webiny-bot" + - name: Create ".npmrc" file in the project root, with a dummy auth token + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc + - name: Version and publish to Verdaccio + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn release --type=verdaccio + - name: Create verdaccio-files artifact + uses: actions/upload-artifact@v4 + with: + name: verdaccio-files-ddb-es + retention-days: 1 + path: >- + $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ + + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.verdaccio.yaml + - name: Disable Webiny telemetry + run: > + mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > + ~/.webiny/config + - name: Create a new Webiny project + run: > + npx create-webiny-project@local-npm new-webiny-project --tag local-npm + --no-interactive --assign-to-yarnrc + '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' + --template-options '{"region":"${{ env.AWS_REGION + }}","storageOperations":"ddb-es"}' + - name: Print CLI version + working-directory: new-webiny-project + run: yarn webiny --version + - name: Create project-files artifact + uses: actions/upload-artifact@v4 + with: + name: project-files-ddb-es + retention-days: 1 + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* + - name: Deploy Core + working-directory: new-webiny-project + run: yarn webiny deploy apps/core --env dev + - name: Deploy API + working-directory: new-webiny-project + run: yarn webiny deploy apps/api --env dev + - name: Deploy Admin Area + working-directory: new-webiny-project + run: yarn webiny deploy apps/admin --env dev + - name: Deploy Website + working-directory: new-webiny-project + run: yarn webiny deploy apps/website --env dev + - name: Create Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn setup-cypress --projectFolder ../new-webiny-project + - name: Save Cypress config + id: save-cypress-config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d + '\t\n\r')" >> $GITHUB_OUTPUT + - name: Cypress - run installation wizard test + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn cy:run --browser chrome --spec + "cypress/e2e/adminInstallation/**/*.cy.js" + runs-on: ubuntu-latest + permissions: + id-token: write + e2e-wby-cms-ddb-es-cypress-tests: + name: >- + ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ + matrix.node }}) + needs: + - constants + - e2e-wby-cms-ddb-es-constants + - e2e-wby-cms-ddb-es-project-setup + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + node: + - 18 + cypress-folder: >- + ${{ + fromJson(needs.e2e-wby-cms-ddb-es-constants.outputs.cypress-folders) + }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.pulumi-backend-url }} + AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} + ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Build packages + run: yarn build:quick + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Set up Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo '${{ + needs.e2e-wby-cms-ddb-es-project-setup.outputs.cypress-config }}' > + cypress-tests/cypress.config.ts + - name: Cypress - run "${{ matrix.cypress-folder }}" tests + timeout-minutes: 40 + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + runs-on: ubuntu-latest + e2e-wby-cms-ddb-os-constants: + needs: constants + name: Constants - DDB-OS + outputs: + cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: '' + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - name: List Cypress tests folders + id: list-cypress-folders + run: >- + echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> + $GITHUB_OUTPUT + - name: Get Pulumi backend URL + id: get-pulumi-backend-url + run: >- + echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ + github.run_id }}_ddb-os" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + e2e-wby-cms-ddb-os-project-setup: + needs: + - constants + - e2e-wby-cms-ddb-os-constants + name: E2E (DDB-OS) - Project setup + outputs: + cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.pulumi-backend-url }} + AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} + ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs + aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn --immutable + - name: Build packages + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn build:quick + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Start Verdaccio local server + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c + .verdaccio.yaml + - name: Configure NPM to use local registry + run: npm config set registry http://localhost:4873 + - name: Set git email + run: git config --global user.email "webiny-bot@webiny.com" + - name: Set git username + run: git config --global user.name "webiny-bot" + - name: Create ".npmrc" file in the project root, with a dummy auth token + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc + - name: Version and publish to Verdaccio + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn release --type=verdaccio + - name: Create verdaccio-files artifact + uses: actions/upload-artifact@v4 + with: + name: verdaccio-files-ddb-os + retention-days: 1 + path: >- + $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ + + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.verdaccio.yaml + - name: Disable Webiny telemetry + run: > + mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > + ~/.webiny/config + - name: Create a new Webiny project + run: > + npx create-webiny-project@local-npm new-webiny-project --tag local-npm + --no-interactive --assign-to-yarnrc + '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' + --template-options '{"region":"${{ env.AWS_REGION + }}","storageOperations":"ddb-os"}' + - name: Print CLI version + working-directory: new-webiny-project + run: yarn webiny --version + - name: Create project-files artifact + uses: actions/upload-artifact@v4 + with: + name: project-files-ddb-os + retention-days: 1 + path: |- + new-webiny-project/ + !new-webiny-project/node_modules/**/* + !new-webiny-project/**/node_modules/**/* + !new-webiny-project/.yarn/cache/**/* + - name: Deploy Core + working-directory: new-webiny-project + run: yarn webiny deploy apps/core --env dev + - name: Deploy API + working-directory: new-webiny-project + run: yarn webiny deploy apps/api --env dev + - name: Deploy Admin Area + working-directory: new-webiny-project + run: yarn webiny deploy apps/admin --env dev + - name: Deploy Website + working-directory: new-webiny-project + run: yarn webiny deploy apps/website --env dev + - name: Create Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn setup-cypress --projectFolder ../new-webiny-project + - name: Save Cypress config + id: save-cypress-config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d + '\t\n\r')" >> $GITHUB_OUTPUT + - name: Cypress - run installation wizard test + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + yarn cy:run --browser chrome --spec + "cypress/e2e/adminInstallation/**/*.cy.js" + runs-on: ubuntu-latest + permissions: + id-token: write + e2e-wby-cms-ddb-os-cypress-tests: + name: >- + ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ + matrix.node }}) + needs: + - constants + - e2e-wby-cms-ddb-os-constants + - e2e-wby-cms-ddb-os-project-setup + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + node: + - 18 + cypress-folder: >- + ${{ + fromJson(needs.e2e-wby-cms-ddb-os-constants.outputs.cypress-folders) + }} + environment: next + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} + PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} + WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.pulumi-backend-url }} + AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} + ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} + ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: >- + $(hub pr show ${{ github.event.issue.number }} -f + %B)/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Build packages + run: yarn build:quick + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Set up Cypress config + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: >- + echo '${{ + needs.e2e-wby-cms-ddb-os-project-setup.outputs.cypress-config }}' > + cypress-tests/cypress.config.ts + - name: Cypress - run "${{ matrix.cypress-folder }}" tests + timeout-minutes: 40 + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" + runs-on: ubuntu-latest diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 5e92fb74c7c..37ed065586d 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -1,11 +1,25 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; -import { createSetupVerdaccioSteps, createDeployWebinySteps } from "./steps"; +import { + createSetupVerdaccioSteps, + createDeployWebinySteps, + createYarnCacheSteps, + createInstallBuildSteps, + createGlobalBuildCacheSteps, + createRunBuildCacheSteps +} from "./steps"; import { NODE_OPTIONS, NODE_VERSION } from "./utils"; import { createJob, createValidateWorkflowsJob } from "./jobs"; -const DIR_PR = "checked-out-pr"; +// Will print "next" or "dev". Important for caching (via actions/cache). +const BRANCH_NAME = "$(hub pr show ${{ github.event.issue.number }} -f %B)"; +const DIR_WEBINY_JS = BRANCH_NAME; const DIR_TEST_PROJECT = "new-webiny-project"; +const installBuildSteps = createInstallBuildSteps({ workingDirectory: DIR_WEBINY_JS }); +const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: DIR_WEBINY_JS }); +const globalBuildCacheSteps = createGlobalBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); +const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); + const createCheckoutPrSteps = ({ workingDirectory = "" } = {}) => [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, @@ -19,17 +33,7 @@ const createCheckoutPrSteps = ({ workingDirectory = "" } = {}) => } ] as NonNullable; -const yarnCacheSteps: NormalJob["steps"] = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_PR + "/.yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - } -]; - -const createJobs = (dbSetup: string) => { +const createCypressJobs = (dbSetup: string) => { const jobNames = { constants: `e2e-wby-cms-${dbSetup}-constants`, projectSetup: `e2e-wby-cms-${dbSetup}-project-setup`, @@ -37,27 +41,14 @@ const createJobs = (dbSetup: string) => { }; const constantsJob: NormalJob = createJob({ - needs: "checkComment", - name: `E2E (${dbSetup.toUpperCase()}) - Constants`, + needs: "constants", + name: `Constants - ${dbSetup.toUpperCase()}`, outputs: { - "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", - "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}", "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, steps: [ ...createCheckoutPrSteps(), - { - name: "Create global cache key", - id: "global-cache-key", - run: 'echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT', - env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" } - }, - { - name: "Create workflow run cache key", - id: "run-cache-key", - run: 'echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' - }, { name: "List Cypress tests folders", id: "list-cypress-folders", @@ -71,26 +62,6 @@ const createJobs = (dbSetup: string) => { ] }); - const buildGlobalCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_PR + "/.webiny/cached-packages", - key: `\${{ needs.${jobNames.constants}.outputs.global-cache-key }}` - } - } - ]; - - const buildRunCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: DIR_PR + "/.webiny/cached-packages", - key: `\${{ needs.${jobNames.constants}.outputs.run-cache-key }}` - } - } - ]; - const env: Record = { CYPRESS_MAILOSAUR_API_KEY: "${{ secrets.CYPRESS_MAILOSAUR_API_KEY }}", PULUMI_CONFIG_PASSPHRASE: "${{ secrets.PULUMI_CONFIG_PASSPHRASE }}", @@ -111,39 +82,39 @@ const createJobs = (dbSetup: string) => { } const projectSetupJob: NormalJob = createJob({ - needs: jobNames.constants, + needs: ["constants", jobNames.constants], name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, outputs: { "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" }, environment: "next", env, - checkout: { path: DIR_PR }, + checkout: { path: DIR_WEBINY_JS }, awsAuth: true, steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_PR }), + ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), ...yarnCacheSteps, - ...buildGlobalCacheSteps, + ...globalBuildCacheSteps, { name: "Install dependencies", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: "yarn --immutable" }, { name: "Build packages", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: "yarn build:quick" }, - ...buildRunCacheSteps, - ...createSetupVerdaccioSteps({ workingDirectory: DIR_PR }), + ...runBuildCacheSteps, + ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), { name: 'Create ".npmrc" file in the project root, with a dummy auth token', - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" }, { name: "Version and publish to Verdaccio", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: "yarn release --type=verdaccio" }, { @@ -152,7 +123,9 @@ const createJobs = (dbSetup: string) => { with: { name: `verdaccio-files-${dbSetup}`, "retention-days": 1, - path: [DIR_PR + "/.verdaccio/", DIR_PR + "/.verdaccio.yaml"].join("\n") + path: [DIR_WEBINY_JS + "/.verdaccio/", DIR_WEBINY_JS + "/.verdaccio.yaml"].join( + "\n" + ) } }, { @@ -186,18 +159,18 @@ const createJobs = (dbSetup: string) => { ...createDeployWebinySteps({ workingDirectory: DIR_TEST_PROJECT }), { name: "Create Cypress config", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: `yarn setup-cypress --projectFolder ../${DIR_TEST_PROJECT}` }, { name: "Save Cypress config", id: "save-cypress-config", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: "echo \"cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\\t\\n\\r')\" >> $GITHUB_OUTPUT" }, { name: "Cypress - run installation wizard test", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: 'yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js"' } ] @@ -205,7 +178,7 @@ const createJobs = (dbSetup: string) => { const cypressTestsJob = createJob({ name: `\${{ matrix.cypress-folder }} (${dbSetup}, \${{ matrix.os }}, Node v\${{ matrix.node }})`, - needs: [jobNames.constants, jobNames.projectSetup], + needs: ["constants", jobNames.constants, jobNames.projectSetup], strategy: { "fail-fast": false, matrix: { @@ -216,30 +189,21 @@ const createJobs = (dbSetup: string) => { }, environment: "next", env, - checkout: { path: DIR_PR }, + checkout: { path: DIR_WEBINY_JS }, steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_PR }), + ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), ...yarnCacheSteps, - ...buildRunCacheSteps, - { - name: "Install dependencies", - "working-directory": DIR_PR, - run: "yarn --immutable" - }, - { - name: "Build packages", - "working-directory": DIR_PR, - run: "yarn build:quick" - }, + ...runBuildCacheSteps, + ...installBuildSteps, { name: "Set up Cypress config", - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: `echo '\${{ needs.${jobNames.projectSetup}.outputs.cypress-config }}' > cypress-tests/cypress.config.ts` }, { name: 'Cypress - run "${{ matrix.cypress-folder }}" tests', "timeout-minutes": 40, - "working-directory": DIR_PR, + "working-directory": DIR_WEBINY_JS, run: 'yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}"' } ] @@ -252,8 +216,8 @@ const createJobs = (dbSetup: string) => { }; }; -export const pullRequestsCommandCypress = createWorkflow({ - name: "Pull Requests Command - Cypress", +export const pullRequestsCommandCypressTest = createWorkflow({ + name: "Pull Requests Command - Cypress (Test)", on: "issue_comment", env: { NODE_OPTIONS, @@ -289,8 +253,40 @@ export const pullRequestsCommandCypress = createWorkflow({ } ] }), - ...createJobs("ddb"), - ...createJobs("ddb-es"), - ...createJobs("ddb-os") + constants: createJob({ + needs: "checkComment", + name: "Create constants", + outputs: { + "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", + "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" + }, + steps: [ + { + name: "Create global cache key", + id: "global-cache-key", + run: `echo "global-cache-key=${BRANCH_NAME}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT` + }, + { + name: "Create workflow run cache key", + id: "run-cache-key", + run: 'echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' + } + ] + }), + build: createJob({ + name: "Build", + needs: "constants", + checkout: { path: DIR_WEBINY_JS }, + "runs-on": "blacksmith-4vcpu-ubuntu-2204", + steps: [ + ...yarnCacheSteps, + ...globalBuildCacheSteps, + ...installBuildSteps, + ...runBuildCacheSteps + ] + }), + ...createCypressJobs("ddb"), + ...createCypressJobs("ddb-es"), + ...createCypressJobs("ddb-os") } }); From ee1f1b26233a9b0ba7e6cd5e84f3ffa14fcea4a1 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:40:23 +0200 Subject: [PATCH 27/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 39 +++++++------------ .../wac/pullRequestsCommandCypress.wac.ts | 10 +++-- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index aef47672ebd..3899ff22892 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -62,7 +62,13 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - name: Create global cache key id: global-cache-key run: >- @@ -86,9 +92,13 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache @@ -124,7 +134,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -170,9 +179,6 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -312,9 +318,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -358,7 +361,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -407,9 +409,6 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -553,9 +552,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -600,7 +596,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -649,9 +644,6 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -795,9 +787,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B) - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 37ed065586d..66bfd80b62d 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -47,6 +47,7 @@ const createCypressJobs = (dbSetup: string) => { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, + checkout: false, steps: [ ...createCheckoutPrSteps(), { @@ -89,8 +90,8 @@ const createCypressJobs = (dbSetup: string) => { }, environment: "next", env, - checkout: { path: DIR_WEBINY_JS }, awsAuth: true, + checkout: false, steps: [ ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), ...yarnCacheSteps, @@ -189,7 +190,7 @@ const createCypressJobs = (dbSetup: string) => { }, environment: "next", env, - checkout: { path: DIR_WEBINY_JS }, + checkout: false, steps: [ ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), ...yarnCacheSteps, @@ -260,7 +261,9 @@ export const pullRequestsCommandCypressTest = createWorkflow({ "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" }, + checkout: false, steps: [ + ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), { name: "Create global cache key", id: "global-cache-key", @@ -276,9 +279,10 @@ export const pullRequestsCommandCypressTest = createWorkflow({ build: createJob({ name: "Build", needs: "constants", - checkout: { path: DIR_WEBINY_JS }, + checkout: false, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ + ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), ...yarnCacheSteps, ...globalBuildCacheSteps, ...installBuildSteps, From ff20ada3cc05aa6ea9389d89bc66319f432c60f9 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:47:56 +0200 Subject: [PATCH 28/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 65 ++++++++++++++----- .../wac/pullRequestsCommandCypress.wac.ts | 36 ++++++---- 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index 3899ff22892..a3bb8047f9e 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -52,8 +52,27 @@ jobs: env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false - constants: + baseBranch: needs: checkComment + name: Get base branch + outputs: + base-branch: ${{ steps.base-branch.outputs.base-branch }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Get base branch + id: base-branch + run: >- + echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f + %B)" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + constants: + needs: baseBranch name: Create constants outputs: global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} @@ -65,7 +84,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -86,7 +105,9 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build - needs: constants + needs: + - baseBranch + - constants runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 @@ -95,7 +116,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -125,7 +146,9 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-constants: - needs: constants + needs: + - baseBranch + - constants name: Constants - DDB outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -137,7 +160,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: '' + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -157,6 +180,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-project-setup: needs: + - baseBranch - constants - e2e-wby-cms-ddb-constants name: E2E (DDB) - Project setup @@ -182,7 +206,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -293,6 +317,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch - constants - e2e-wby-cms-ddb-constants - e2e-wby-cms-ddb-project-setup @@ -321,7 +346,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -352,7 +377,9 @@ jobs: run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-es-constants: - needs: constants + needs: + - baseBranch + - constants name: Constants - DDB-ES outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -364,7 +391,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: '' + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -384,6 +411,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-es-project-setup: needs: + - baseBranch - constants - e2e-wby-cms-ddb-es-constants name: E2E (DDB-ES) - Project setup @@ -412,7 +440,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -523,6 +551,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch - constants - e2e-wby-cms-ddb-es-constants - e2e-wby-cms-ddb-es-project-setup @@ -555,7 +584,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -587,7 +616,9 @@ jobs: run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-os-constants: - needs: constants + needs: + - baseBranch + - constants name: Constants - DDB-OS outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -599,7 +630,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: '' + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -619,6 +650,7 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-os-project-setup: needs: + - baseBranch - constants - e2e-wby-cms-ddb-os-constants name: E2E (DDB-OS) - Project setup @@ -647,7 +679,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} @@ -758,6 +790,7 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch - constants - e2e-wby-cms-ddb-os-constants - e2e-wby-cms-ddb-os-project-setup @@ -790,7 +823,7 @@ jobs: - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 66bfd80b62d..c511896081f 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -20,12 +20,12 @@ const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: DIR_WEBINY_JS }) const globalBuildCacheSteps = createGlobalBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); -const createCheckoutPrSteps = ({ workingDirectory = "" } = {}) => +const createCheckoutPrSteps = () => [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, { name: "Checkout Pull Request", - "working-directory": workingDirectory, + "working-directory": "${{ needs.baseBranch.outputs.base-branch }}", run: "hub pr checkout ${{ github.event.issue.number }}", env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" @@ -41,7 +41,7 @@ const createCypressJobs = (dbSetup: string) => { }; const constantsJob: NormalJob = createJob({ - needs: "constants", + needs: ["baseBranch", "constants"], name: `Constants - ${dbSetup.toUpperCase()}`, outputs: { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", @@ -83,7 +83,7 @@ const createCypressJobs = (dbSetup: string) => { } const projectSetupJob: NormalJob = createJob({ - needs: ["constants", jobNames.constants], + needs: ["baseBranch", "constants", jobNames.constants], name: `E2E (${dbSetup.toUpperCase()}) - Project setup`, outputs: { "cypress-config": "${{ steps.save-cypress-config.outputs.cypress-config }}" @@ -93,7 +93,7 @@ const createCypressJobs = (dbSetup: string) => { awsAuth: true, checkout: false, steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), + ...createCheckoutPrSteps(), ...yarnCacheSteps, ...globalBuildCacheSteps, { @@ -179,7 +179,7 @@ const createCypressJobs = (dbSetup: string) => { const cypressTestsJob = createJob({ name: `\${{ matrix.cypress-folder }} (${dbSetup}, \${{ matrix.os }}, Node v\${{ matrix.node }})`, - needs: ["constants", jobNames.constants, jobNames.projectSetup], + needs: ["baseBranch", "constants", jobNames.constants, jobNames.projectSetup], strategy: { "fail-fast": false, matrix: { @@ -192,7 +192,7 @@ const createCypressJobs = (dbSetup: string) => { env, checkout: false, steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), + ...createCheckoutPrSteps(), ...yarnCacheSteps, ...runBuildCacheSteps, ...installBuildSteps, @@ -254,8 +254,22 @@ export const pullRequestsCommandCypressTest = createWorkflow({ } ] }), - constants: createJob({ + baseBranch: createJob({ needs: "checkComment", + name: "Get base branch", + outputs: { + "base-branch": "${{ steps.base-branch.outputs.base-branch }}" + }, + steps: [ + { + name: "Get base branch", + id: "base-branch", + run: 'echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f %B)" >> $GITHUB_OUTPUT' + } + ] + }), + constants: createJob({ + needs: "baseBranch", name: "Create constants", outputs: { "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", @@ -263,7 +277,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ }, checkout: false, steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), + ...createCheckoutPrSteps(), { name: "Create global cache key", id: "global-cache-key", @@ -278,11 +292,11 @@ export const pullRequestsCommandCypressTest = createWorkflow({ }), build: createJob({ name: "Build", - needs: "constants", + needs: ["baseBranch", "constants"], checkout: false, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ - ...createCheckoutPrSteps({ workingDirectory: DIR_WEBINY_JS }), + ...createCheckoutPrSteps(), ...yarnCacheSteps, ...globalBuildCacheSteps, ...installBuildSteps, From c8345810e95f505ad55c636a953be41a296320e6 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:51:21 +0200 Subject: [PATCH 29/50] ci: refactor steps [no ci] --- .github/workflows/pullRequestsCommandCypressTest.yml | 2 ++ .github/workflows/wac/pullRequestsCommandCypress.wac.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index a3bb8047f9e..f1e924337c5 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -62,6 +62,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + - name: Install Hub Utility + run: sudo apt-get install -y hub - name: Get base branch id: base-branch run: >- diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index c511896081f..3b2574d467d 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -261,6 +261,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ "base-branch": "${{ steps.base-branch.outputs.base-branch }}" }, steps: [ + { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, { name: "Get base branch", id: "base-branch", From 7a19d182f5cb898e851a39e55264e98a6898a45b Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:52:41 +0200 Subject: [PATCH 30/50] ci: refactor steps [no ci] --- .github/workflows/pullRequestsCommandCypressTest.yml | 7 ++++--- .github/workflows/wac/pullRequestsCommandCypress.wac.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index f1e924337c5..f94e0debb54 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -57,6 +57,10 @@ jobs: name: Get base branch outputs: base-branch: ${{ steps.base-branch.outputs.base-branch }} + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - uses: actions/setup-node@v4 with: @@ -70,9 +74,6 @@ jobs: echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f %B)" >> $GITHUB_OUTPUT runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: needs: baseBranch name: Create constants diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 3b2574d467d..a675c11de66 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -260,6 +260,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ outputs: { "base-branch": "${{ steps.base-branch.outputs.base-branch }}" }, + env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, steps: [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, { From 8c772f662c6f665ff1dd281d7b4612ca7fda2a57 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 13:55:38 +0200 Subject: [PATCH 31/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 22 +++++++++++++++++++ .../wac/pullRequestsCommandCypress.wac.ts | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index f94e0debb54..9b720b7797d 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -86,6 +86,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -118,6 +120,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -162,6 +166,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -208,6 +214,8 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -348,6 +356,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -393,6 +403,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -442,6 +454,8 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -586,6 +600,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -632,6 +648,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -681,6 +699,8 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -825,6 +845,8 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub + - name: Create new folder for the base branch + run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index a675c11de66..54cad457e99 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -23,6 +23,10 @@ const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBI const createCheckoutPrSteps = () => [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, + { + name: "Create new folder for the base branch", + run: 'mkdir -p "${{ needs.baseBranch.outputs.base-branch }}"' + }, { name: "Checkout Pull Request", "working-directory": "${{ needs.baseBranch.outputs.base-branch }}", From cede5318153a26243c7a3688393fbaa9b64b83c5 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:03:15 +0200 Subject: [PATCH 32/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 32 +++++++++---------- .../wac/jobs/createValidateWorkflowsJob.ts | 8 +++-- .../wac/pullRequestsCommandCypress.wac.ts | 7 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index 9b720b7797d..e508c84f90e 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -8,21 +8,6 @@ env: NODE_OPTIONS: '--max_old_space_size=4096' AWS_REGION: eu-central-1 jobs: - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false checkComment: name: Check comment for /cypress if: ${{ github.event.issue.pull_request }} @@ -52,6 +37,22 @@ jobs: env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false + validateWorkflows: + name: Validate workflows + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install dependencies + run: yarn --immutable + - name: Validate + run: npx github-actions-wac validate + needs: checkComment + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false baseBranch: needs: checkComment name: Get base branch @@ -65,7 +66,6 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - name: Get base branch diff --git a/.github/workflows/wac/jobs/createValidateWorkflowsJob.ts b/.github/workflows/wac/jobs/createValidateWorkflowsJob.ts index 36aaa5a46be..ca00060c893 100644 --- a/.github/workflows/wac/jobs/createValidateWorkflowsJob.ts +++ b/.github/workflows/wac/jobs/createValidateWorkflowsJob.ts @@ -1,6 +1,9 @@ import { createJob } from "./createJob"; +import { NormalJob } from "github-actions-wac"; -export const createValidateWorkflowsJob = () => +type CreateValidateWorkflowsJobParams = Partial; + +export const createValidateWorkflowsJob = (params: CreateValidateWorkflowsJobParams = {}) => createJob({ name: "Validate workflows", steps: [ @@ -12,5 +15,6 @@ export const createValidateWorkflowsJob = () => name: "Validate", run: "npx github-actions-wac validate" } - ] + ], + ...params }); diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 54cad457e99..6f4691517cc 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -31,9 +31,7 @@ const createCheckoutPrSteps = () => name: "Checkout Pull Request", "working-directory": "${{ needs.baseBranch.outputs.base-branch }}", run: "hub pr checkout ${{ github.event.issue.number }}", - env: { - GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" - } + env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" } } ] as NonNullable; @@ -229,7 +227,6 @@ export const pullRequestsCommandCypressTest = createWorkflow({ AWS_REGION: "eu-central-1" }, jobs: { - validateWorkflows: createValidateWorkflowsJob(), checkComment: createJob({ name: `Check comment for /cypress`, if: "${{ github.event.issue.pull_request }}", @@ -258,12 +255,14 @@ export const pullRequestsCommandCypressTest = createWorkflow({ } ] }), + validateWorkflows: createValidateWorkflowsJob({ needs: "checkComment" }), baseBranch: createJob({ needs: "checkComment", name: "Get base branch", outputs: { "base-branch": "${{ steps.base-branch.outputs.base-branch }}" }, + checkout: false, env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, steps: [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, From 9df59582c6b1c41d94b139706b7c6aa4f946ebd0 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:07:21 +0200 Subject: [PATCH 33/50] ci: refactor steps [no ci] --- .../workflows/pullRequestsCommandCypressTest.yml | 14 ++++++++------ .../wac/pullRequestsCommandCypress.wac.ts | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index e508c84f90e..d36a5b637b5 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -80,6 +80,10 @@ jobs: outputs: global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - uses: actions/setup-node@v4 with: @@ -105,14 +109,15 @@ jobs: echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build needs: - baseBranch - constants + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 @@ -149,9 +154,6 @@ jobs: $(hub pr show ${{ github.event.issue.number }} -f %B)/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-constants: needs: - baseBranch diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 6f4691517cc..150bb3784db 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -281,6 +281,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" }, checkout: false, + env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, steps: [ ...createCheckoutPrSteps(), { @@ -299,6 +300,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ name: "Build", needs: ["baseBranch", "constants"], checkout: false, + env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createCheckoutPrSteps(), From eda1ad1002d3e6c72b89e6b059cf604101b58ef3 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:15:23 +0200 Subject: [PATCH 34/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 60 +++++-------------- .../wac/pullRequestsCommandCypress.wac.ts | 15 ++--- 2 files changed, 20 insertions(+), 55 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index d36a5b637b5..b66bc501804 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -58,14 +58,11 @@ jobs: name: Get base branch outputs: base-branch: ${{ steps.base-branch.outputs.base-branch }} - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - name: Get base branch @@ -74,59 +71,49 @@ jobs: echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f %B)" >> $GITHUB_OUTPUT runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: needs: baseBranch name: Create constants outputs: global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - name: Create global cache key id: global-cache-key run: >- - echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} - -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + echo "global-cache-key=${{ needs.baseBranch.outputs.base-branch }}-${{ + runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX + }}" >> $GITHUB_OUTPUT - name: Create workflow run cache key id: run-cache-key run: >- echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build needs: - baseBranch - constants - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -154,6 +141,9 @@ jobs: $(hub pr show ${{ github.event.issue.number }} -f %B)/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-constants: needs: - baseBranch @@ -168,8 +158,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -216,8 +204,6 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -358,8 +344,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -405,8 +389,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -456,8 +438,6 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -602,8 +582,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -650,8 +628,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -701,8 +677,6 @@ jobs: aws-region: eu-central-1 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} @@ -847,8 +821,6 @@ jobs: node-version: 18 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Create new folder for the base branch - run: mkdir -p "${{ needs.baseBranch.outputs.base-branch }}" - name: Checkout Pull Request working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 150bb3784db..516ebc04321 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -23,10 +23,6 @@ const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBI const createCheckoutPrSteps = () => [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, - { - name: "Create new folder for the base branch", - run: 'mkdir -p "${{ needs.baseBranch.outputs.base-branch }}"' - }, { name: "Checkout Pull Request", "working-directory": "${{ needs.baseBranch.outputs.base-branch }}", @@ -262,8 +258,6 @@ export const pullRequestsCommandCypressTest = createWorkflow({ outputs: { "base-branch": "${{ steps.base-branch.outputs.base-branch }}" }, - checkout: false, - env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, steps: [ { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, { @@ -281,13 +275,11 @@ export const pullRequestsCommandCypressTest = createWorkflow({ "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}" }, checkout: false, - env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, steps: [ - ...createCheckoutPrSteps(), { name: "Create global cache key", id: "global-cache-key", - run: `echo "global-cache-key=${BRANCH_NAME}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT` + run: `echo "global-cache-key=\${{ needs.baseBranch.outputs.base-branch }}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT` }, { name: "Create workflow run cache key", @@ -299,8 +291,9 @@ export const pullRequestsCommandCypressTest = createWorkflow({ build: createJob({ name: "Build", needs: ["baseBranch", "constants"], - checkout: false, - env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, + checkout: { + path: "${{ needs.baseBranch.outputs.base-branch }}" + }, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createCheckoutPrSteps(), From c8b92002f9ef7f058898debdc42156edfb26310a Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:18:24 +0200 Subject: [PATCH 35/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 27 +++++++++++++++++++ .../wac/pullRequestsCommandCypress.wac.ts | 10 +++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index b66bc501804..d8e48e24d84 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -156,6 +156,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -202,6 +205,9 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -342,6 +348,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -387,6 +396,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -436,6 +448,9 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -580,6 +595,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -626,6 +644,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -675,6 +696,9 @@ jobs: with: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request @@ -819,6 +843,9 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 516ebc04321..9520a8508d1 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -45,7 +45,7 @@ const createCypressJobs = (dbSetup: string) => { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, - checkout: false, + checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, steps: [ ...createCheckoutPrSteps(), { @@ -89,7 +89,7 @@ const createCypressJobs = (dbSetup: string) => { environment: "next", env, awsAuth: true, - checkout: false, + checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, steps: [ ...createCheckoutPrSteps(), ...yarnCacheSteps, @@ -188,7 +188,7 @@ const createCypressJobs = (dbSetup: string) => { }, environment: "next", env, - checkout: false, + checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, steps: [ ...createCheckoutPrSteps(), ...yarnCacheSteps, @@ -291,9 +291,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ build: createJob({ name: "Build", needs: ["baseBranch", "constants"], - checkout: { - path: "${{ needs.baseBranch.outputs.base-branch }}" - }, + checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createCheckoutPrSteps(), From 0de294761d4e404f3f54c00c6fd7bce16ce4f058 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:27:06 +0200 Subject: [PATCH 36/50] ci: refactor steps [no ci] --- .github/workflows/pullRequestsCommandCypressTest.yml | 2 ++ .github/workflows/wac/pullRequestsCommandCypress.wac.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index d8e48e24d84..6375e744bd4 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -67,6 +67,8 @@ jobs: run: sudo apt-get install -y hub - name: Get base branch id: base-branch + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} run: >- echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f %B)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 9520a8508d1..2b40a52b136 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -263,6 +263,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ { name: "Get base branch", id: "base-branch", + env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" }, run: 'echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f %B)" >> $GITHUB_OUTPUT' } ] From 609c73f684ee477e907548dcbd542ebf63e64821 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:36:17 +0200 Subject: [PATCH 37/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 161 ++++++++---------- .../wac/pullRequestsCommandCypress.wac.ts | 24 +-- 2 files changed, 75 insertions(+), 110 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index 6375e744bd4..9d58249df92 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -123,25 +123,21 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -150,6 +146,7 @@ jobs: needs: - baseBranch - constants + - build name: Constants - DDB outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -219,28 +216,24 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -251,21 +244,19 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb retention-days: 1 - path: >- - $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ - - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.verdaccio.yaml + path: |- + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -303,16 +294,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -362,34 +353,33 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-es-constants: needs: - baseBranch - constants + - build name: Constants - DDB-ES outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -462,28 +452,24 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -494,21 +480,19 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-es retention-days: 1 - path: >- - $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ - - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.verdaccio.yaml + path: |- + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -546,16 +530,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -609,35 +593,34 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-es-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-os-constants: needs: - baseBranch - constants + - build name: Constants - DDB-OS outputs: cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} @@ -710,28 +693,24 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -742,21 +721,19 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 with: name: verdaccio-files-ddb-os retention-days: 1 - path: >- - $(hub pr show ${{ github.event.issue.number }} -f %B)/.verdaccio/ - - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.verdaccio.yaml + path: |- + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -794,16 +771,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -857,28 +834,26 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: $(hub pr show ${{ github.event.issue.number }} -f %B)/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: >- - $(hub pr show ${{ github.event.issue.number }} -f - %B)/.webiny/cached-packages + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-os-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: $(hub pr show ${{ github.event.issue.number }} -f %B) + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 2b40a52b136..6a48be9458e 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -11,8 +11,7 @@ import { NODE_OPTIONS, NODE_VERSION } from "./utils"; import { createJob, createValidateWorkflowsJob } from "./jobs"; // Will print "next" or "dev". Important for caching (via actions/cache). -const BRANCH_NAME = "$(hub pr show ${{ github.event.issue.number }} -f %B)"; -const DIR_WEBINY_JS = BRANCH_NAME; +const DIR_WEBINY_JS = "${{ needs.baseBranch.outputs.base-branch }}"; const DIR_TEST_PROJECT = "new-webiny-project"; const installBuildSteps = createInstallBuildSteps({ workingDirectory: DIR_WEBINY_JS }); @@ -25,7 +24,7 @@ const createCheckoutPrSteps = () => { name: "Install Hub Utility", run: "sudo apt-get install -y hub" }, { name: "Checkout Pull Request", - "working-directory": "${{ needs.baseBranch.outputs.base-branch }}", + "working-directory": DIR_WEBINY_JS, run: "hub pr checkout ${{ github.event.issue.number }}", env: { GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" } } @@ -39,13 +38,13 @@ const createCypressJobs = (dbSetup: string) => { }; const constantsJob: NormalJob = createJob({ - needs: ["baseBranch", "constants"], + needs: ["baseBranch", "constants", "build"], name: `Constants - ${dbSetup.toUpperCase()}`, outputs: { "cypress-folders": "${{ steps.list-cypress-folders.outputs.cypress-folders }}", "pulumi-backend-url": "${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }}" }, - checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, + checkout: { path: DIR_WEBINY_JS }, steps: [ ...createCheckoutPrSteps(), { @@ -89,21 +88,12 @@ const createCypressJobs = (dbSetup: string) => { environment: "next", env, awsAuth: true, - checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, + checkout: { path: DIR_WEBINY_JS }, steps: [ ...createCheckoutPrSteps(), ...yarnCacheSteps, ...globalBuildCacheSteps, - { - name: "Install dependencies", - "working-directory": DIR_WEBINY_JS, - run: "yarn --immutable" - }, - { - name: "Build packages", - "working-directory": DIR_WEBINY_JS, - run: "yarn build:quick" - }, + ...installBuildSteps, ...runBuildCacheSteps, ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), { @@ -292,7 +282,7 @@ export const pullRequestsCommandCypressTest = createWorkflow({ build: createJob({ name: "Build", needs: ["baseBranch", "constants"], - checkout: { path: "${{ needs.baseBranch.outputs.base-branch }}" }, + checkout: { path: DIR_WEBINY_JS }, "runs-on": "blacksmith-4vcpu-ubuntu-2204", steps: [ ...createCheckoutPrSteps(), From c14ac910cabd200e412d0ecf56c3f00e25b56e71 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:44:05 +0200 Subject: [PATCH 38/50] ci: refactor steps [no ci] --- .github/workflows/wac/pullRequestsCommandCypress.wac.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 6a48be9458e..65650e3dc7c 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -92,9 +92,8 @@ const createCypressJobs = (dbSetup: string) => { steps: [ ...createCheckoutPrSteps(), ...yarnCacheSteps, - ...globalBuildCacheSteps, - ...installBuildSteps, ...runBuildCacheSteps, + ...installBuildSteps, ...createSetupVerdaccioSteps({ workingDirectory: DIR_WEBINY_JS }), { name: 'Create ".npmrc" file in the project root, with a dummy auth token', From 308e0cce6e25283a706994b78184371959c05fe1 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 14:47:30 +0200 Subject: [PATCH 39/50] ci: refactor steps [no ci] --- .../pullRequestsCommandCypressTest.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index 9d58249df92..82345fed6fa 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -221,17 +221,13 @@ jobs: - uses: actions/cache@v4 with: path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.global-cache-key }} + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- @@ -457,17 +453,13 @@ jobs: - uses: actions/cache@v4 with: path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.global-cache-key }} + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- @@ -698,17 +690,13 @@ jobs: - uses: actions/cache@v4 with: path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.global-cache-key }} + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages run: yarn build:quick working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - name: Start Verdaccio local server working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- From 7cedf6d1490f9aebb339eafd04b1e918b0d1f141 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 15:42:04 +0200 Subject: [PATCH 40/50] ci: refactor steps [no ci] --- .github/workflows/pullRequestsCommandCypressTest.yml | 3 +++ .github/workflows/wac/pullRequestsCommandCypress.wac.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml index 82345fed6fa..6aede9dcdf8 100644 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ b/.github/workflows/pullRequestsCommandCypressTest.yml @@ -170,6 +170,7 @@ jobs: run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- @@ -399,6 +400,7 @@ jobs: run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- @@ -636,6 +638,7 @@ jobs: run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 65650e3dc7c..541db161bb8 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -50,7 +50,8 @@ const createCypressJobs = (dbSetup: string) => { { name: "List Cypress tests folders", id: "list-cypress-folders", - run: 'echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT' + run: 'echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT', + "working-directory": DIR_WEBINY_JS }, { name: "Get Pulumi backend URL", From e926e30d9b26d078dec9e74d6f02bfc10af97a00 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 21:54:42 +0200 Subject: [PATCH 41/50] ci: remove test workflow [no ci] --- .../workflows/pullRequestsCommandCypress.yml | 370 ++++---- .../pullRequestsCommandCypressTest.yml | 850 ------------------ .../wac/pullRequestsCommandCypress.wac.ts | 4 +- 3 files changed, 220 insertions(+), 1004 deletions(-) delete mode 100644 .github/workflows/pullRequestsCommandCypressTest.yml diff --git a/.github/workflows/pullRequestsCommandCypress.yml b/.github/workflows/pullRequestsCommandCypress.yml index 0d78e311bc3..c84a1963233 100644 --- a/.github/workflows/pullRequestsCommandCypress.yml +++ b/.github/workflows/pullRequestsCommandCypress.yml @@ -8,21 +8,6 @@ env: NODE_OPTIONS: '--max_old_space_size=4096' AWS_REGION: eu-central-1 jobs: - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false checkComment: name: Check comment for /cypress if: ${{ github.event.issue.pull_request }} @@ -52,14 +37,27 @@ jobs: env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false - e2e-wby-cms-ddb-constants: + validateWorkflows: + name: Validate workflows + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + - name: Install dependencies + run: yarn --immutable + - name: Validate + run: npx github-actions-wac validate + needs: checkComment + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + baseBranch: needs: checkComment - name: E2E (DDB) - Constants + name: Get base branch outputs: - global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} - run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} - cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} - pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} + base-branch: ${{ steps.base-branch.outputs.base-branch }} steps: - uses: actions/setup-node@v4 with: @@ -67,29 +65,112 @@ jobs: - uses: actions/checkout@v4 - name: Install Hub Utility run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: '' - run: hub pr checkout ${{ github.event.issue.number }} + - name: Get base branch + id: base-branch env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + run: >- + echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f + %B)" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + constants: + needs: baseBranch + name: Create constants + outputs: + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} + run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: Create global cache key id: global-cache-key run: >- - echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} - -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + echo "global-cache-key=${{ needs.baseBranch.outputs.base-branch }}-${{ + runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX + }}" >> $GITHUB_OUTPUT - name: Create workflow run cache key id: run-cache-key run: >- echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + build: + name: Build + needs: + - baseBranch + - constants + runs-on: blacksmith-4vcpu-ubuntu-2204 + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: ${{ needs.baseBranch.outputs.base-branch }} + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + - uses: actions/cache@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} + - name: Build packages + run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} + - uses: actions/cache@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + e2e-wby-cms-ddb-constants: + needs: + - baseBranch + - constants + - build + name: Constants - DDB + outputs: + cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} + pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} + - name: Install Hub Utility + run: sudo apt-get install -y hub + - name: Checkout Pull Request + working-directory: ${{ needs.baseBranch.outputs.base-branch }} + run: hub pr checkout ${{ github.event.issue.number }} + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- @@ -100,7 +181,10 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-project-setup: - needs: e2e-wby-cms-ddb-constants + needs: + - baseBranch + - constants + - e2e-wby-cms-ddb-constants name: E2E (DDB) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -123,34 +207,30 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-constants.outputs.global-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick - - uses: actions/cache@v4 - with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-constants.outputs.run-cache-key }} + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Start Verdaccio local server - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -161,10 +241,10 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 @@ -172,8 +252,8 @@ jobs: name: verdaccio-files-ddb retention-days: 1 path: |- - checked-out-pr/.verdaccio/ - checked-out-pr/.verdaccio.yaml + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -211,16 +291,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -232,6 +312,8 @@ jobs: ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch + - constants - e2e-wby-cms-ddb-constants - e2e-wby-cms-ddb-project-setup strategy: @@ -258,44 +340,45 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-constants.outputs.run-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-es-constants: - needs: checkComment - name: E2E (DDB-ES) - Constants + needs: + - baseBranch + - constants + - build + name: Constants - DDB-ES outputs: - global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} - run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: @@ -303,31 +386,21 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: '' + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: Create global cache key - id: global-cache-key - run: >- - echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} - -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: Create workflow run cache key - id: run-cache-key - run: >- - echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- @@ -338,7 +411,10 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-es-project-setup: - needs: e2e-wby-cms-ddb-es-constants + needs: + - baseBranch + - constants + - e2e-wby-cms-ddb-es-constants name: E2E (DDB-ES) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -364,34 +440,30 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.global-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick - - uses: actions/cache@v4 - with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.run-cache-key }} + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Start Verdaccio local server - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -402,10 +474,10 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 @@ -413,8 +485,8 @@ jobs: name: verdaccio-files-ddb-es retention-days: 1 path: |- - checked-out-pr/.verdaccio/ - checked-out-pr/.verdaccio.yaml + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -452,16 +524,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -473,6 +545,8 @@ jobs: ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch + - constants - e2e-wby-cms-ddb-es-constants - e2e-wby-cms-ddb-es-project-setup strategy: @@ -503,45 +577,46 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.run-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-es-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest e2e-wby-cms-ddb-os-constants: - needs: checkComment - name: E2E (DDB-OS) - Constants + needs: + - baseBranch + - constants + - build + name: Constants - DDB-OS outputs: - global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} - run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} steps: @@ -549,31 +624,21 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: '' + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: Create global cache key - id: global-cache-key - run: >- - echo "global-cache-key=$(hub pr show ${{ github.event.issue.number }} - -f %B)-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: Create workflow run cache key - id: run-cache-key - run: >- - echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - name: List Cypress tests folders id: list-cypress-folders run: >- echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> $GITHUB_OUTPUT + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Get Pulumi backend URL id: get-pulumi-backend-url run: >- @@ -584,7 +649,10 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false e2e-wby-cms-ddb-os-project-setup: - needs: e2e-wby-cms-ddb-os-constants + needs: + - baseBranch + - constants + - e2e-wby-cms-ddb-os-constants name: E2E (DDB-OS) - Project setup outputs: cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} @@ -610,34 +678,30 @@ jobs: aws-region: eu-central-1 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.global-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick - - uses: actions/cache@v4 - with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.run-cache-key }} + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Start Verdaccio local server - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c .verdaccio.yaml @@ -648,10 +712,10 @@ jobs: - name: Set git username run: git config --global user.name "webiny-bot" - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - name: Version and publish to Verdaccio - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn release --type=verdaccio - name: Create verdaccio-files artifact uses: actions/upload-artifact@v4 @@ -659,8 +723,8 @@ jobs: name: verdaccio-files-ddb-os retention-days: 1 path: |- - checked-out-pr/.verdaccio/ - checked-out-pr/.verdaccio.yaml + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ + ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - name: Disable Webiny telemetry run: > mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > @@ -698,16 +762,16 @@ jobs: working-directory: new-webiny-project run: yarn webiny deploy apps/website --env dev - name: Create Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn setup-cypress --projectFolder ../new-webiny-project - name: Save Cypress config id: save-cypress-config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d '\t\n\r')" >> $GITHUB_OUTPUT - name: Cypress - run installation wizard test - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- yarn cy:run --browser chrome --spec "cypress/e2e/adminInstallation/**/*.cy.js" @@ -719,6 +783,8 @@ jobs: ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ matrix.node }}) needs: + - baseBranch + - constants - e2e-wby-cms-ddb-os-constants - e2e-wby-cms-ddb-os-project-setup strategy: @@ -749,36 +815,36 @@ jobs: node-version: 18 - uses: actions/checkout@v4 with: - path: checked-out-pr + path: ${{ needs.baseBranch.outputs.base-branch }} - name: Install Hub Utility run: sudo apt-get install -y hub - name: Checkout Pull Request - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: hub pr checkout ${{ github.event.issue.number }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - uses: actions/cache@v4 with: - path: checked-out-pr/.yarn/cache + path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: checked-out-pr/.webiny/cached-packages - key: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.run-cache-key }} + path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages + key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies - working-directory: checked-out-pr run: yarn --immutable + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Build packages - working-directory: checked-out-pr run: yarn build:quick + working-directory: ${{ needs.baseBranch.outputs.base-branch }} - name: Set up Cypress config - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: >- echo '${{ needs.e2e-wby-cms-ddb-os-project-setup.outputs.cypress-config }}' > cypress-tests/cypress.config.ts - name: Cypress - run "${{ matrix.cypress-folder }}" tests timeout-minutes: 40 - working-directory: checked-out-pr + working-directory: ${{ needs.baseBranch.outputs.base-branch }} run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" runs-on: ubuntu-latest diff --git a/.github/workflows/pullRequestsCommandCypressTest.yml b/.github/workflows/pullRequestsCommandCypressTest.yml deleted file mode 100644 index 6aede9dcdf8..00000000000 --- a/.github/workflows/pullRequestsCommandCypressTest.yml +++ /dev/null @@ -1,850 +0,0 @@ -# This file was automatically generated by github-actions-wac. -# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) -# and run "github-actions-wac build" (or "ghawac build") to regenerate this file. -# For more information, run "github-actions-wac --help". -name: Pull Requests Command - Cypress (Test) -'on': issue_comment -env: - NODE_OPTIONS: '--max_old_space_size=4096' - AWS_REGION: eu-central-1 -jobs: - checkComment: - name: Check comment for /cypress - if: ${{ github.event.issue.pull_request }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Check for Command - id: command - uses: xt0rted/slash-command-action@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - command: cypress - reaction: 'true' - reaction-type: eyes - allow-edits: 'false' - permission-level: write - - name: Create comment - uses: peter-evans/create-or-update-comment@v2 - with: - issue-number: ${{ github.event.issue.number }} - body: >- - Cypress E2E tests have been initiated (for more information, click - [here](https://github.com/webiny/webiny-js/actions/runs/${{ - github.run_id }})). :sparkles: - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - needs: checkComment - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - baseBranch: - needs: checkComment - name: Get base branch - outputs: - base-branch: ${{ steps.base-branch.outputs.base-branch }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Get base branch - id: base-branch - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - run: >- - echo "base-branch=$(hub pr show ${{ github.event.issue.number }} -f - %B)" >> $GITHUB_OUTPUT - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - constants: - needs: baseBranch - name: Create constants - outputs: - global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} - run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Create global cache key - id: global-cache-key - run: >- - echo "global-cache-key=${{ needs.baseBranch.outputs.base-branch }}-${{ - runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX - }}" >> $GITHUB_OUTPUT - - name: Create workflow run cache key - id: run-cache-key - run: >- - echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ - vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - build: - name: Build - needs: - - baseBranch - - constants - runs-on: blacksmith-4vcpu-ubuntu-2204 - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.global-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - e2e-wby-cms-ddb-constants: - needs: - - baseBranch - - constants - - build - name: Constants - DDB - outputs: - cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} - pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: List Cypress tests folders - id: list-cypress-folders - run: >- - echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> - $GITHUB_OUTPUT - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Get Pulumi backend URL - id: get-pulumi-backend-url - run: >- - echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - github.run_id }}_ddb" >> $GITHUB_OUTPUT - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - e2e-wby-cms-ddb-project-setup: - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-constants - name: E2E (DDB) - Project setup - outputs: - cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-constants.outputs.pulumi-backend-url }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs - aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Start Verdaccio local server - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c - .verdaccio.yaml - - name: Configure NPM to use local registry - run: npm config set registry http://localhost:4873 - - name: Set git email - run: git config --global user.email "webiny-bot@webiny.com" - - name: Set git username - run: git config --global user.name "webiny-bot" - - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn release --type=verdaccio - - name: Create verdaccio-files artifact - uses: actions/upload-artifact@v4 - with: - name: verdaccio-files-ddb - retention-days: 1 - path: |- - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - - name: Disable Webiny telemetry - run: > - mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > - ~/.webiny/config - - name: Create a new Webiny project - run: > - npx create-webiny-project@local-npm new-webiny-project --tag local-npm - --no-interactive --assign-to-yarnrc - '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' - --template-options '{"region":"${{ env.AWS_REGION - }}","storageOperations":"ddb"}' - - name: Print CLI version - working-directory: new-webiny-project - run: yarn webiny --version - - name: Create project-files artifact - uses: actions/upload-artifact@v4 - with: - name: project-files-ddb - retention-days: 1 - path: |- - new-webiny-project/ - !new-webiny-project/node_modules/**/* - !new-webiny-project/**/node_modules/**/* - !new-webiny-project/.yarn/cache/**/* - - name: Deploy Core - working-directory: new-webiny-project - run: yarn webiny deploy apps/core --env dev - - name: Deploy API - working-directory: new-webiny-project - run: yarn webiny deploy apps/api --env dev - - name: Deploy Admin Area - working-directory: new-webiny-project - run: yarn webiny deploy apps/admin --env dev - - name: Deploy Website - working-directory: new-webiny-project - run: yarn webiny deploy apps/website --env dev - - name: Create Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn setup-cypress --projectFolder ../new-webiny-project - - name: Save Cypress config - id: save-cypress-config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d - '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn cy:run --browser chrome --spec - "cypress/e2e/adminInstallation/**/*.cy.js" - runs-on: ubuntu-latest - permissions: - id-token: write - e2e-wby-cms-ddb-cypress-tests: - name: >- - ${{ matrix.cypress-folder }} (ddb, ${{ matrix.os }}, Node v${{ matrix.node - }}) - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-constants - - e2e-wby-cms-ddb-project-setup - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - node: - - 18 - cypress-folder: >- - ${{ fromJson(needs.e2e-wby-cms-ddb-constants.outputs.cypress-folders) - }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-constants.outputs.pulumi-backend-url }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Set up Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo '${{ needs.e2e-wby-cms-ddb-project-setup.outputs.cypress-config - }}' > cypress-tests/cypress.config.ts - - name: Cypress - run "${{ matrix.cypress-folder }}" tests - timeout-minutes: 40 - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - runs-on: ubuntu-latest - e2e-wby-cms-ddb-es-constants: - needs: - - baseBranch - - constants - - build - name: Constants - DDB-ES - outputs: - cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} - pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: List Cypress tests folders - id: list-cypress-folders - run: >- - echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> - $GITHUB_OUTPUT - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Get Pulumi backend URL - id: get-pulumi-backend-url - run: >- - echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - github.run_id }}_ddb-es" >> $GITHUB_OUTPUT - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - e2e-wby-cms-ddb-es-project-setup: - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-es-constants - name: E2E (DDB-ES) - Project setup - outputs: - cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.pulumi-backend-url }} - AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} - ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs - aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Start Verdaccio local server - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c - .verdaccio.yaml - - name: Configure NPM to use local registry - run: npm config set registry http://localhost:4873 - - name: Set git email - run: git config --global user.email "webiny-bot@webiny.com" - - name: Set git username - run: git config --global user.name "webiny-bot" - - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn release --type=verdaccio - - name: Create verdaccio-files artifact - uses: actions/upload-artifact@v4 - with: - name: verdaccio-files-ddb-es - retention-days: 1 - path: |- - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - - name: Disable Webiny telemetry - run: > - mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > - ~/.webiny/config - - name: Create a new Webiny project - run: > - npx create-webiny-project@local-npm new-webiny-project --tag local-npm - --no-interactive --assign-to-yarnrc - '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' - --template-options '{"region":"${{ env.AWS_REGION - }}","storageOperations":"ddb-es"}' - - name: Print CLI version - working-directory: new-webiny-project - run: yarn webiny --version - - name: Create project-files artifact - uses: actions/upload-artifact@v4 - with: - name: project-files-ddb-es - retention-days: 1 - path: |- - new-webiny-project/ - !new-webiny-project/node_modules/**/* - !new-webiny-project/**/node_modules/**/* - !new-webiny-project/.yarn/cache/**/* - - name: Deploy Core - working-directory: new-webiny-project - run: yarn webiny deploy apps/core --env dev - - name: Deploy API - working-directory: new-webiny-project - run: yarn webiny deploy apps/api --env dev - - name: Deploy Admin Area - working-directory: new-webiny-project - run: yarn webiny deploy apps/admin --env dev - - name: Deploy Website - working-directory: new-webiny-project - run: yarn webiny deploy apps/website --env dev - - name: Create Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn setup-cypress --projectFolder ../new-webiny-project - - name: Save Cypress config - id: save-cypress-config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d - '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn cy:run --browser chrome --spec - "cypress/e2e/adminInstallation/**/*.cy.js" - runs-on: ubuntu-latest - permissions: - id-token: write - e2e-wby-cms-ddb-es-cypress-tests: - name: >- - ${{ matrix.cypress-folder }} (ddb-es, ${{ matrix.os }}, Node v${{ - matrix.node }}) - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-es-constants - - e2e-wby-cms-ddb-es-project-setup - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - node: - - 18 - cypress-folder: >- - ${{ - fromJson(needs.e2e-wby-cms-ddb-es-constants.outputs.cypress-folders) - }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-es-constants.outputs.pulumi-backend-url }} - AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} - ELASTIC_SEARCH_ENDPOINT: ${{ secrets.ELASTIC_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Set up Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo '${{ - needs.e2e-wby-cms-ddb-es-project-setup.outputs.cypress-config }}' > - cypress-tests/cypress.config.ts - - name: Cypress - run "${{ matrix.cypress-folder }}" tests - timeout-minutes: 40 - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - runs-on: ubuntu-latest - e2e-wby-cms-ddb-os-constants: - needs: - - baseBranch - - constants - - build - name: Constants - DDB-OS - outputs: - cypress-folders: ${{ steps.list-cypress-folders.outputs.cypress-folders }} - pulumi-backend-url: ${{ steps.pulumi-backend-url.outputs.pulumi-backend-url }} - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: List Cypress tests folders - id: list-cypress-folders - run: >- - echo "cypress-folders=$(node scripts/listCypressTestsFolders.js)" >> - $GITHUB_OUTPUT - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Get Pulumi backend URL - id: get-pulumi-backend-url - run: >- - echo "pulumi-backend-url=${{ secrets.WEBINY_PULUMI_BACKEND }}${{ - github.run_id }}_ddb-os" >> $GITHUB_OUTPUT - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - e2e-wby-cms-ddb-os-project-setup: - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-os-constants - name: E2E (DDB-OS) - Project setup - outputs: - cypress-config: ${{ steps.save-cypress-config.outputs.cypress-config }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.pulumi-backend-url }} - AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} - ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs - aws-region: eu-central-1 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Start Verdaccio local server - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn add pm2 verdaccio && npx pm2 start verdaccio -- -c - .verdaccio.yaml - - name: Configure NPM to use local registry - run: npm config set registry http://localhost:4873 - - name: Set git email - run: git config --global user.email "webiny-bot@webiny.com" - - name: Set git username - run: git config --global user.name "webiny-bot" - - name: Create ".npmrc" file in the project root, with a dummy auth token - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc - - name: Version and publish to Verdaccio - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn release --type=verdaccio - - name: Create verdaccio-files artifact - uses: actions/upload-artifact@v4 - with: - name: verdaccio-files-ddb-os - retention-days: 1 - path: |- - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio/ - ${{ needs.baseBranch.outputs.base-branch }}/.verdaccio.yaml - - name: Disable Webiny telemetry - run: > - mkdir ~/.webiny && echo '{ "id": "ci", "telemetry": false }' > - ~/.webiny/config - - name: Create a new Webiny project - run: > - npx create-webiny-project@local-npm new-webiny-project --tag local-npm - --no-interactive --assign-to-yarnrc - '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}' - --template-options '{"region":"${{ env.AWS_REGION - }}","storageOperations":"ddb-os"}' - - name: Print CLI version - working-directory: new-webiny-project - run: yarn webiny --version - - name: Create project-files artifact - uses: actions/upload-artifact@v4 - with: - name: project-files-ddb-os - retention-days: 1 - path: |- - new-webiny-project/ - !new-webiny-project/node_modules/**/* - !new-webiny-project/**/node_modules/**/* - !new-webiny-project/.yarn/cache/**/* - - name: Deploy Core - working-directory: new-webiny-project - run: yarn webiny deploy apps/core --env dev - - name: Deploy API - working-directory: new-webiny-project - run: yarn webiny deploy apps/api --env dev - - name: Deploy Admin Area - working-directory: new-webiny-project - run: yarn webiny deploy apps/admin --env dev - - name: Deploy Website - working-directory: new-webiny-project - run: yarn webiny deploy apps/website --env dev - - name: Create Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn setup-cypress --projectFolder ../new-webiny-project - - name: Save Cypress config - id: save-cypress-config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo "cypress-config=$(cat cypress-tests/cypress.config.ts | tr -d - '\t\n\r')" >> $GITHUB_OUTPUT - - name: Cypress - run installation wizard test - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - yarn cy:run --browser chrome --spec - "cypress/e2e/adminInstallation/**/*.cy.js" - runs-on: ubuntu-latest - permissions: - id-token: write - e2e-wby-cms-ddb-os-cypress-tests: - name: >- - ${{ matrix.cypress-folder }} (ddb-os, ${{ matrix.os }}, Node v${{ - matrix.node }}) - needs: - - baseBranch - - constants - - e2e-wby-cms-ddb-os-constants - - e2e-wby-cms-ddb-os-project-setup - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - node: - - 18 - cypress-folder: >- - ${{ - fromJson(needs.e2e-wby-cms-ddb-os-constants.outputs.cypress-folders) - }} - environment: next - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - CYPRESS_MAILOSAUR_API_KEY: ${{ secrets.CYPRESS_MAILOSAUR_API_KEY }} - PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} - PULUMI_SECRETS_PROVIDER: ${{ secrets.PULUMI_SECRETS_PROVIDER }} - WEBINY_PULUMI_BACKEND: ${{ needs.e2e-wby-cms-ddb-os-constants.outputs.pulumi-backend-url }} - AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} - ELASTIC_SEARCH_ENDPOINT: ${{ secrets.OPEN_SEARCH_ENDPOINT }} - ELASTIC_SEARCH_INDEX_PREFIX: ${{ github.run_id }}_ - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }} - - name: Install Hub Utility - run: sudo apt-get install -y hub - - name: Checkout Pull Request - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: hub pr checkout ${{ github.event.issue.number }} - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: ${{ needs.baseBranch.outputs.base-branch }}/.webiny/cached-packages - key: ${{ needs.constants.outputs.run-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Build packages - run: yarn build:quick - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - - name: Set up Cypress config - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: >- - echo '${{ - needs.e2e-wby-cms-ddb-os-project-setup.outputs.cypress-config }}' > - cypress-tests/cypress.config.ts - - name: Cypress - run "${{ matrix.cypress-folder }}" tests - timeout-minutes: 40 - working-directory: ${{ needs.baseBranch.outputs.base-branch }} - run: yarn cy:run --browser chrome --spec "${{ matrix.cypress-folder }}" - runs-on: ubuntu-latest diff --git a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts index 541db161bb8..542d6b30371 100644 --- a/.github/workflows/wac/pullRequestsCommandCypress.wac.ts +++ b/.github/workflows/wac/pullRequestsCommandCypress.wac.ts @@ -205,8 +205,8 @@ const createCypressJobs = (dbSetup: string) => { }; }; -export const pullRequestsCommandCypressTest = createWorkflow({ - name: "Pull Requests Command - Cypress (Test)", +export const pullRequestsCommandCypress = createWorkflow({ + name: "Pull Requests Command - Cypress", on: "issue_comment", env: { NODE_OPTIONS, From 45f9823ad0416e5e7d709e2318dbf6106f4444a1 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 21:57:13 +0200 Subject: [PATCH 42/50] ci: remove test workflow [no ci] --- .github/workflows/pullRequests.yml | 71 ++++++-- .github/workflows/wac/pullRequests.wac.ts | 211 +++++++++------------- 2 files changed, 138 insertions(+), 144 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index af54d1a569d..6ac9d4146c3 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -50,12 +50,14 @@ jobs: YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: name: Create constants - runs-on: ubuntu-latest outputs: global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} run-cache-key: ${{ steps.run-cache-key.outputs.run-cache-key }} is-fork-pr: ${{ steps.is-fork-pr.outputs.is-fork-pr }} steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 - name: Create global cache key id: global-cache-key run: >- @@ -72,6 +74,10 @@ jobs: run: >- echo "is-fork-pr=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false build: name: Build needs: constants @@ -83,19 +89,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.global-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -112,22 +120,27 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Check code formatting run: yarn prettier:check + working-directory: ${{ github.base_ref }} - name: Check dependencies run: yarn adio + working-directory: ${{ github.base_ref }} - name: Check TS configs run: yarn check-ts-configs + working-directory: ${{ github.base_ref }} - name: ESLint run: yarn eslint + working-directory: ${{ github.base_ref }} runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' @@ -142,14 +155,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages (full) run: yarn build + working-directory: ${{ github.base_ref }} - name: Check types for Cypress tests run: yarn cy:ts + working-directory: ${{ github.base_ref }} env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false @@ -180,18 +196,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: ${{ github.base_ref }} jestTestsDdb: needs: - constants @@ -234,18 +253,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: ${{ github.base_ref }} jestTestsDdbEs: needs: - constants @@ -293,18 +315,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: ${{ github.base_ref }} permissions: id-token: write if: needs.constants.outputs.is-fork-pr != 'true' @@ -355,18 +380,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - name: Run tests run: yarn test ${{ matrix.package.cmd }} + working-directory: ${{ github.base_ref }} permissions: id-token: write if: needs.constants.outputs.is-fork-pr != 'true' @@ -386,28 +414,36 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} - uses: actions/cache@v4 with: - path: .yarn/cache + path: ${{ github.base_ref }}/.yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - uses: actions/cache@v4 with: - path: .webiny/cached-packages + path: ${{ github.base_ref }}/.webiny/cached-packages key: ${{ needs.constants.outputs.run-cache-key }} - name: Install dependencies run: yarn --immutable + working-directory: ${{ github.base_ref }} - name: Build packages run: yarn build:quick + working-directory: ${{ github.base_ref }} - name: Start Verdaccio local server run: npx pm2 start verdaccio -- -c .verdaccio.yaml + working-directory: ${{ github.base_ref }} - name: Configure NPM to use local registry run: npm config set registry http://localhost:4873 + working-directory: ${{ github.base_ref }} - name: Set git email run: git config --global user.email "webiny-bot@webiny.com" + working-directory: ${{ github.base_ref }} - name: Set git username run: git config --global user.name "webiny-bot" + working-directory: ${{ github.base_ref }} - name: Create ".npmrc" file in the project root, with a dummy auth token run: echo '//localhost:4873/:_authToken="dummy-auth-token"' > .npmrc + working-directory: ${{ github.base_ref }} - name: Version and publish to Verdaccio run: yarn release --type=verdaccio + working-directory: ${{ github.base_ref }} - name: Upload verdaccio files uses: actions/upload-artifact@v4 with: @@ -416,6 +452,7 @@ jobs: path: | .verdaccio/ .verdaccio.yaml + working-directory: ${{ github.base_ref }} runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index 6b988bf034c..a7c0f3e408e 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -1,36 +1,21 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; import { createValidateWorkflowsJob, createJob } from "./jobs"; import { NODE_VERSION, listPackagesWithJestTests } from "./utils"; +import { + createGlobalBuildCacheSteps, + createInstallBuildSteps, + createRunBuildCacheSteps, + createYarnCacheSteps, + withCommonParams +} from "./steps"; -const yarnCacheSteps: NormalJob["steps"] = [ - { - uses: "actions/cache@v4", - with: { - path: ".yarn/cache", - key: "yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}" - } - } -]; - -const buildGlobalCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "${{ needs.constants.outputs.global-cache-key }}" - } - } -]; +// Will print "next" or "dev". Important for caching (via actions/cache). +const DIR_WEBINY_JS = "${{ github.base_ref }}"; -const buildRunCacheSteps = [ - { - uses: "actions/cache@v4", - with: { - path: ".webiny/cached-packages", - key: "${{ needs.constants.outputs.run-cache-key }}" - } - } -]; +const installBuildSteps = createInstallBuildSteps({ workingDirectory: DIR_WEBINY_JS }); +const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: DIR_WEBINY_JS }); +const globalBuildCacheSteps = createGlobalBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); +const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: DIR_WEBINY_JS }); const createJestTestsJob = (storage: string | null) => { const env: Record = {}; @@ -69,18 +54,12 @@ const createJestTestsJob = (storage: string | null) => { awsAuth: storage === "ddb-es" || storage === "ddb-os", steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, + ...runBuildCacheSteps, + ...installBuildSteps, { name: "Run tests", - run: "yarn test ${{ matrix.package.cmd }}" + run: "yarn test ${{ matrix.package.cmd }}", + "working-directory": DIR_WEBINY_JS } ] }); @@ -119,14 +98,14 @@ export const pullRequests = createWorkflow({ } ] }), - constants: { + constants: createJob({ name: "Create constants", - "runs-on": "ubuntu-latest", outputs: { "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}", "run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}", "is-fork-pr": "${{ steps.is-fork-pr.outputs.is-fork-pr }}" }, + checkout: false, steps: [ { name: "Create global cache key", @@ -144,25 +123,19 @@ export const pullRequests = createWorkflow({ run: 'echo "is-fork-pr=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_OUTPUT' } ] - }, + }), build: createJob({ name: "Build", needs: "constants", "runs-on": "blacksmith-8vcpu-ubuntu-2204", steps: [ ...yarnCacheSteps, - ...buildGlobalCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, + ...globalBuildCacheSteps, + ...installBuildSteps, + // Once we've built packages with the help of the global cache, we can now cache // the result for this run. All of the following jobs will use this cache. - ...buildRunCacheSteps + ...runBuildCacheSteps ] }), staticCodeAnalysis: createJob({ @@ -170,27 +143,17 @@ export const pullRequests = createWorkflow({ name: "Static code analysis", steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Check code formatting", - run: "yarn prettier:check" - }, - { - name: "Check dependencies", - run: "yarn adio" - }, - { - name: "Check TS configs", - run: "yarn check-ts-configs" - }, - { - name: "ESLint", - run: "yarn eslint" - } + ...runBuildCacheSteps, + ...withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Check code formatting", run: "yarn prettier:check" }, + { name: "Check dependencies", run: "yarn adio" }, + { name: "Check TS configs", run: "yarn check-ts-configs" }, + { name: "ESLint", run: "yarn eslint" } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }), staticCodeAnalysisTs: createJob({ @@ -201,20 +164,16 @@ export const pullRequests = createWorkflow({ // We're not using run cache here. We want to build all packages // with TypeScript, to ensure there are no TypeScript errors. - // ...buildRunCacheSteps, + // ...runBuildCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages (full)", - run: "yarn build" - }, - { - name: "Check types for Cypress tests", - run: "yarn cy:ts" - } + ...withCommonParams( + [ + { name: "Install dependencies", run: "yarn --immutable" }, + { name: "Build packages (full)", run: "yarn build" }, + { name: "Check types for Cypress tests", run: "yarn cy:ts" } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }), jestTestsNoStorage: createJestTestsJob(null), @@ -232,48 +191,46 @@ export const pullRequests = createWorkflow({ }, steps: [ ...yarnCacheSteps, - ...buildRunCacheSteps, - { - name: "Install dependencies", - run: "yarn --immutable" - }, - { - name: "Build packages", - run: "yarn build:quick" - }, - { - name: "Start Verdaccio local server", - run: "npx pm2 start verdaccio -- -c .verdaccio.yaml" - }, - { - name: "Configure NPM to use local registry", - run: "npm config set registry http://localhost:4873" - }, - { - name: "Set git email", - run: 'git config --global user.email "webiny-bot@webiny.com"' - }, - { - name: "Set git username", - run: 'git config --global user.name "webiny-bot"' - }, - { - name: 'Create ".npmrc" file in the project root, with a dummy auth token', - run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" - }, - { - name: "Version and publish to Verdaccio", - run: "yarn release --type=verdaccio" - }, - { - name: "Upload verdaccio files", - uses: "actions/upload-artifact@v4", - with: { - name: "verdaccio-files", - "retention-days": 1, - path: ".verdaccio/\n.verdaccio.yaml\n" - } - } + ...runBuildCacheSteps, + ...installBuildSteps, + ...withCommonParams( + [ + { + name: "Start Verdaccio local server", + run: "npx pm2 start verdaccio -- -c .verdaccio.yaml" + }, + { + name: "Configure NPM to use local registry", + run: "npm config set registry http://localhost:4873" + }, + { + name: "Set git email", + run: 'git config --global user.email "webiny-bot@webiny.com"' + }, + { + name: "Set git username", + run: 'git config --global user.name "webiny-bot"' + }, + { + name: 'Create ".npmrc" file in the project root, with a dummy auth token', + run: "echo '//localhost:4873/:_authToken=\"dummy-auth-token\"' > .npmrc" + }, + { + name: "Version and publish to Verdaccio", + run: "yarn release --type=verdaccio" + }, + { + name: "Upload verdaccio files", + uses: "actions/upload-artifact@v4", + with: { + name: "verdaccio-files", + "retention-days": 1, + path: ".verdaccio/\n.verdaccio.yaml\n" + } + } + ], + { "working-directory": DIR_WEBINY_JS } + ) ] }), testCreateWebinyProject: createJob({ From 9107546b80ba95b1b97b2ef53bb89ced3a693ca2 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 22:02:10 +0200 Subject: [PATCH 43/50] ci: refactor workflow [no ci] --- .github/workflows/pullRequests.yml | 7 +++---- .github/workflows/wac/pullRequests.wac.ts | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 6ac9d4146c3..bc913b818d8 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -449,10 +449,9 @@ jobs: with: name: verdaccio-files retention-days: 1 - path: | - .verdaccio/ - .verdaccio.yaml - working-directory: ${{ github.base_ref }} + path: |- + ${{ github.base_ref }}/.verdaccio/ + ${{ github.base_ref }}/.verdaccio.yaml runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index a7c0f3e408e..188e0acf2b5 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -218,19 +218,22 @@ export const pullRequests = createWorkflow({ { name: "Version and publish to Verdaccio", run: "yarn release --type=verdaccio" - }, - { - name: "Upload verdaccio files", - uses: "actions/upload-artifact@v4", - with: { - name: "verdaccio-files", - "retention-days": 1, - path: ".verdaccio/\n.verdaccio.yaml\n" - } } ], { "working-directory": DIR_WEBINY_JS } - ) + ), + { + name: "Upload verdaccio files", + uses: "actions/upload-artifact@v4", + with: { + name: "verdaccio-files", + "retention-days": 1, + path: [ + DIR_WEBINY_JS + "/.verdaccio/", + DIR_WEBINY_JS + "/.verdaccio.yaml" + ].join("\n") + } + } ] }), testCreateWebinyProject: createJob({ From da14523253dd45b77a8561ead2ce36b402638054 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 22:43:41 +0200 Subject: [PATCH 44/50] ci: refactor workflow [no ci] --- .github/workflows/pullRequests.yml | 15 +++++++++++++++ .github/workflows/wac/pullRequests.wac.ts | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index bc913b818d8..8fdfc54fec9 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -87,6 +87,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -118,6 +120,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -153,6 +157,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -194,6 +200,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -251,6 +259,8 @@ jobs: with: node-version: 18 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -313,6 +323,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -378,6 +390,8 @@ jobs: role-to-assume: arn:aws:iam::726952677045:role/GitHubActionsWebinyJs aws-region: eu-central-1 - uses: actions/checkout@v4 + with: + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache @@ -412,6 +426,7 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} + path: ${{ github.base_ref }} - uses: actions/cache@v4 with: path: ${{ github.base_ref }}/.yarn/cache diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index 188e0acf2b5..21dad4a78fb 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -52,6 +52,7 @@ const createJestTestsJob = (storage: string | null) => { "runs-on": "${{ matrix.os }}", env, awsAuth: storage === "ddb-es" || storage === "ddb-os", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...runBuildCacheSteps, @@ -128,6 +129,7 @@ export const pullRequests = createWorkflow({ name: "Build", needs: "constants", "runs-on": "blacksmith-8vcpu-ubuntu-2204", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...globalBuildCacheSteps, @@ -141,6 +143,7 @@ export const pullRequests = createWorkflow({ staticCodeAnalysis: createJob({ needs: ["constants", "build"], name: "Static code analysis", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, ...runBuildCacheSteps, @@ -159,6 +162,7 @@ export const pullRequests = createWorkflow({ staticCodeAnalysisTs: createJob({ name: "Static code analysis (TypeScript)", "runs-on": "blacksmith-8vcpu-ubuntu-2204", + checkout: { path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, @@ -187,7 +191,8 @@ export const pullRequests = createWorkflow({ if: "needs.constants.outputs.is-fork-pr != 'true'", checkout: { "fetch-depth": 0, - ref: "${{ github.event.pull_request.head.ref }}" + ref: "${{ github.event.pull_request.head.ref }}", + path: DIR_WEBINY_JS }, steps: [ ...yarnCacheSteps, From be2f04b9f39d47b12dda42703fe9b7693696d408 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 23:02:46 +0200 Subject: [PATCH 45/50] ci: refactor workflow [no ci] --- .github/workflows/rebuildCache.yml | 83 ------------------- .github/workflows/rebuildCaches.yml | 95 ++++++++++++++++++++++ .github/workflows/wac/rebuildCaches.wac.ts | 48 +++++++++++ 3 files changed, 143 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/rebuildCache.yml create mode 100644 .github/workflows/rebuildCaches.yml create mode 100644 .github/workflows/wac/rebuildCaches.wac.ts diff --git a/.github/workflows/rebuildCache.yml b/.github/workflows/rebuildCache.yml deleted file mode 100644 index 3c92b005fed..00000000000 --- a/.github/workflows/rebuildCache.yml +++ /dev/null @@ -1,83 +0,0 @@ -# This ensures build/yarn caches are rebuilt and that we don't experience cache miss -# when pushing our own code (which makes the whole job last significantly longer). -name: Rebuild Cache (Next) - -on: - schedule: - - cron: "0 1 * * *" # Every day at 1AM. - -env: - NODE_OPTIONS: --max_old_space_size=4096 - -jobs: - cache-keys: - name: Create cache keys - runs-on: ubuntu-latest - outputs: - day: ${{ steps.create-cache-keys.outputs.day }} - steps: - - name: Create cache key (day) - id: create-cache-keys - run: echo "day=$(node --eval "console.log(new Date().getDate())")" >> $GITHUB_OUTPUT - - cache-dependencies-packages-root: - name: Cache dependencies and packages - runs-on: ubuntu-latest - needs: cache-keys - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: actions/checkout@v4 - - - uses: actions/cache@v4 - id: yarn-cache - with: - path: .yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - - uses: actions/cache@v4 - id: cached-packages - with: - path: .webiny/cached-packages - key: ${{ runner.os }}-${{ needs.cache-keys.outputs.day }}-${{ secrets.RANDOM_CACHE_KEY_SUFFIX }} - - - name: Install dependencies - run: yarn --immutable - - - name: Build packages - run: yarn build - - cache-dependencies-packages-next: - name: Cache dependencies and packages ("next" folder) - runs-on: ubuntu-latest - needs: cache-keys - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: actions/checkout@v4 - with: - path: next - - - uses: actions/cache@v4 - id: yarn-cache - with: - path: next/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('next/**/yarn.lock') }} - - - uses: actions/cache@v4 - id: cached-packages - with: - path: next/.webiny/cached-packages - key: ${{ runner.os }}-${{ needs.cache-keys.outputs.day }}-${{ secrets.RANDOM_CACHE_KEY_SUFFIX }} - - - name: Install dependencies - working-directory: next - run: yarn --immutable - - - name: Build packages - working-directory: next - run: yarn build diff --git a/.github/workflows/rebuildCaches.yml b/.github/workflows/rebuildCaches.yml new file mode 100644 index 00000000000..ef989d58a7d --- /dev/null +++ b/.github/workflows/rebuildCaches.yml @@ -0,0 +1,95 @@ +# This file was automatically generated by github-actions-wac. +# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) +# and run "github-actions-wac build" (or "ghawac build") to regenerate this file. +# For more information, run "github-actions-wac --help". +name: Rebuild Caches +'on': + workflow_dispatch: {} + schedule: + - cron: 0 4 * * * +jobs: + constants: + name: Create constants + outputs: + global-cache-key-suffix: ${{ steps.global-cache-key.outputs.global-cache-key-suffix }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Create global cache key suffix + id: global-cache-key + run: >- + echo "global-cache-key-suffix=-${{ runner.os }}-$(/bin/date -u + "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + cache-dependencies-packages-dev: + name: Cache dependencies and packages ("dev" branch) + needs: constants + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: dev + - uses: actions/cache@v4 + with: + path: dev/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: dev/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: dev + - name: Build packages + run: yarn build:quick + working-directory: dev + - name: Install dependencies + run: yarn --immutable + working-directory: dev + - name: Build packages + run: yarn build:quick + working-directory: dev + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + cache-dependencies-packages-next: + name: Cache dependencies and packages ("next" branch) + needs: constants + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: next + - uses: actions/cache@v4 + with: + path: next/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: next/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: next + - name: Build packages + run: yarn build:quick + working-directory: next + - name: Install dependencies + run: yarn --immutable + working-directory: next + - name: Build packages + run: yarn build:quick + working-directory: next + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/.github/workflows/wac/rebuildCaches.wac.ts b/.github/workflows/wac/rebuildCaches.wac.ts new file mode 100644 index 00000000000..30c4812952a --- /dev/null +++ b/.github/workflows/wac/rebuildCaches.wac.ts @@ -0,0 +1,48 @@ +import { createWorkflow } from "github-actions-wac"; +import { createJob } from "./jobs"; +import { + createGlobalBuildCacheSteps, + createInstallBuildSteps, + createYarnCacheSteps +} from "./steps"; + +const createCacheJob = (branchName: string) => { + return createJob({ + name: `Cache dependencies and packages ("${branchName}" branch)`, + needs: "constants", + checkout: { path: branchName }, + steps: [ + ...createYarnCacheSteps({ workingDirectory: branchName }), + ...createGlobalBuildCacheSteps({ workingDirectory: branchName }), + ...createInstallBuildSteps({ workingDirectory: branchName }), + ...createInstallBuildSteps({ workingDirectory: branchName }) + ] + }) +} + +export const rebuildCaches = createWorkflow({ + name: "Rebuild Caches", + on: { + workflow_dispatch: {}, + schedule: [{ cron: "0 4 * * *" }] + }, + jobs: { + constants: createJob({ + name: "Create constants", + outputs: { + "global-cache-key-suffix": + "${{ steps.global-cache-key.outputs.global-cache-key-suffix }}" + }, + checkout: false, + steps: [ + { + name: "Create global cache key suffix", + id: "global-cache-key", + run: 'echo "global-cache-key-suffix=-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' + } + ] + }), + "cache-dependencies-packages-dev": createCacheJob("dev"), + "cache-dependencies-packages-next": createCacheJob("next"), + } +}); From 8857ea76042a35620caaab62393e7987d3fd0509 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 23:07:56 +0200 Subject: [PATCH 46/50] ci: refactor workflow [no ci] --- .github/workflows/rebuildCachesDev.yml | 55 +++++++++++++++++++ ...ebuildCaches.yml => rebuildCachesNext.yml} | 48 ++-------------- .github/workflows/wac/rebuildCaches.wac.ts | 38 ++++++------- 3 files changed, 76 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/rebuildCachesDev.yml rename .github/workflows/{rebuildCaches.yml => rebuildCachesNext.yml} (51%) diff --git a/.github/workflows/rebuildCachesDev.yml b/.github/workflows/rebuildCachesDev.yml new file mode 100644 index 00000000000..2867d6031a0 --- /dev/null +++ b/.github/workflows/rebuildCachesDev.yml @@ -0,0 +1,55 @@ +# This file was automatically generated by github-actions-wac. +# DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) +# and run "github-actions-wac build" (or "ghawac build") to regenerate this file. +# For more information, run "github-actions-wac --help". +name: Rebuild Caches +'on': + workflow_dispatch: {} + schedule: + - cron: 0 4 * * * +jobs: + constants: + name: Create constants + outputs: + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Create global cache key + id: global-cache-key + run: >- + echo "global-cache-key=dev-${{ runner.os }}-$(/bin/date -u + "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false + cacheDependenciesPackages: + name: Cache dependencies and packages ("dev" branch) + needs: constants + steps: + - uses: actions/setup-node@v4 + with: + node-version: 18 + - uses: actions/checkout@v4 + with: + path: dev + - uses: actions/cache@v4 + with: + path: dev/.yarn/cache + key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + - uses: actions/cache@v4 + with: + path: dev/.webiny/cached-packages + key: ${{ needs.constants.outputs.global-cache-key }} + - name: Install dependencies + run: yarn --immutable + working-directory: dev + - name: Build packages + run: yarn build:quick + working-directory: dev + runs-on: ubuntu-latest + env: + NODE_OPTIONS: '--max_old_space_size=4096' + YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/.github/workflows/rebuildCaches.yml b/.github/workflows/rebuildCachesNext.yml similarity index 51% rename from .github/workflows/rebuildCaches.yml rename to .github/workflows/rebuildCachesNext.yml index ef989d58a7d..eac07589701 100644 --- a/.github/workflows/rebuildCaches.yml +++ b/.github/workflows/rebuildCachesNext.yml @@ -11,55 +11,21 @@ jobs: constants: name: Create constants outputs: - global-cache-key-suffix: ${{ steps.global-cache-key.outputs.global-cache-key-suffix }} + global-cache-key: ${{ steps.global-cache-key.outputs.global-cache-key }} steps: - uses: actions/setup-node@v4 with: node-version: 18 - - name: Create global cache key suffix + - name: Create global cache key id: global-cache-key run: >- - echo "global-cache-key-suffix=-${{ runner.os }}-$(/bin/date -u + echo "global-cache-key=next-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false - cache-dependencies-packages-dev: - name: Cache dependencies and packages ("dev" branch) - needs: constants - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - with: - path: dev - - uses: actions/cache@v4 - with: - path: dev/.yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - uses: actions/cache@v4 - with: - path: dev/.webiny/cached-packages - key: ${{ needs.constants.outputs.global-cache-key }} - - name: Install dependencies - run: yarn --immutable - working-directory: dev - - name: Build packages - run: yarn build:quick - working-directory: dev - - name: Install dependencies - run: yarn --immutable - working-directory: dev - - name: Build packages - run: yarn build:quick - working-directory: dev - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false - cache-dependencies-packages-next: + cacheDependenciesPackages: name: Cache dependencies and packages ("next" branch) needs: constants steps: @@ -83,12 +49,6 @@ jobs: - name: Build packages run: yarn build:quick working-directory: next - - name: Install dependencies - run: yarn --immutable - working-directory: next - - name: Build packages - run: yarn build:quick - working-directory: next runs-on: ubuntu-latest env: NODE_OPTIONS: '--max_old_space_size=4096' diff --git a/.github/workflows/wac/rebuildCaches.wac.ts b/.github/workflows/wac/rebuildCaches.wac.ts index 30c4812952a..d7bb550d477 100644 --- a/.github/workflows/wac/rebuildCaches.wac.ts +++ b/.github/workflows/wac/rebuildCaches.wac.ts @@ -6,21 +6,7 @@ import { createYarnCacheSteps } from "./steps"; -const createCacheJob = (branchName: string) => { - return createJob({ - name: `Cache dependencies and packages ("${branchName}" branch)`, - needs: "constants", - checkout: { path: branchName }, - steps: [ - ...createYarnCacheSteps({ workingDirectory: branchName }), - ...createGlobalBuildCacheSteps({ workingDirectory: branchName }), - ...createInstallBuildSteps({ workingDirectory: branchName }), - ...createInstallBuildSteps({ workingDirectory: branchName }) - ] - }) -} - -export const rebuildCaches = createWorkflow({ +const createRebuildCachesWorkflow = (branchName: string) => ({ name: "Rebuild Caches", on: { workflow_dispatch: {}, @@ -30,19 +16,29 @@ export const rebuildCaches = createWorkflow({ constants: createJob({ name: "Create constants", outputs: { - "global-cache-key-suffix": - "${{ steps.global-cache-key.outputs.global-cache-key-suffix }}" + "global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}" }, checkout: false, steps: [ { - name: "Create global cache key suffix", + name: "Create global cache key", id: "global-cache-key", - run: 'echo "global-cache-key-suffix=-${{ runner.os }}-$(/bin/date -u "+%m%d")-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT' + run: `echo "global-cache-key=${branchName}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT` } ] }), - "cache-dependencies-packages-dev": createCacheJob("dev"), - "cache-dependencies-packages-next": createCacheJob("next"), + cacheDependenciesPackages: createJob({ + name: `Cache dependencies and packages ("${branchName}" branch)`, + needs: "constants", + checkout: { path: branchName }, + steps: [ + ...createYarnCacheSteps({ workingDirectory: branchName }), + ...createGlobalBuildCacheSteps({ workingDirectory: branchName }), + ...createInstallBuildSteps({ workingDirectory: branchName }), + ] + }) } }); + +export const rebuildCachesDev = createRebuildCachesWorkflow("dev"); +export const rebuildCachesNext = createRebuildCachesWorkflow("next"); From cba2d30b60e399a31d49b07ac9746d872f3b2a72 Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 23:08:57 +0200 Subject: [PATCH 47/50] ci: refactor workflow [no ci] --- .../{rebuildCachesDev.yml => rebuildGlobalCacheDev.yml} | 0 ...{rebuildCachesNext.yml => rebuildGlobalCacheNext.yml} | 0 .../{rebuildCaches.wac.ts => rebuildGlobalCache.wac.ts} | 9 ++++----- 3 files changed, 4 insertions(+), 5 deletions(-) rename .github/workflows/{rebuildCachesDev.yml => rebuildGlobalCacheDev.yml} (100%) rename .github/workflows/{rebuildCachesNext.yml => rebuildGlobalCacheNext.yml} (100%) rename .github/workflows/wac/{rebuildCaches.wac.ts => rebuildGlobalCache.wac.ts} (83%) diff --git a/.github/workflows/rebuildCachesDev.yml b/.github/workflows/rebuildGlobalCacheDev.yml similarity index 100% rename from .github/workflows/rebuildCachesDev.yml rename to .github/workflows/rebuildGlobalCacheDev.yml diff --git a/.github/workflows/rebuildCachesNext.yml b/.github/workflows/rebuildGlobalCacheNext.yml similarity index 100% rename from .github/workflows/rebuildCachesNext.yml rename to .github/workflows/rebuildGlobalCacheNext.yml diff --git a/.github/workflows/wac/rebuildCaches.wac.ts b/.github/workflows/wac/rebuildGlobalCache.wac.ts similarity index 83% rename from .github/workflows/wac/rebuildCaches.wac.ts rename to .github/workflows/wac/rebuildGlobalCache.wac.ts index d7bb550d477..e7b071ca7e0 100644 --- a/.github/workflows/wac/rebuildCaches.wac.ts +++ b/.github/workflows/wac/rebuildGlobalCache.wac.ts @@ -1,4 +1,3 @@ -import { createWorkflow } from "github-actions-wac"; import { createJob } from "./jobs"; import { createGlobalBuildCacheSteps, @@ -6,7 +5,7 @@ import { createYarnCacheSteps } from "./steps"; -const createRebuildCachesWorkflow = (branchName: string) => ({ +const createRebuildGlobalCacheWorkflow = (branchName: string) => ({ name: "Rebuild Caches", on: { workflow_dispatch: {}, @@ -34,11 +33,11 @@ const createRebuildCachesWorkflow = (branchName: string) => ({ steps: [ ...createYarnCacheSteps({ workingDirectory: branchName }), ...createGlobalBuildCacheSteps({ workingDirectory: branchName }), - ...createInstallBuildSteps({ workingDirectory: branchName }), + ...createInstallBuildSteps({ workingDirectory: branchName }) ] }) } }); -export const rebuildCachesDev = createRebuildCachesWorkflow("dev"); -export const rebuildCachesNext = createRebuildCachesWorkflow("next"); +export const rebuildGlobalCacheDev = createRebuildGlobalCacheWorkflow("dev"); +export const rebuildGlobalCacheNext = createRebuildGlobalCacheWorkflow("next"); From 0b4703b5494bd55cfb8b01943131710da2991f4c Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 23:09:53 +0200 Subject: [PATCH 48/50] ci: refactor workflow [no ci] --- .github/workflows/rebuildGlobalCacheDev.yml | 4 ++-- .github/workflows/rebuildGlobalCacheNext.yml | 4 ++-- .github/workflows/wac/rebuildGlobalCache.wac.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rebuildGlobalCacheDev.yml b/.github/workflows/rebuildGlobalCacheDev.yml index 2867d6031a0..96e20f0f623 100644 --- a/.github/workflows/rebuildGlobalCacheDev.yml +++ b/.github/workflows/rebuildGlobalCacheDev.yml @@ -2,7 +2,7 @@ # DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) # and run "github-actions-wac build" (or "ghawac build") to regenerate this file. # For more information, run "github-actions-wac --help". -name: Rebuild Caches +name: Rebuild Global Cache ("dev" branch) 'on': workflow_dispatch: {} schedule: @@ -26,7 +26,7 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false cacheDependenciesPackages: - name: Cache dependencies and packages ("dev" branch) + name: Cache dependencies and packages needs: constants steps: - uses: actions/setup-node@v4 diff --git a/.github/workflows/rebuildGlobalCacheNext.yml b/.github/workflows/rebuildGlobalCacheNext.yml index eac07589701..fdd4d538d54 100644 --- a/.github/workflows/rebuildGlobalCacheNext.yml +++ b/.github/workflows/rebuildGlobalCacheNext.yml @@ -2,7 +2,7 @@ # DO NOT MODIFY IT BY HAND. Instead, modify the source *.wac.ts file(s) # and run "github-actions-wac build" (or "ghawac build") to regenerate this file. # For more information, run "github-actions-wac --help". -name: Rebuild Caches +name: Rebuild Global Cache ("next" branch) 'on': workflow_dispatch: {} schedule: @@ -26,7 +26,7 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' YARN_ENABLE_IMMUTABLE_INSTALLS: false cacheDependenciesPackages: - name: Cache dependencies and packages ("next" branch) + name: Cache dependencies and packages needs: constants steps: - uses: actions/setup-node@v4 diff --git a/.github/workflows/wac/rebuildGlobalCache.wac.ts b/.github/workflows/wac/rebuildGlobalCache.wac.ts index e7b071ca7e0..e166408e654 100644 --- a/.github/workflows/wac/rebuildGlobalCache.wac.ts +++ b/.github/workflows/wac/rebuildGlobalCache.wac.ts @@ -6,7 +6,7 @@ import { } from "./steps"; const createRebuildGlobalCacheWorkflow = (branchName: string) => ({ - name: "Rebuild Caches", + name: `Rebuild Global Cache ("${branchName}" branch)`, on: { workflow_dispatch: {}, schedule: [{ cron: "0 4 * * *" }] @@ -27,7 +27,7 @@ const createRebuildGlobalCacheWorkflow = (branchName: string) => ({ ] }), cacheDependenciesPackages: createJob({ - name: `Cache dependencies and packages ("${branchName}" branch)`, + name: `Cache dependencies and packages`, needs: "constants", checkout: { path: branchName }, steps: [ From 69cab342cc8f00ea477fcc09f3fc2d2ed500716f Mon Sep 17 00:00:00 2001 From: adrians5j Date: Thu, 4 Apr 2024 23:11:05 +0200 Subject: [PATCH 49/50] ci: refactor workflow [no ci] --- .github/workflows/rebuildGlobalCacheDev.yml | 1 + .github/workflows/rebuildGlobalCacheNext.yml | 1 + .github/workflows/wac/rebuildGlobalCache.wac.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rebuildGlobalCacheDev.yml b/.github/workflows/rebuildGlobalCacheDev.yml index 96e20f0f623..73729864f1a 100644 --- a/.github/workflows/rebuildGlobalCacheDev.yml +++ b/.github/workflows/rebuildGlobalCacheDev.yml @@ -35,6 +35,7 @@ jobs: - uses: actions/checkout@v4 with: path: dev + ref: dev - uses: actions/cache@v4 with: path: dev/.yarn/cache diff --git a/.github/workflows/rebuildGlobalCacheNext.yml b/.github/workflows/rebuildGlobalCacheNext.yml index fdd4d538d54..78c1ab0c6aa 100644 --- a/.github/workflows/rebuildGlobalCacheNext.yml +++ b/.github/workflows/rebuildGlobalCacheNext.yml @@ -35,6 +35,7 @@ jobs: - uses: actions/checkout@v4 with: path: next + ref: next - uses: actions/cache@v4 with: path: next/.yarn/cache diff --git a/.github/workflows/wac/rebuildGlobalCache.wac.ts b/.github/workflows/wac/rebuildGlobalCache.wac.ts index e166408e654..5697c620ecb 100644 --- a/.github/workflows/wac/rebuildGlobalCache.wac.ts +++ b/.github/workflows/wac/rebuildGlobalCache.wac.ts @@ -29,7 +29,7 @@ const createRebuildGlobalCacheWorkflow = (branchName: string) => ({ cacheDependenciesPackages: createJob({ name: `Cache dependencies and packages`, needs: "constants", - checkout: { path: branchName }, + checkout: { path: branchName, ref: branchName }, steps: [ ...createYarnCacheSteps({ workingDirectory: branchName }), ...createGlobalBuildCacheSteps({ workingDirectory: branchName }), From 667479fdcae424cb8a996cc6dfeeb18289e9b04b Mon Sep 17 00:00:00 2001 From: adrians5j Date: Fri, 5 Apr 2024 09:48:29 +0200 Subject: [PATCH 50/50] ci: temporary disable workflow validation [no ci] --- .github/workflows/pullRequests.yml | 15 --------------- .github/workflows/pushDev.yml | 15 --------------- .github/workflows/pushNext.yml | 15 --------------- .github/workflows/wac/pullRequests.wac.ts | 4 ++-- .github/workflows/wac/push.wac.ts | 4 ++-- 5 files changed, 4 insertions(+), 49 deletions(-) diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 8fdfc54fec9..e741af8b405 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -5,21 +5,6 @@ name: Pull Requests 'on': pull_request jobs: - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false validateCommits: name: Validate commit messages if: github.base_ref != 'dev' diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index 0efe71a93a0..e68779a2334 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -8,21 +8,6 @@ name: Dev Branch - Push branches: - dev jobs: - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: name: Create constants outputs: diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 458ff62d574..7bb1b77b626 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -8,21 +8,6 @@ name: Next Branch - Push branches: - next jobs: - validateWorkflows: - name: Validate workflows - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: actions/checkout@v4 - - name: Install dependencies - run: yarn --immutable - - name: Validate - run: npx github-actions-wac validate - runs-on: ubuntu-latest - env: - NODE_OPTIONS: '--max_old_space_size=4096' - YARN_ENABLE_IMMUTABLE_INSTALLS: false constants: name: Create constants outputs: diff --git a/.github/workflows/wac/pullRequests.wac.ts b/.github/workflows/wac/pullRequests.wac.ts index 21dad4a78fb..a9bd769deee 100644 --- a/.github/workflows/wac/pullRequests.wac.ts +++ b/.github/workflows/wac/pullRequests.wac.ts @@ -1,5 +1,5 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; -import { createValidateWorkflowsJob, createJob } from "./jobs"; +import { createJob } from "./jobs"; import { NODE_VERSION, listPackagesWithJestTests } from "./utils"; import { createGlobalBuildCacheSteps, @@ -78,7 +78,7 @@ export const pullRequests = createWorkflow({ name: "Pull Requests", on: "pull_request", jobs: { - validateWorkflows: createValidateWorkflowsJob(), + // validateWorkflows: createValidateWorkflowsJob(), validateCommits: createJob({ name: "Validate commit messages", if: "github.base_ref != 'dev'", diff --git a/.github/workflows/wac/push.wac.ts b/.github/workflows/wac/push.wac.ts index c257aa94317..da05ad317cb 100644 --- a/.github/workflows/wac/push.wac.ts +++ b/.github/workflows/wac/push.wac.ts @@ -1,6 +1,6 @@ import { createWorkflow, NormalJob } from "github-actions-wac"; import { listPackagesWithJestTests, NODE_VERSION } from "./utils"; -import { createJob, createValidateWorkflowsJob } from "./jobs"; +import { createJob } from "./jobs"; import { createDeployWebinySteps, createSetupVerdaccioSteps, @@ -263,7 +263,7 @@ const createPushWorkflow = (branchName: string) => { name: `${ucFirstBranchName} Branch - Push`, on: { push: { branches: [branchName] } }, jobs: { - validateWorkflows: createValidateWorkflowsJob(), + // validateWorkflows: createValidateWorkflowsJob(), constants: createJob({ name: "Create constants", outputs: {