generated from digitalservicebund/remix-application-template
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (107 loc) · 4.43 KB
/
check-and-test.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Check and Test
on:
workflow_call:
inputs:
package:
required: true
type: string
description: "The Package to check and test."
shouldRunIntegrationTests:
required: false
type: boolean
description: "Whether to run integration tests (E2E and A11y). Default is true."
default: true
nightlyTests:
required: false
type: boolean
description: "If enabled extensive tests are executed sequentially with more devices and browsers."
default: false
env:
WORKSPACE: "@digitalcheck/${{ inputs.package }}"
jobs:
check-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Cache npm dependencies
id: cache-npm-deps
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
if: steps.cache-npm-deps.outputs.cache-hit != 'true'
run: npm ci
- name: Audit used licences
run: npm run audit:licences
- name: Fix format
run: npm run format:fix --workspace ${{ env.WORKSPACE }}
- name: Check format
run: npm run format:check --workspace ${{ env.WORKSPACE }}
- name: Fix lint
run: npm run lint:fix --workspace ${{ env.WORKSPACE }}
- name: Lint
run: npm run lint:check --workspace ${{ env.WORKSPACE }}
- name: Check types
run: npm run typecheck --workspace ${{ env.WORKSPACE }}
- name: Run unit tests
run: npm test --workspace ${{ env.WORKSPACE }}
- name: Cache Playwright dependencies
id: cache-playwright-deps
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-${{ inputs.package }}-playwright-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ inputs.package }}-playwright-
- name: Install E2E & A11y test dependencies
if: inputs.shouldRunIntegrationTests && (inputs.nightlyTests || steps.cache-playwright-deps.outputs.cache-hit == 'false')
run: npx --yes playwright install --with-deps
- name: Run nightly E2E tests
if: inputs.shouldRunIntegrationTests && inputs.nightlyTests
id: e2e-nightly
run: npm run test:e2e-nightly --workspace ${{ env.WORKSPACE }}
- name: Run E2E tests
if: inputs.shouldRunIntegrationTests && !inputs.nightlyTests
id: e2e
run: npm run test:e2e --workspace ${{ env.WORKSPACE }}
- uses: actions/upload-artifact@v4
if: failure() && (steps.e2e.outcome == 'failure' || steps.e2e-ci.outcome == 'failure')
with:
name: ${{ inputs.package }}-playwright-e2e-test-results
path: packages/${{ inputs.package }}/tests/playwright-report
- name: Run nightly A11Y tests
if: inputs.shouldRunIntegrationTests && inputs.nightlyTests
id: a11y-nightly
run: npm run test:a11y-nightly --workspace ${{ env.WORKSPACE }}
env:
# Use a different port (from the one used with E2E tests) to workaround problem in CI/GitHub Actions,
# starting to occur with playwright/test 1.28.0:
# Error: http://localhost:4173 is already used ...
# See https://github.com/digitalservicebund/typescript-vite-application-template/actions/runs/3486985178/jobs/5834089375
VITE_PORT: 4183
- name: Run A11y tests
if: inputs.shouldRunIntegrationTests && !inputs.nightlyTests
id: a11y
run: npm run test:a11y --workspace ${{ env.WORKSPACE }}
env:
VITE_PORT: 4183
- uses: actions/upload-artifact@v4
if: failure() && (steps.a11y.outcome == 'failure' || steps.a11y-ci.outcome == 'failure')
with:
name: playwright-a11y-test-results
path: packages/${{ inputs.package }}/tests/a11y/playwright-report
- name: Send failure to Slack
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: failure()
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}