-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (87 loc) · 3.07 KB
/
common-frontend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Reusable frontend workflow
on:
workflow_call:
inputs:
app-name:
description: "Application name"
required: true
type: string
cypress-base-url:
description: "Cypress base url"
required: true
type: string
env:
FRONTEND_DIR: ./frontend
BACKEND_DIR: ./backend
GITHUB_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
common-frontend:
if: ${{ contains(github.event.head_commit.message, inputs.app-name) || contains(github.ref, 'snyk-io') }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.9.0]
steps:
- uses: actions/checkout@v3
- uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Helsinki"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache Yarn modules
uses: actions/cache@v3
id: yarn-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('frontend/package.json') }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
working-directory: ${{ env.FRONTEND_DIR }}
run: |
yarn install --immutable
if: steps.yarn-cache.outputs.cache-hit != 'true'
- name: Run Linters
working-directory: ${{ env.FRONTEND_DIR }}
run: yarn ${{ inputs.app-name }}:lint
- name: Format
working-directory: ${{ env.FRONTEND_DIR }}
run: yarn ${{ inputs.app-name }}:format
- name: Run Jest Tests
working-directory: ${{ env.FRONTEND_DIR }}
run: yarn ${{ inputs.app-name }}:test:jest
- name: Cache Cypress
uses: actions/cache@v3
id: cypress-cache
with:
path: "~/.cache/Cypress"
key: ${{ runner.os }}-cypress-cache-${{ hashFiles('frontend/package.json') }}
- name: Install Cypress
uses: cypress-io/github-action@v4
with:
working-directory: ${{ env.FRONTEND_DIR }}
runTests: false
if: steps.cypress-cache.outputs.cache-hit != 'true'
- name: Run Cypress Tests
uses: cypress-io/github-action@v4
with:
working-directory: ${{ env.FRONTEND_DIR }}
install: false
start: yarn ${{ inputs.app-name }}:start:ci
wait-on: ${{ inputs.cypress-base-url }}
command: yarn ${{ inputs.app-name }}:test:cypress
timeout-minutes: 10
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: ${{ env.FRONTEND_DIR }}/packages/${{ inputs.app-name }}/src/tests/cypress/screenshots
- name: Build
working-directory: ${{ env.FRONTEND_DIR }}
run: yarn ${{ inputs.app-name }}:build
- name: Cache build
uses: actions/cache@v3
with:
path: ${{ env.BACKEND_DIR }}/${{ inputs.app-name }}/src/main/resources/static
key: ${{ runner.os }}-${{ inputs.app-name }}-frontend-build-${{ github.sha }}