From 9c986310a78810e92b146586cf3999dd90d5bce4 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: Wed, 14 Aug 2024 17:16:38 +0200 Subject: [PATCH] ci: Automate more of the release process (no-changelog) --- .github/workflows/check-pr-title.yml | 3 +- .github/workflows/chromatic.yml | 2 +- .github/workflows/ci-postgres-mysql.yml | 108 +----------------- .github/workflows/ci-pull-requests.yml | 7 +- .github/workflows/db-tests-reusable.yml | 101 +++++++++++++++++ .github/workflows/docker-images-nightly.yml | 5 - .github/workflows/docker-images.yml | 48 -------- .github/workflows/e2e-reusable.yml | 11 +- .github/workflows/e2e-tests-pr.yml | 3 +- .github/workflows/linting-reusable.yml | 1 - .github/workflows/release-create-pr.yml | 30 +++-- .github/workflows/release-pr-checks.yml | 49 ++++++++ .github/workflows/release-publish.yml | 119 ++++++++++++++++---- .github/workflows/units-tests-reusable.yml | 1 - 14 files changed, 283 insertions(+), 205 deletions(-) create mode 100644 .github/workflows/db-tests-reusable.yml delete mode 100644 .github/workflows/docker-images.yml create mode 100644 .github/workflows/release-pr-checks.yml diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml index add6e858a36c2..761cc5b8c7f8d 100644 --- a/.github/workflows/check-pr-title.yml +++ b/.github/workflows/check-pr-title.yml @@ -7,8 +7,7 @@ on: - edited - synchronize branches: - - '**' - - '!release/*' + - 'master' jobs: check-pr-title: diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index bfd43e9257fe5..d2ebc05320fe8 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: pull_request_review: types: [submitted] - branch: + branches: - 'master' paths: - packages/design-system/** diff --git a/.github/workflows/ci-postgres-mysql.yml b/.github/workflows/ci-postgres-mysql.yml index d5abf1fa2652f..1dcc74bc80650 100644 --- a/.github/workflows/ci-postgres-mysql.yml +++ b/.github/workflows/ci-postgres-mysql.yml @@ -38,113 +38,17 @@ jobs: path: ./packages/**/dist key: ${{ github.sha }}:db-tests - sqlite-pooled: - name: SQLite Pooled - runs-on: ubuntu-latest - needs: build - timeout-minutes: 20 - env: - DB_TYPE: sqlite - DB_SQLITE_POOL_SIZE: 4 - 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: Setup build cache - uses: rharkor/caching-for-turbo@v1.5 - - - name: Restore cached build artifacts - uses: actions/cache/restore@v4.0.0 - with: - path: ./packages/**/dist - key: ${{ github.sha }}:db-tests - - - name: Test SQLite Pooled - working-directory: packages/cli - run: pnpm jest - - mysql: - name: MySQL - runs-on: ubuntu-latest + db-tests: + name: DB tests + uses: ./.github/workflows/db-tests-reusable.yml needs: build - timeout-minutes: 20 - env: - DB_MYSQLDB_PASSWORD: password - 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: Setup build cache - uses: rharkor/caching-for-turbo@v1.5 - - - name: Restore cached build artifacts - uses: actions/cache/restore@v4.0.0 - with: - path: ./packages/**/dist - key: ${{ github.sha }}:db-tests - - - name: Start MySQL - uses: isbang/compose-action@v2.0.0 - with: - compose-file: ./.github/docker-compose.yml - services: | - mysql - - - name: Test MySQL - working-directory: packages/cli - run: pnpm test:mysql --testTimeout 20000 - - postgres: - name: Postgres - runs-on: ubuntu-latest - needs: build - timeout-minutes: 20 - env: - DB_POSTGRESDB_PASSWORD: password - DB_POSTGRESDB_POOL_SIZE: 1 # Detect connection pooling deadlocks - 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: Setup build cache - uses: rharkor/caching-for-turbo@v1.5 - - - name: Restore cached build artifacts - uses: actions/cache/restore@v4.0.0 - with: - path: ./packages/**/dist - key: ${{ github.sha }}:db-tests - - - name: Start Postgres - uses: isbang/compose-action@v2.0.0 - with: - compose-file: ./.github/docker-compose.yml - services: | - postgres - - - name: Test Postgres - working-directory: packages/cli - run: pnpm test:postgres + with: + cacheKey: ${{ github.sha }}:db-tests notify-on-failure: name: Notify Slack on failure runs-on: ubuntu-latest - needs: [mysql, postgres] + needs: [db-tests] steps: - name: Notify Slack on failure uses: act10ns/slack@v2.0.0 diff --git a/.github/workflows/ci-pull-requests.yml b/.github/workflows/ci-pull-requests.yml index 78a5388950d51..d9938983b1de5 100644 --- a/.github/workflows/ci-pull-requests.yml +++ b/.github/workflows/ci-pull-requests.yml @@ -1,6 +1,10 @@ name: Build, unit test and lint branch -on: [pull_request] +on: + pull_request: + branches: + - '**' + - '!release/*' jobs: install-and-build: @@ -9,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/db-tests-reusable.yml b/.github/workflows/db-tests-reusable.yml new file mode 100644 index 0000000000000..009f4a8f99401 --- /dev/null +++ b/.github/workflows/db-tests-reusable.yml @@ -0,0 +1,101 @@ +name: Reusable DB test workflow + +on: + workflow_call: + inputs: + cacheKey: + description: Cache key for build artifacts. + required: true + type: string + +jobs: + sqlite-pooled: + name: SQLite Pooled + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + DB_TYPE: sqlite + DB_SQLITE_POOL_SIZE: 4 + 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: Restore cached build artifacts + uses: actions/cache/restore@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ inputs.cacheKey }} + + - name: Test SQLite Pooled + working-directory: packages/cli + run: pnpm jest + + mysql: + name: MySQL + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + DB_MYSQLDB_PASSWORD: password + 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: Restore cached build artifacts + uses: actions/cache/restore@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ inputs.cacheKey }} + + - name: Start MySQL + uses: isbang/compose-action@v2.0.0 + with: + compose-file: ./.github/docker-compose.yml + services: | + mysql + + - name: Test MySQL + working-directory: packages/cli + run: pnpm test:mysql --testTimeout 20000 + + postgres: + name: Postgres + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + DB_POSTGRESDB_PASSWORD: password + DB_POSTGRESDB_POOL_SIZE: 1 # Detect connection pooling deadlocks + 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: Restore cached build artifacts + uses: actions/cache/restore@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ inputs.cacheKey }} + + - name: Start Postgres + uses: isbang/compose-action@v2.0.0 + with: + compose-file: ./.github/docker-compose.yml + services: | + postgres + + - name: Test Postgres + working-directory: packages/cli + run: pnpm test:postgres diff --git a/.github/workflows/docker-images-nightly.yml b/.github/workflows/docker-images-nightly.yml index b701392e8b832..34950d7ac2413 100644 --- a/.github/workflows/docker-images-nightly.yml +++ b/.github/workflows/docker-images-nightly.yml @@ -6,10 +6,6 @@ on: - cron: '0 1 * * *' workflow_dispatch: inputs: - repository: - description: 'GitHub repository to create image off.' - required: true - default: 'n8n-io/n8n' branch: description: 'GitHub branch to create image off.' required: true @@ -49,7 +45,6 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.1 with: - repository: ${{ github.event.inputs.repository || 'n8n-io/n8n' }} ref: ${{ github.event.inputs.branch || 'master' }} - name: Set up QEMU diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml deleted file mode 100644 index 5c91f3832d134..0000000000000 --- a/.github/workflows/docker-images.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Docker Image CI - -on: - release: - types: [published] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4.1.1 - - - name: Get the version - id: vars - run: echo ::set-output name=tag::$(echo ${GITHUB_REF:14}) - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 - - - 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 }} - - - name: Build - uses: docker/build-push-action@v5.1.0 - with: - context: ./docker/images/n8n - build-args: | - N8N_VERSION=${{ steps.vars.outputs.tag }} - platforms: linux/amd64,linux/arm64 - provenance: false - push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/n8n:${{ steps.vars.outputs.tag }} - ghcr.io/${{ github.repository_owner }}/n8n:${{ steps.vars.outputs.tag }} diff --git a/.github/workflows/e2e-reusable.yml b/.github/workflows/e2e-reusable.yml index beea3bca27cf5..ab88930a3a0f7 100644 --- a/.github/workflows/e2e-reusable.yml +++ b/.github/workflows/e2e-reusable.yml @@ -22,11 +22,6 @@ on: 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 - type: string record: description: 'Record test run.' required: false @@ -78,7 +73,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: ${{ inputs.branch }} - name: Checkout PR @@ -111,7 +105,7 @@ jobs: /github/home/.cache /github/home/.pnpm-store ./packages/**/dist - key: ${{ inputs.cache-key }} + key: ${{ github.sha }}-e2e testing: runs-on: ubuntu-latest @@ -128,7 +122,6 @@ jobs: steps: - uses: actions/checkout@v4.1.1 with: - repository: n8n-io/n8n ref: ${{ inputs.branch }} - name: Checkout PR @@ -146,7 +139,7 @@ jobs: /github/home/.cache /github/home/.pnpm-store ./packages/**/dist - key: ${{ inputs.cache-key }} + key: ${{ github.sha }}-e2e - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/e2e-tests-pr.yml b/.github/workflows/e2e-tests-pr.yml index f845dbb06203f..72557a8f2581c 100644 --- a/.github/workflows/e2e-tests-pr.yml +++ b/.github/workflows/e2e-tests-pr.yml @@ -3,7 +3,7 @@ name: PR E2E on: pull_request_review: types: [submitted] - branch: + branches: - 'master' concurrency: @@ -18,7 +18,6 @@ jobs: with: pr_number: ${{ github.event.pull_request.number }} user: ${{ github.event.pull_request.user.login || 'PR User' }} - spec: 'e2e/*' secrets: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/linting-reusable.yml b/.github/workflows/linting-reusable.yml index 2650622bd04e4..ed8d23494000e 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-create-pr.yml b/.github/workflows/release-create-pr.yml index a17fa1bf89984..c56b9a404a2cd 100644 --- a/.github/workflows/release-create-pr.yml +++ b/.github/workflows/release-create-pr.yml @@ -48,20 +48,34 @@ jobs: env: RELEASE_TYPE: ${{ github.event.inputs.release-type }} - - name: Update Changelog - run: node .github/scripts/update-changelog.mjs - - name: Push the base branch run: | git push -f origin refs/remotes/origin/${{ github.event.inputs.base-branch }}:refs/heads/release/${{ env.NEXT_RELEASE }} - name: Push the release branch, and Create the PR - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 + id: create-pull-request with: base: 'release/${{ env.NEXT_RELEASE }}' - branch: '${{ env.NEXT_RELEASE }}-pr' - commit-message: ':rocket: Release ${{ env.NEXT_RELEASE }}' + branch: 'release-pr/${{ env.NEXT_RELEASE }}' + commit-message: 'Bump package versions' delete-branch: true - labels: 'release' + labels: release,release:${{ github.event.inputs.release-type }} title: ':rocket: Release ${{ env.NEXT_RELEASE }}' - body-path: 'CHANGELOG-${{ env.NEXT_RELEASE }}.md' + body: '' + + - name: Generate Changelog + run: node .github/scripts/update-changelog.mjs + + - run: ls -al + + - name: Update PR + run: | + gh pr edit ${{ steps.create-pull-request.outputs.pull-request-number }} --body-file 'CHANGELOG-${{ env.NEXT_RELEASE }}.md' + git checkout --track origin/release-pr/${{ env.NEXT_RELEASE }} + git config user.name "github-actions[bot]" + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git commit CHANGELOG.md -m "Changelog for ${{ env.NEXT_RELEASE }}" + git push origin release-pr/${{ env.NEXT_RELEASE }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-pr-checks.yml b/.github/workflows/release-pr-checks.yml new file mode 100644 index 0000000000000..46aaa470655ad --- /dev/null +++ b/.github/workflows/release-pr-checks.yml @@ -0,0 +1,49 @@ +name: 'Release: PR Checks' + +on: + pull_request: + types: + - opened + branches: + - 'release/*' + +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: Run typecheck + run: pnpm typecheck + + - name: Cache build artifacts + uses: actions/cache/save@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ github.sha }}-release-pr:build + + db-tests: + name: DB tests + uses: ./.github/workflows/db-tests-reusable.yml + needs: build + with: + cacheKey: ${{ github.sha }}-release-pr:build + + e2e-tests: + name: E2E Tests + uses: ./.github/workflows/e2e-reusable.yml + with: + pr_number: ${{ github.event.pull_request.number }} + user: ${{ 'Release' }} + secrets: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 239c18b51223e..07c642b12e7de 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -8,18 +8,15 @@ on: - 'release/*' jobs: - publish-release: - if: github.event.pull_request.merged == true + publish-to-npm: + name: Publish to NPM runs-on: ubuntu-latest - - permissions: - contents: write - id-token: write - - timeout-minutes: 60 + if: github.event.pull_request.merged == true + timeout-minutes: 10 env: NPM_CONFIG_PROVENANCE: true - + outputs: + release: ${{ steps.set-release.outputs.release }} steps: - name: Checkout uses: actions/checkout@v4.1.1 @@ -49,27 +46,101 @@ jobs: 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 + # npm dist-tag rm n8n rc + + - id: set-release + run: echo "release=${{ env.RELEASE }}" >> $GITHUB_OUTPUT + + publish-to-docker-hub: + name: Publish to DockerHub + needs: [publish-to-npm] + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + + - 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 }} + + - 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: false # TODO revert to true + tags: | + ${{ secrets.DOCKER_USERNAME }}/n8n:${{ needs.publish-to-npm.outputs.release }} + ghcr.io/${{ github.repository_owner }}/n8n:${{ needs.publish-to-npm.outputs.release }} + + create-github-release: + name: Create a GitHub Release + needs: [publish-to-npm, publish-to-docker-hub] + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + timeout-minutes: 5 + + permissions: + contents: write + id-token: write + + steps: - 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] + # if: github.event.pull_request.merged == true + # 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] + if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'release:patch') }} + 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 1f64b2e27c6c3..60bf593e824ef 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