mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
31e4ab5e37
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
146 lines
4.1 KiB
YAML
146 lines
4.1 KiB
YAML
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
name: e2e
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request_target:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
NODE_VERSION: 18
|
|
HEAD_COMMIT_HASH: "${{ !!github.event.pull_request && github.event.pull_request.head.sha || github.sha }}"
|
|
|
|
jobs:
|
|
build-frontend:
|
|
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@v3
|
|
with:
|
|
ref: ${{ env.HEAD_COMMIT_HASH }}
|
|
|
|
- name: Cache build
|
|
uses: actions/cache@v3.0.11
|
|
id: build-cache
|
|
with:
|
|
path: .next
|
|
key: ${{ env.HEAD_COMMIT_HASH }}
|
|
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache yarn cache
|
|
uses: actions/cache@v3
|
|
id: yarn-cache
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
with:
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
|
|
- name: Set up NodeJS
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
run: yarn install --immutable
|
|
|
|
- name: Build test production build
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
run: yarn build:test
|
|
|
|
- uses: actions/upload-artifact@master
|
|
with:
|
|
name: e2e-build
|
|
path: |
|
|
.next
|
|
!.next/cache
|
|
!.next/standalone
|
|
|
|
end2end:
|
|
name: Perform E2E Test in ${{ matrix.browser }}
|
|
needs: build-frontend
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: cypress/browsers:node18.12.0-chrome106-ff106
|
|
options: --user 1001 --shm-size=2g
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
browser: [ 'chrome' ]
|
|
containers: [ 1, 2, 3, 4, 5 ]
|
|
steps:
|
|
- name: Check out repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Cache build
|
|
uses: actions/cache@v3.0.11
|
|
id: build-cache
|
|
with:
|
|
path: .next
|
|
key: ${{ env.HEAD_COMMIT_HASH }}
|
|
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache yarn cache
|
|
uses: actions/cache@v3
|
|
id: yarn-cache
|
|
with:
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
|
|
- name: Set up NodeJS
|
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Download built frontend
|
|
uses: actions/download-artifact@master
|
|
with:
|
|
name: e2e-build
|
|
path: .next
|
|
|
|
- name: Run server
|
|
run: yarn start:ci &
|
|
env:
|
|
NODE_ENV: test
|
|
|
|
- name: Wait for server
|
|
run: "sleep 3 && curl --max-time 120 http://127.0.0.1:3001/"
|
|
|
|
- name: Run cypress
|
|
run: "yarn cy:run:${{ matrix.browser }} --record true --parallel --group \"UI - ${{ matrix.browser }}\""
|
|
env:
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: actions/upload-artifact@master
|
|
if: always()
|
|
with:
|
|
name: screenshots
|
|
path: cypress/screenshots
|