-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (135 loc) · 3.93 KB
/
run_tests.yaml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Run tests
on:
# Enable reusing this workflow.
workflow_call:
# Run after PR is merged to main.
push:
branches:
- main
# Run for PR's. External PR's require approval before running checks.
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
build:
name: Build image
uses: ./.github/workflows/build_image.yaml
lint:
name: Lint code
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: fudis-test
path: /tmp
- name: Load image
run: docker load --input /tmp/fudis-test.image.tar
- name: Run linter
run: docker run -t fudis-test npm run lint
stylelint:
name: Lint styles
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: fudis-test
path: /tmp
- name: Load image
run: docker load --input /tmp/fudis-test.image.tar
- name: Run stylelint
run: docker run -t fudis-test npm run stylelint
formatting:
name: Check formatting
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Run prettier
run: npm run format:check
component-tests:
name: Component tests
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: fudis-test
path: /tmp
- name: Load image
run: docker load --input /tmp/fudis-test.image.tar
- name: Run unit tests
run: docker run -te CI=true fudis-test npm test
visual-regression-tests:
name: Visual regression tests
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: fudis-test
path: /tmp
- name: Load image
run: docker load --input /tmp/fudis-test.image.tar
- name: Start Storybook
run: docker run -d -p 6006:6006 fudis-test npm run storybook
- name: Build Playwright image
run: docker build -t fudis-pw test/
- name: Wait for Storybook server to be up
run: curl --head -X GET --retry 10 --retry-connrefused --retry-delay 5 http://localhost:6006
- name: Create test output directories for mounts
run: mkdir test/test-results test/playwright-report
- name: Run visual regression tests
run: |
docker run -t \
-e CI=true \
-e PLAYWRIGHT_BASE_URL=http://localhost:6006 \
--network=host \
--mount type=bind,source=./test/test-results,target=/usr/src/app/test-results \
--mount type=bind,source=./test/playwright-report,target=/usr/src/app/playwright-report \
fudis-pw
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: test/playwright-report/
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results
path: test/test-results/