Files
n8n/.github/workflows/test-e2e-helm.yml
n8n-cat-bot[bot] 0f6f292924 refactor: Align Helm harness with n8n-hosting examples and refresh (#46045)
Co-authored-by: n8n-cat-bot[bot] <283985454+n8n-cat-bot[bot]@users.noreply.github.com>
2026-12-02 12:31:15 +00:00

318 lines
12 KiB
YAML

name: 'Test: E2E Helm Chart'
run-name: "${{ github.event_name == 'workflow_dispatch' && format('Test: E2E Helm Chart (branch={0}, chart={1})', inputs.branch || 'default', inputs['helm-chart-ref'] || 'pinned') || '' }}"
# Scope and design: packages/quality/environments/containers/HELM-TESTING.md
on:
schedule:
- cron: '0 3 * * *'
pull_request:
paths:
- '.github/workflows/test-e2e-helm.yml'
- 'packages/quality/environments/containers/helm-*.ts'
- 'packages/quality/environments/containers/index.ts'
- 'packages/quality/environments/containers/services/localstack.ts'
- 'packages/quality/environments/containers/startup-deadline.ts'
- 'packages/quality/environments/containers/test-containers.ts'
- 'packages/quality/testing/playwright/playwright-projects.ts'
- 'packages/quality/testing/playwright/playwright.config.ts'
- 'packages/quality/testing/playwright/tests/deployment/probe.ts'
- 'packages/quality/testing/playwright/tests/helm/**'
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
required: false
default: ''
helm-chart-ref:
description: 'n8n-hosting branch/tag for Helm chart. Empty uses the tag pinned in helm-helpers.ts.'
required: false
default: ''
permissions:
contents: read
env:
DOCKER_IMAGE: ghcr.io/${{ github.repository }}:ci-${{ github.run_id }}
HELM_CHART_REF: ${{ inputs.helm-chart-ref }}
jobs:
build:
name: 'Build Docker Image'
# Fork PRs cannot push ephemeral images to GHCR or read license secrets, so skip the workflow there.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: blacksmith-4vcpu-ubuntu-2204
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.branch || github.ref }}
fetch-depth: 1
- name: Login to GHCR
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to GHCR
uses: ./.github/actions/setup-nodejs
with:
build-command: 'pnpm build:docker'
enable-docker-cache: true
docker-cache-key: n8n-io/n8n
env:
INCLUDE_TEST_CONTROLLER: 'true'
IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: ci-${{ github.run_id }}
RUNNERS_IMAGE_BASE_NAME: ghcr.io/${{ github.repository_owner }}/runners
helm-e2e:
name: 'Helm E2E (${{ matrix.profile }})'
needs: build
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- profile: standalone
test_project: e2e
test_spec: tests/e2e/nodes/code-node-api.spec.ts
helm_spec: ''
reset_e2e_db: 'true'
retries: '2'
requires_license: false
- profile: minimal
test_project: e2e
test_spec: tests/e2e/nodes/code-node-api.spec.ts
helm_spec: 'tests/helm/queue.spec.ts tests/helm/worker-replacement.spec.ts'
reset_e2e_db: 'true'
retries: '2'
requires_license: false
- profile: multi-main
test_project: helm
test_spec: tests/helm/multi-main.spec.ts
helm_spec: ''
reset_e2e_db: 'false'
retries: '0'
requires_license: true
- profile: webhook-processor
test_project: helm
test_spec: tests/helm/webhook-processor.spec.ts
helm_spec: tests/helm/webhook-processor-replacement.spec.ts
reset_e2e_db: 'false'
retries: '0'
requires_license: false
- profile: s3
test_project: helm
test_spec: tests/helm/s3-binary-storage.spec.ts
helm_spec: ''
reset_e2e_db: 'false'
retries: '0'
requires_license: true
- profile: upgrade
test_project: helm
test_spec: tests/helm/upgrade-persistence.spec.ts
helm_spec: ''
reset_e2e_db: 'false'
retries: '0'
requires_license: false
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.branch || github.ref }}
fetch-depth: 1
- name: Setup Environment
uses: ./.github/actions/setup-nodejs
with:
build-command: 'pnpm build'
- name: Install Browsers
if: matrix.test_project == 'e2e'
working-directory: packages/quality/testing/playwright
run: pnpm exec playwright install chromium
- name: Install Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
- name: Install kubectl
uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1
- name: Start K3s + Helm stack
env:
TESTCONTAINERS_RYUK_DISABLED: 'true'
HELM_PROFILE: ${{ matrix.profile }}
TEST_PROJECT: ${{ matrix.test_project }}
N8N_LICENSE_ACTIVATION_KEY: ${{ matrix.requires_license && secrets.N8N_LICENSE_ACTIVATION_KEY || '' }}
N8N_LICENSE_CERT: ${{ matrix.requires_license && secrets.N8N_LICENSE_CERT || '' }}
run: |
set -euo pipefail
# tsx is a devDependency of n8n-containers, not the repo root, so it
# must run via that package (root `npx tsx` stopped resolving when
# shamefully-hoist was removed).
STACK_ARGS=(
--profile "${HELM_PROFILE}"
--url-file /tmp/n8n-helm-url.txt
--kubeconfig-file /tmp/n8n-helm-kubeconfig.txt
--info-file /tmp/n8n-helm-info.json
)
if [ "${HELM_PROFILE}" = "upgrade" ]; then
# Omit --image so the upgrade profile uses the pinned baseline in helm-helpers.ts.
STACK_ARGS+=(--upgrade-target-image "${DOCKER_IMAGE}")
else
STACK_ARGS+=(--image "${DOCKER_IMAGE}")
fi
if [ "${TEST_PROJECT}" = "e2e" ]; then
STACK_ARGS+=(
--env E2E_TESTS=true
--env NODE_ENV=development
)
fi
if [ -n "${HELM_CHART_REF}" ]; then
STACK_ARGS+=(--chart-ref "${HELM_CHART_REF}")
fi
pnpm --filter n8n-containers exec tsx helm-start-stack.ts "${STACK_ARGS[@]}"
N8N_URL=$(cat /tmp/n8n-helm-url.txt)
echo "n8n URL: ${N8N_URL}"
echo "N8N_BASE_URL=${N8N_URL}" >> "$GITHUB_ENV"
KUBECONFIG_PATH=$(cat /tmp/n8n-helm-kubeconfig.txt)
echo "KUBECONFIG=${KUBECONFIG_PATH}" >> "$GITHUB_ENV"
echo "N8N_HELM_STACK_INFO=/tmp/n8n-helm-info.json" >> "$GITHUB_ENV"
- name: Run Helm E2E test
working-directory: packages/quality/testing/playwright
env:
TEST_PROJECT: ${{ matrix.test_project }}
TEST_SPEC: ${{ matrix.test_spec }}
RESET_E2E_DB: ${{ matrix.reset_e2e_db }}
TEST_RETRIES: ${{ matrix.retries }}
PLAYWRIGHT_SKIP_WEBSERVER: 'true'
PLAYWRIGHT_HTML_OPEN: 'never'
run: |
set -euo pipefail
pnpm exec playwright test \
--project="${TEST_PROJECT}" \
"${TEST_SPEC}" \
--workers=1 \
--retries="${TEST_RETRIES}" \
--reporter=list,html
- name: Run additional Helm profile tests
if: matrix.helm_spec != ''
working-directory: packages/quality/testing/playwright
env:
HELM_SPEC: ${{ matrix.helm_spec }}
RESET_E2E_DB: 'false'
PLAYWRIGHT_SKIP_WEBSERVER: 'true'
PLAYWRIGHT_HTML_OPEN: 'never'
run: |
set -euo pipefail
read -r -a HELM_SPECS <<< "${HELM_SPEC}"
pnpm exec playwright test \
--project=helm \
"${HELM_SPECS[@]}" \
--workers=1 \
--retries=0 \
--reporter=list,html
- name: Debug K8s State
if: failure()
run: |
echo "=== Pod Status ==="
kubectl get pods -o wide || true
echo ""
echo "=== Services ==="
kubectl get svc -o wide || true
echo ""
echo "=== PVCs ==="
kubectl get pvc -o wide || true
echo ""
echo "=== Helm History ==="
helm history n8n || true
echo ""
echo "=== Pod Descriptions ==="
kubectl describe pods -l app.kubernetes.io/name=n8n || true
kubectl describe pods -l app=localstack || true
echo ""
echo "=== Recent Events ==="
kubectl get events --sort-by=.lastTimestamp | tail -30 || true
echo ""
echo "=== n8n Pod Logs (last 100 lines) ==="
kubectl logs -l app.kubernetes.io/name=n8n --all-containers --tail=100 || true
echo ""
echo "=== LocalStack Pod Logs (last 100 lines) ==="
kubectl logs -l app=localstack --all-containers --tail=100 || true
echo ""
echo "=== Health Check ==="
if [ -n "${N8N_BASE_URL:-}" ]; then
curl -s -o /dev/null -w "HTTP %{http_code}" "${N8N_BASE_URL}/healthz/readiness" || echo "UNREACHABLE"
else
echo "N8N_BASE_URL not set"
fi
- name: Upload Failure Artifacts
if: failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: helm-e2e-report-${{ matrix.profile }}
path: |
packages/quality/testing/playwright/test-results/
packages/quality/testing/playwright/playwright-report/
retention-days: 7
cleanup-ghcr:
name: 'Cleanup GHCR Image'
needs: [build, helm-e2e]
if: always() && needs.build.result != 'skipped'
runs-on: blacksmith-2vcpu-ubuntu-2204
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/scripts
sparse-checkout-cone-mode: false
- name: Delete images from GHCR
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_ORG: ${{ github.repository_owner }}
GHCR_REPO: ${{ github.event.repository.name }}
run: node .github/scripts/cleanup-ghcr-images.mjs --tag ci-${{ github.run_id }}
notify-on-failure:
name: Notify Slack on nightly failure
needs: [build, helm-e2e]
if: always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule'
runs-on: blacksmith-2vcpu-ubuntu-2204
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
sparse-checkout: .github/scripts/slack
sparse-checkout-cone-mode: false
- name: Notify Slack
env:
SLACK_TOKEN: ${{ secrets.QBOT_SLACK_TOKEN }}
run: |
node .github/scripts/slack/notify.mjs \
--channel '#team-catalysts' \
--text 'Nightly Helm chart E2E failed - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'