-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (147 loc) · 5.52 KB
/
frontend-jobs.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
on:
workflow_call:
inputs:
container-registry:
required: true
type: string
container-image-name:
required: true
type: string
container-image-version:
required: true
type: string
jobs:
check-style-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Cache npm cache
uses: actions/cache@v4
id: cache-npm-cache
with:
# The docs discourage caching `node-modules`, cf. https://github.com/actions/cache/blob/main/examples.md#node---npm
path: /home/runner/.npm
key: npm-cache-${{ hashFiles('./frontend/package-lock.json') }}
- name: Install node modules
run: npm ci
working-directory: ./frontend
- name: Check style
run: npm run style:check
working-directory: ./frontend
- name: Send status to Slack
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
test-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Cache npm cache
uses: actions/cache@v4
id: cache-npm-cache
with:
# The docs discourage caching `node-modules`, cf. https://github.com/actions/cache/blob/main/examples.md#node---npm
path: /home/runner/.npm
key: npm-cache-${{ hashFiles('./frontend/package-lock.json') }}
- name: Install node modules
run: npm ci
working-directory: ./frontend
- name: Run tests
run: npm run test
working-directory: ./frontend
- name: Send status to Slack
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
analyze-frontend-with-sonar-cube:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Cache npm cache
uses: actions/cache@v4
id: cache-npm-cache
with:
# The docs discourage caching `node-modules`, cf. https://github.com/actions/cache/blob/main/examples.md#node---npm
path: /home/runner/.npm
key: npm-cache-${{ hashFiles('./frontend/package-lock.json') }}
- name: Install node modules
run: npm ci
working-directory: ./frontend
- name: Install SonarScanner
uses: digitalservicebund/setup-sonarscanner@3ade23691f865c02dce6b46452947a0e7944196e # v1.0.0
- name: Scan with SonarQube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
npm run coverage
sonar-scanner
working-directory: ./frontend
- name: Check SonarQube Quality Gate
uses: sonarsource/sonarqube-quality-gate-action@5a8df806f0c5ac1fb76a2779e927f7e38f88137f
with:
scanMetadataReportFile: frontend/.scannerwork/report-task.txt
timeout-minutes: 3
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Send status to Slack
uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
audit-licenses-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ./frontend/package.json
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Cache npm cache
uses: actions/cache@v4
id: cache-npm-cache
with:
# The docs discourage caching `node-modules`, cf. https://github.com/actions/cache/blob/main/examples.md#node---npm
path: /home/runner/.npm
key: npm-cache-${{ hashFiles('./frontend/package-lock.json') }}
- name: Install node modules
run: npm ci
working-directory: ./frontend
- name: Run license scanner
run: npm run audit:licences
working-directory: ./frontend
- name: Upload licence report
uses: actions/upload-artifact@v4
with:
name: licence-reports-frontend
retention-days: 3
path: frontend/frontend-licence-report.csv
- name: Send status to Slack
uses: digitalservicebund/notify-on-failure-gha@66c485757701f8d5dbee32f24df38d904ca693ba
if: ${{ failure() && github.ref == 'refs/heads/main' }}
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}