From 23a8d332786b28b26d863449e1138d561f847236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 20 Aug 2024 16:10:26 +0200 Subject: [PATCH] p --- .github/workflows/ci-pull-requests.yml | 1 - .github/workflows/e2e-reusable.yml | 71 ++---------- .github/workflows/e2e-tests-pr.yml | 23 ++++ .github/workflows/e2e-tests.yml | 23 ++++ .github/workflows/linting-reusable.yml | 1 - .github/workflows/release-pr-checks.yml | 5 +- .github/workflows/release-publish.yml | 129 ++++++++++++--------- .github/workflows/units-tests-reusable.yml | 1 - 8 files changed, 129 insertions(+), 125 deletions(-) diff --git a/.github/workflows/ci-pull-requests.yml b/.github/workflows/ci-pull-requests.yml index 5dce01c91fac2f..22f3c1d866f7f0 100644 --- a/.github/workflows/ci-pull-requests.yml +++ b/.github/workflows/ci-pull-requests.yml @@ -13,7 +13,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: refs/pull/${{ github.event.pull_request.number }}/merge - run: corepack enable diff --git a/.github/workflows/e2e-reusable.yml b/.github/workflows/e2e-reusable.yml index beea3bca27cf52..8b1faf307cbe8e 100644 --- a/.github/workflows/e2e-reusable.yml +++ b/.github/workflows/e2e-reusable.yml @@ -17,15 +17,10 @@ on: required: false default: 'e2e/*' type: string - run-env: - description: 'Node env version to run tests with.' - required: false - default: 'browsers:node18.12.0-chrome107' - type: string cache-key: description: 'Cache key for modules and build artifacts.' - required: false - default: ${{ github.sha }}-${{ inputs.run-env }}-e2e-modules + required: true + default: ${{ github.sha }}-e2e type: string record: description: 'Record test run.' @@ -69,56 +64,12 @@ jobs: # "sha-5d3fe...35d3-time-1620841214" run: echo "value=sha-$GITHUB_SHA-time-$(date +"%s")" >> $GITHUB_OUTPUT - install: - runs-on: ubuntu-latest - needs: ['prepare'] - container: - image: cypress/${{ inputs.run-env }} - options: --user 1001 - steps: - - uses: actions/checkout@v4.1.1 - with: - repository: n8n-io/n8n - ref: ${{ inputs.branch }} - - - name: Checkout PR - if: ${{ inputs.pr_number }} - run: | - git fetch origin pull/${{ inputs.pr_number }}/head - git checkout FETCH_HEAD - - - uses: pnpm/action-setup@v4.0.0 - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Cypress build - uses: cypress-io/github-action@v6.6.1 - with: - # Disable running of tests within install job - runTests: false - install: false - build: pnpm build - - - name: Cypress install - working-directory: cypress - run: pnpm cypress:install - - - name: Cache build artifacts - uses: actions/cache/save@v4.0.0 - with: - path: | - /github/home/.cache - /github/home/.pnpm-store - ./packages/**/dist - key: ${{ inputs.cache-key }} - testing: runs-on: ubuntu-latest container: - image: cypress/${{ inputs.run-env }} + image: cypress/browsers:node18.12.0-chrome107 options: --user 1001 - needs: ['prepare', 'install'] + needs: 'prepare' strategy: fail-fast: false matrix: @@ -128,7 +79,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: ${{ inputs.branch }} - name: Checkout PR @@ -138,18 +88,17 @@ jobs: git checkout FETCH_HEAD - uses: pnpm/action-setup@v4.0.0 + - run: pnpm install --frozen-lockfile - name: Restore cached pnpm modules uses: actions/cache/restore@v4.0.0 with: - path: | - /github/home/.cache - /github/home/.pnpm-store - ./packages/**/dist + path: ./packages/**/dist key: ${{ inputs.cache-key }} - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Cypress install + working-directory: cypress + run: pnpm cypress:install - name: Cypress run uses: cypress-io/github-action@v6.6.1 @@ -170,7 +119,7 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} E2E_TESTS: true - COMMIT_INFO_MESSAGE: 🌳 ${{ inputs.branch }} 🖥️ ${{ inputs.run-env }} 🤖 ${{ inputs.user }} 🗃️ ${{ inputs.spec }} + COMMIT_INFO_MESSAGE: 🌳 ${{ inputs.branch }} 🖥️ 🤖 ${{ inputs.user }} 🗃️ ${{ inputs.spec }} SHELL: /bin/sh # Check if all tests passed and set the output variable diff --git a/.github/workflows/e2e-tests-pr.yml b/.github/workflows/e2e-tests-pr.yml index 32cc27dab6a15b..e439d9adab98d4 100644 --- a/.github/workflows/e2e-tests-pr.yml +++ b/.github/workflows/e2e-tests-pr.yml @@ -11,13 +11,36 @@ concurrency: cancel-in-progress: true jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - run: corepack enable + - uses: actions/setup-node@v4.0.2 + with: + node-version: 20.x + cache: pnpm + - run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Cache build artifacts + uses: actions/cache/save@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ github.sha }}-e2e + run-e2e-tests: name: E2E [Electron/Node 18] + needs: build uses: ./.github/workflows/e2e-reusable.yml if: ${{ github.event.review.state == 'approved' && !contains(github.event.pull_request.labels.*.name, 'community') }} with: pr_number: ${{ github.event.pull_request.number }} user: ${{ github.event.pull_request.user.login || 'PR User' }} + cache-key: ${{ github.sha }}-e2e secrets: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index e7400adecbe25a..5d519509b185d7 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -29,6 +29,27 @@ on: default: '' jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + - run: corepack enable + - uses: actions/setup-node@v4.0.2 + with: + node-version: 20.x + cache: pnpm + - run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Cache build artifacts + uses: actions/cache/save@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ github.sha }}-e2e + calls-start-url: name: Calls start URL runs-on: ubuntu-latest @@ -41,11 +62,13 @@ jobs: run-e2e-tests: name: E2E [Electron/Node 18] + needs: build uses: ./.github/workflows/e2e-reusable.yml with: branch: ${{ github.event.inputs.branch || 'master' }} user: ${{ github.event.inputs.user || 'PR User' }} spec: ${{ github.event.inputs.spec || 'e2e/*' }} + cache-key: ${{ github.sha }}-e2e secrets: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/linting-reusable.yml b/.github/workflows/linting-reusable.yml index 7c5278810e0545..4421b00c9dbd60 100644 --- a/.github/workflows/linting-reusable.yml +++ b/.github/workflows/linting-reusable.yml @@ -21,7 +21,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: ${{ inputs.ref }} - run: corepack enable diff --git a/.github/workflows/release-pr-checks.yml b/.github/workflows/release-pr-checks.yml index 819a3937c39a11..30fa2a45ad67bb 100644 --- a/.github/workflows/release-pr-checks.yml +++ b/.github/workflows/release-pr-checks.yml @@ -41,11 +41,10 @@ jobs: e2e-tests: name: E2E Tests - uses: ./.github/workflows/e2e-reusable.yml needs: build + uses: ./.github/workflows/e2e-reusable.yml with: - # reuse the build cache in e2e tests as well - # cache-key: ${{ github.sha }}-release-pr:build + cache-key: ${{ github.sha }}-release-pr:build pr_number: ${{ github.event.pull_request.number }} user: ${{ 'Release' }} secrets: diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 19274567905731..dad1251a8e0ca0 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -15,7 +15,8 @@ jobs: timeout-minutes: 10 env: NPM_CONFIG_PROVENANCE: true - + outputs: + release: ${{ steps.set-release.outputs.release }} steps: - name: Checkout uses: actions/checkout@v4.1.1 @@ -32,20 +33,25 @@ jobs: - name: Set release version in env run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV - - name: Build - run: pnpm build + # - name: Build + # run: pnpm build + + # - name: Dry-run publishing + # run: pnpm publish -r --no-git-checks --dry-run - - name: Dry-run publishing - run: pnpm publish -r --no-git-checks --dry-run + # - name: Publish to NPM + # run: | + # echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + # node .github/scripts/trim-fe-packageJson.js + # node .github/scripts/ensure-provenance-fields.mjs + # sed -i "s/default: 'dev'/default: 'stable'/g" packages/cli/dist/config/schema.js + # pnpm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --tag rc --no-git-checks + # npm dist-tag rm n8n rc - - name: Publish to NPM - run: | - echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - node .github/scripts/trim-fe-packageJson.js - node .github/scripts/ensure-provenance-fields.mjs - sed -i "s/default: 'dev'/default: 'stable'/g" packages/cli/dist/config/schema.js - pnpm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --tag rc --no-git-checks - npm dist-tag rm n8n rc + - run: echo "Fake publish to NPM ${{ env.RELEASE }}" + + - id: set-release + run: echo "release=${{ env.RELEASE }}" >> $GITHUB_OUTPUT publish-to-docker-hub: name: Publish to DockerHub @@ -66,34 +72,33 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.0.0 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to DockerHub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - uses: actions/setup-node@v4.0.2 - - run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV - - - name: Build - uses: docker/build-push-action@v5.1.0 - with: - context: ./docker/images/n8n - build-args: | - N8N_VERSION=${{ env.RELEASE }} - platforms: linux/amd64,linux/arm64 - provenance: false - push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/n8n:${{ env.RELEASE }} - ghcr.io/${{ github.repository_owner }}/n8n:${{ env.RELEASE }} + # - name: Login to GitHub Container Registry + # uses: docker/login-action@v3.0.0 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Login to DockerHub + # uses: docker/login-action@v3.0.0 + # with: + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + # - name: Build + # uses: docker/build-push-action@v5.1.0 + # with: + # context: ./docker/images/n8n + # build-args: | + # N8N_VERSION=${{ needs.publish-to-npm.outputs.release }} + # platforms: linux/amd64,linux/arm64 + # provenance: false + # push: true + # tags: | + # ${{ secrets.DOCKER_USERNAME }}/n8n:${{ needs.publish-to-npm.outputs.release }} + # ghcr.io/${{ github.repository_owner }}/n8n:${{ needs.publish-to-npm.outputs.release }} + + - run: echo "Fake publish to Dockerhub ${{ needs.publish-to-npm.outputs.release }}" create-github-release: name: Create a GitHub Release @@ -107,28 +112,36 @@ jobs: id-token: write steps: - - uses: actions/setup-node@v4.0.2 - - run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV - - name: Create a Release on GitHub uses: ncipollo/release-action@v1 with: commit: ${{github.event.pull_request.base.ref}} - tag: 'n8n@${{env.RELEASE}}' + tag: 'n8n@${{ needs.publish-to-npm.outputs.release }}' prerelease: true makeLatest: false body: ${{github.event.pull_request.body}} - - name: Trigger a release note - continue-on-error: true - run: curl -u docsWorkflows:${{ secrets.N8N_WEBHOOK_DOCS_PASSWORD }} --request GET 'https://internal.users.n8n.cloud/webhook/trigger-release-note' --header 'Content-Type:application/json' --data '{"version":"${{env.RELEASE}}"}' - - # - name: Merge Release into 'master' - # run: | - # git fetch origin - # git checkout --track origin/master - # git config user.name "Jan Oberhauser" - # git config user.email jan.oberhauser@gmail.com - # git merge --ff n8n@${{env.RELEASE}} - # git push origin master - # git push origin :${{github.event.pull_request.base.ref}} + # trigger-release-note: + # name: Trigger a release note + # needs: [publish-to-npm, create-github-release] + # runs-on: ubuntu-latest + # steps: + # - name: Trigger a release note + # continue-on-error: true + # run: curl -u docsWorkflows:${{ secrets.N8N_WEBHOOK_DOCS_PASSWORD }} --request GET 'https://internal.users.n8n.cloud/webhook/trigger-release-note' --header 'Content-Type:application/json' --data '{"version":"${{ needs.publish-to-npm.outputs.release }}"}' + + merge-back-into-master: + name: Merge back into master + needs: [publish-to-npm, create-github-release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + - run: | + git checkout --track origin/master + git config user.name "github-actions[bot]" + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git merge --ff n8n@${{ needs.publish-to-npm.outputs.release }} + git push origin master + git push origin :${{github.event.pull_request.base.ref}} diff --git a/.github/workflows/units-tests-reusable.yml b/.github/workflows/units-tests-reusable.yml index 6bed7c2fdcb89c..d04c6709719c95 100644 --- a/.github/workflows/units-tests-reusable.yml +++ b/.github/workflows/units-tests-reusable.yml @@ -36,7 +36,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: ${{ inputs.ref }} - run: corepack enable