Skip to content

Commit

Permalink
p
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Aug 20, 2024
1 parent e747ce0 commit d7c8988
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 122 deletions.
76 changes: 15 additions & 61 deletions .github/workflows/e2e-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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/[email protected]
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/[email protected]

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Cypress build
uses: cypress-io/[email protected]
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/[email protected]
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:
Expand All @@ -137,19 +88,22 @@ jobs:
git fetch origin pull/${{ inputs.pr_number }}/head
git checkout FETCH_HEAD
- uses: pnpm/[email protected]
- run: corepack enable
- uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
- run: pnpm install --frozen-lockfile

- name: Restore cached pnpm modules
uses: actions/cache/[email protected]
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/[email protected]
Expand All @@ -170,7 +124,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
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/e2e-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,36 @@ concurrency:
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- run: corepack enable
- uses: actions/[email protected]
with:
node-version: 20.x
cache: pnpm
- run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Cache build artifacts
uses: actions/cache/[email protected]
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 }}

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ on:
default: ''

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- run: corepack enable
- uses: actions/[email protected]
with:
node-version: 20.x
cache: pnpm
- run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Cache build artifacts
uses: actions/cache/[email protected]
with:
path: ./packages/**/dist
key: ${{ github.sha }}-e2e

calls-start-url:
name: Calls start URL
runs-on: ubuntu-latest
Expand All @@ -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 }}

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release-pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
127 changes: 69 additions & 58 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
timeout-minutes: 10
env:
NPM_CONFIG_PROVENANCE: true

outputs:
uuid: ${{ steps.set-release.outputs.value }}
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -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
Expand All @@ -66,34 +72,33 @@ jobs:
- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: actions/[email protected]
- run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV

- name: Build
uses: docker/[email protected]
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/[email protected]
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Login to DockerHub
# uses: docker/[email protected]
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Build
# uses: docker/[email protected]
# 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
Expand All @@ -107,28 +112,34 @@ jobs:
id-token: write

steps:
- uses: actions/[email protected]
- 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 [email protected]
# 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/[email protected]
- 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}}

0 comments on commit d7c8988

Please sign in to comment.