2021-01-06 15:37:59 -05:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 15:50:07 -05:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
name: Frontend / Run E2E Tests
|
2020-07-16 05:22:53 -04:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
2022-10-21 12:57:29 -04:00
|
|
|
pull_request_target:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
2022-11-06 14:07:44 -05:00
|
|
|
pull_request:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
2020-07-16 05:22:53 -04:00
|
|
|
|
2022-10-21 12:57:29 -04:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
env:
|
|
|
|
NODE_VERSION: 18
|
2022-11-06 16:04:23 -05:00
|
|
|
HEAD_COMMIT_HASH: "${{ !!github.event.pull_request && github.event.pull_request.head.sha || github.sha }}"
|
2022-10-21 12:57:29 -04:00
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 12:40:59 -05:00
|
|
|
group: ${{ github.workflow }}-${{ !!github.event.pull_request && github.event.pull_request.head.label || github.ref }}-${{ github.event_name }}-${{ github.job }}
|
2022-11-11 04:55:08 -05:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-07-16 05:22:53 -04:00
|
|
|
jobs:
|
2022-11-11 04:55:08 -05:00
|
|
|
changes:
|
|
|
|
name: Check for frontend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 11:24:36 -05:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 04:55:08 -05:00
|
|
|
steps:
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
- name: Check for frontend file changes
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
|
2022-11-11 04:55:08 -05:00
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
2022-12-04 16:41:39 -05:00
|
|
|
- 'commons/**'
|
2022-11-11 04:55:08 -05:00
|
|
|
- 'frontend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2021-04-11 16:34:53 -04:00
|
|
|
build-frontend:
|
2022-11-11 04:55:08 -05:00
|
|
|
needs: changes
|
2022-11-29 13:11:52 -05:00
|
|
|
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
|
2020-08-19 16:43:56 -04:00
|
|
|
runs-on: ubuntu-latest
|
2021-04-11 16:34:53 -04:00
|
|
|
name: Build test build of frontend
|
2020-08-19 16:43:56 -04:00
|
|
|
steps:
|
2021-01-06 07:09:33 -05:00
|
|
|
- name: Check out repo
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-06 16:04:23 -05:00
|
|
|
with:
|
|
|
|
ref: ${{ env.HEAD_COMMIT_HASH }}
|
2020-11-29 04:07:44 -05:00
|
|
|
|
2021-04-11 16:34:53 -04:00
|
|
|
- name: Cache build
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
|
2021-06-21 16:59:21 -04:00
|
|
|
id: build-cache
|
2021-04-11 16:34:53 -04:00
|
|
|
with:
|
2022-11-11 04:55:08 -05:00
|
|
|
path: frontend/.next
|
2022-11-06 16:04:23 -05:00
|
|
|
key: ${{ env.HEAD_COMMIT_HASH }}
|
2021-04-11 16:34:53 -04:00
|
|
|
|
2022-11-29 11:36:57 -05:00
|
|
|
- name: Setup node
|
2022-11-11 04:55:08 -05:00
|
|
|
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
2022-11-29 11:36:57 -05:00
|
|
|
uses: ./.github/actions/setup-node
|
2020-08-19 16:43:56 -04:00
|
|
|
with:
|
2022-11-29 11:36:57 -05:00
|
|
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
2020-08-19 16:43:56 -04:00
|
|
|
|
2021-01-06 07:09:33 -05:00
|
|
|
- name: Build test production build
|
2022-11-11 04:55:08 -05:00
|
|
|
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
2021-01-06 07:09:33 -05:00
|
|
|
run: yarn build:test
|
|
|
|
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/upload-artifact@0c366cb4fc8897159c94880f94b55bc716ad6a66 # master
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2021-04-11 16:34:53 -04:00
|
|
|
with:
|
2022-11-11 04:55:08 -05:00
|
|
|
retention-days: 1
|
2022-11-06 11:34:40 -05:00
|
|
|
name: e2e-build
|
2022-01-01 15:43:06 -05:00
|
|
|
path: |
|
2022-11-11 04:55:08 -05:00
|
|
|
frontend/.next
|
|
|
|
!frontend/.next/cache
|
|
|
|
!frontend/.next/standalone
|
2021-01-06 07:09:33 -05:00
|
|
|
|
2021-04-11 16:34:53 -04:00
|
|
|
end2end:
|
|
|
|
name: Perform E2E Test in ${{ matrix.browser }}
|
2022-11-11 04:55:08 -05:00
|
|
|
needs:
|
|
|
|
- build-frontend
|
|
|
|
- changes
|
2021-04-11 16:34:53 -04:00
|
|
|
runs-on: ubuntu-latest
|
2021-06-13 17:02:39 -04:00
|
|
|
container:
|
2022-11-06 11:57:49 -05:00
|
|
|
image: cypress/browsers:node18.12.0-chrome106-ff106
|
2021-06-13 17:02:39 -04:00
|
|
|
options: --user 1001 --shm-size=2g
|
2021-04-11 16:34:53 -04:00
|
|
|
strategy:
|
2021-06-17 15:18:52 -04:00
|
|
|
fail-fast: false
|
2021-04-11 16:34:53 -04:00
|
|
|
matrix:
|
2022-04-10 07:45:13 -04:00
|
|
|
browser: [ 'chrome' ]
|
2022-01-03 06:08:46 -05:00
|
|
|
containers: [ 1, 2, 3, 4, 5 ]
|
2021-04-11 16:34:53 -04:00
|
|
|
steps:
|
|
|
|
- name: Check out repo
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2021-01-11 15:55:25 -05:00
|
|
|
|
2022-07-30 17:32:19 -04:00
|
|
|
- name: Cache build
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
|
2022-07-30 17:32:19 -04:00
|
|
|
id: build-cache
|
|
|
|
with:
|
2022-11-11 04:55:08 -05:00
|
|
|
path: frontend/.next
|
2022-11-06 16:04:23 -05:00
|
|
|
key: ${{ env.HEAD_COMMIT_HASH }}
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-30 17:32:19 -04:00
|
|
|
id: yarn-cache-dir-path
|
2022-10-19 16:47:03 -04:00
|
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
- name: Cache yarn cache
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # v3.2.2
|
2022-07-30 17:32:19 -04:00
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
2022-11-11 04:55:08 -05:00
|
|
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
2022-07-30 17:32:19 -04:00
|
|
|
restore-keys: |
|
2022-10-21 12:57:29 -04:00
|
|
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
|
|
|
|
|
|
- name: Set up NodeJS
|
2022-11-11 04:55:08 -05:00
|
|
|
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
|
2022-10-21 12:57:29 -04:00
|
|
|
with:
|
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-30 17:32:19 -04:00
|
|
|
run: yarn install --immutable
|
|
|
|
|
2021-04-11 16:34:53 -04:00
|
|
|
- name: Download built frontend
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: actions/download-artifact@2a5974104b6d5dbdb2f9468a3e54da3bdd241578 # master
|
2020-08-19 16:43:56 -04:00
|
|
|
with:
|
2022-11-06 11:34:40 -05:00
|
|
|
name: e2e-build
|
2022-11-11 04:55:08 -05:00
|
|
|
path: frontend/.next
|
2021-01-06 07:09:33 -05:00
|
|
|
|
2022-07-30 17:32:19 -04:00
|
|
|
- name: Run server
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-30 17:32:19 -04:00
|
|
|
run: yarn start:ci &
|
2022-09-16 05:03:29 -04:00
|
|
|
env:
|
|
|
|
NODE_ENV: test
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
- name: Wait for server
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-08-01 08:28:22 -04:00
|
|
|
run: "sleep 3 && curl --max-time 120 http://127.0.0.1:3001/"
|
2022-07-30 17:32:19 -04:00
|
|
|
|
|
|
|
- name: Run cypress
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-30 17:32:19 -04:00
|
|
|
run: "yarn cy:run:${{ matrix.browser }} --record true --parallel --group \"UI - ${{ matrix.browser }}\""
|
2021-06-17 15:18:52 -04:00
|
|
|
env:
|
|
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2021-01-06 07:09:33 -05:00
|
|
|
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/upload-artifact@0c366cb4fc8897159c94880f94b55bc716ad6a66 # master
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2020-11-15 14:07:02 -05:00
|
|
|
with:
|
2021-04-11 16:34:53 -04:00
|
|
|
name: screenshots
|
|
|
|
path: cypress/screenshots
|