mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
151 lines
4.2 KiB
YAML
151 lines
4.2 KiB
YAML
|
name: Reusable e2e workflow
|
||
|
|
||
|
on:
|
||
|
workflow_call:
|
||
|
inputs:
|
||
|
branch:
|
||
|
description: 'GitHub branch to test.'
|
||
|
required: false
|
||
|
type: string
|
||
|
default: 'master'
|
||
|
user:
|
||
|
description: 'User who kicked this off.'
|
||
|
required: false
|
||
|
type: string
|
||
|
default: 'schedule'
|
||
|
spec:
|
||
|
description: 'Specify specs.'
|
||
|
required: false
|
||
|
default: 'e2e/*'
|
||
|
type: string
|
||
|
run-env:
|
||
|
description: 'Node env version to run tests with.'
|
||
|
required: false
|
||
|
default: 'browsers:node16.18.0-chrome90-ff88'
|
||
|
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
|
||
|
default: true
|
||
|
type: boolean
|
||
|
parallel:
|
||
|
description: 'Run tests in parallel.'
|
||
|
required: false
|
||
|
default: true
|
||
|
type: boolean
|
||
|
containers:
|
||
|
description: 'Number of containers to run tests in.'
|
||
|
required: false
|
||
|
default: '[1, 2, 3, 4, 5, 6, 7, 8]'
|
||
|
type: string
|
||
|
secrets:
|
||
|
CYPRESS_RECORD_KEY:
|
||
|
description: 'Cypress record key.'
|
||
|
required: true
|
||
|
|
||
|
jobs:
|
||
|
# single job that generates and outputs a common id
|
||
|
prepare:
|
||
|
runs-on: ubuntu-latest
|
||
|
outputs:
|
||
|
uuid: ${{ steps.uuid.outputs.value }}
|
||
|
steps:
|
||
|
- name: Generate unique ID 💎
|
||
|
id: uuid
|
||
|
# take the current commit + timestamp together
|
||
|
# the typical value would be something like
|
||
|
# "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@v3
|
||
|
with:
|
||
|
repository: n8n-io/n8n
|
||
|
ref: ${{ inputs.branch }}
|
||
|
|
||
|
- name: Setup pnpm
|
||
|
uses: pnpm/action-setup@v2.2.4
|
||
|
with:
|
||
|
run_install: true
|
||
|
|
||
|
- name: Cache pnpm modules
|
||
|
uses: actions/cache@v3
|
||
|
with:
|
||
|
path: |
|
||
|
/github/home/.cache
|
||
|
/github/home/.pnpm-store
|
||
|
./node_modules
|
||
|
./packages
|
||
|
key: ${{ inputs.cache-key }}
|
||
|
|
||
|
- name: Cypress build
|
||
|
uses: cypress-io/github-action@v5
|
||
|
with:
|
||
|
# Disable running of tests within install job
|
||
|
runTests: false
|
||
|
install: false
|
||
|
build: pnpm build
|
||
|
|
||
|
- name: Cypress install
|
||
|
run: pnpm cypress:install
|
||
|
|
||
|
testing:
|
||
|
runs-on: ubuntu-latest
|
||
|
container:
|
||
|
image: cypress/${{ inputs.run-env }}
|
||
|
options: --user 1001
|
||
|
needs: ['prepare', 'install']
|
||
|
strategy:
|
||
|
fail-fast: false
|
||
|
matrix:
|
||
|
containers: ${{ fromJSON(inputs.containers) }}
|
||
|
steps:
|
||
|
- uses: actions/checkout@v3
|
||
|
with:
|
||
|
repository: n8n-io/n8n
|
||
|
ref: ${{ inputs.branch }}
|
||
|
|
||
|
- name: Setup pnpm
|
||
|
uses: pnpm/action-setup@v2.2.4
|
||
|
|
||
|
- name: Restore cached pnpm modules
|
||
|
uses: actions/cache@v3
|
||
|
with:
|
||
|
path: |
|
||
|
/github/home/.cache
|
||
|
/github/home/.pnpm-store
|
||
|
./node_modules
|
||
|
./packages
|
||
|
key: ${{ inputs.cache-key }}
|
||
|
|
||
|
- name: Cypress run
|
||
|
uses: cypress-io/github-action@v5
|
||
|
with:
|
||
|
install: false
|
||
|
start: pnpm start
|
||
|
wait-on: 'http://localhost:5678'
|
||
|
wait-on-timeout: 120 #
|
||
|
record: ${{ inputs.record }}
|
||
|
parallel: ${{ inputs.parallel }}
|
||
|
# We have to provide custom ci-build-id key to make sure that this workflow could be run multiple times
|
||
|
# in the same parent workflow
|
||
|
ci-build-id: ${{ needs.prepare.outputs.uuid }}
|
||
|
spec: "/__w/n8n/n8n/cypress/${{ inputs.spec }}"
|
||
|
config-file: /__w/n8n/n8n/cypress.config.js
|
||
|
env:
|
||
|
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 }}
|