hedgedoc/.github/workflows/e2e-tests.yml
renovate[bot] 8ebc07ae7a
chore(deps): update postgres:16.4 docker digest to e62fbf9 (develop) (#5870)
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-12 20:34:41 +00:00

223 lines
7.4 KiB
YAML

# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: E2E Tests
on:
push:
branches: [ develop ]
pull_request_target:
branches: [ develop ]
pull_request:
branches: [ develop ]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ !!github.event.pull_request && github.event.pull_request.head.label || github.ref }}-${{ github.event_name }}-${{ github.job }}
cancel-in-progress: true
env:
NODEJS_VERSION: 20
HEAD_COMMIT_HASH: "${{ !!github.event.pull_request && github.event.pull_request.head.sha || github.sha }}"
jobs:
backend-sqlite: # This run also collects coverage
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn test:e2e:ci --filter=@hedgedoc/backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: sqlite
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Upload coverage
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
directory: backend/coverage-e2e
flags: backend, e2e-tests, backend-e2e-tests
backend-mariadb:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
services:
mariadb:
# renovate: datasource=docker depName=mariadb
image: mariadb:11.5.2@sha256:4a1de8fa2a929944373d7421105500ff6f889ce90dcb883fbb2fdb070e4d427e
env:
MYSQL_USER: hedgedoc
MYSQL_PASSWORD: hedgedoc
MYSQL_DATABASE: hedgedoc
MYSQL_ROOT_PASSWORD: hedgedoc
MARIADB_MYSQL_LOCALHOST_USER: 1
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
options: --health-cmd "healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval 10s --health-timeout 5s --health-retries 10
ports:
- 3306:3306
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn test:e2e:ci --filter=@hedgedoc/backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: mariadb
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
backend-postgres:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
services:
postgres:
# renovate: datasource=docker depName=postgres
image: postgres:16.4@sha256:e62fbf9d3e2b49816a32c400ed2dba83e3b361e6833e624024309c35d334b412
env:
POSTGRES_PASSWORD: hedgedoc
POSTGRES_USER: hedgedoc
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn test:e2e:ci --filter=@hedgedoc/backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: postgres
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
frontend-build:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
name: Build test build of frontend
steps:
- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ env.HEAD_COMMIT_HASH }}
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Build test production build
run: yarn build:test --filter=@hedgedoc/frontend
shell: bash
env:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Compress build
run: tar --zstd -cf frontend-e2e-build.tar.zst frontend/dist/
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: frontend-e2e-build
retention-days: 1
path: frontend-e2e-build.tar.zst
overwrite: true
frontend-cypress:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
needs: frontend-build
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.18.0-chrome-130.0.6723.69-1-ff-131.0.3-edge-130.0.2849.52-1@sha256:3dd9d85309ed42d4befeda0b80e15b93c5ede2d419b6fc93a341ffc7337e3505
options: --shm-size=2g
strategy:
fail-fast: false
matrix:
containers: [ 1, 2, 3 ]
steps:
- name: Install additional packages
run: apt-get update && apt-get install -y jq zstd screen curl
- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ env.HEAD_COMMIT_HASH }}
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Download build
uses: actions/download-artifact@v4
with:
name: frontend-e2e-build
path: .
merge-multiple: true
- name: Decompress build
run: tar -xf frontend-e2e-build.tar.zst
- name: Run server
working-directory: frontend/
run: screen -dmS server -L yarn start
env:
NODE_ENV: test
HOSTNAME: "127.0.0.1"
HD_BASE_URL: "http://127.0.0.1:3001/"
PORT: 3001
- name: Wait for server
run: "sleep 3 && curl -L --max-time 120 http://127.0.0.1:3001/"
- name: Run cypress
run: yarn test:e2e:ci --filter=@hedgedoc/frontend
shell: bash
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
CYPRESS_CONTAINER_ID: ${{ matrix.containers }}
- uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # master
if: always()
with:
name: screenlog-${{ matrix.containers }}
path: frontend/screenlog.0
- uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # master
if: always()
with:
name: screenshots-${{ matrix.containers }}
path: cypress/screenshots