-
Notifications
You must be signed in to change notification settings - Fork 31
72 lines (63 loc) · 2.02 KB
/
unit-tests.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
name: Tests
on:
push:
branches:
- main
paths:
- 'src/**'
- 'yarn.lock'
- '.github/workflows/unit-tests.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'src/**'
- 'yarn.lock'
- '.github/workflows/unit-tests.yml'
jobs:
unit-tests:
runs-on: ubuntu-latest
name: Type-checks, eslint, unit tests and SonarCloud
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: app-frontend
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: install node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Get yarn cache directory path
working-directory: app-frontend
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: install dependencies
working-directory: app-frontend
run: yarn --immutable
- name: type-check
working-directory: app-frontend
run: yarn tsc
- name: run eslint
working-directory: app-frontend
run: yarn lint
- name: run tests
working-directory: app-frontend
run: yarn test --coverage --runInBand
- name: SonarCloud Scan
if: |
github.repository_owner == 'Altinn' &&
(github.event_name != 'pull_request' && github.event.repository.fork == false) ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)
with:
projectBaseDir: app-frontend
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}