-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (78 loc) · 2.72 KB
/
check-nest-test-sonarcloud.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
name: 'Check - Tests & Sonarcloud'
on:
workflow_call:
inputs:
node_version:
type: string
description: "Version to use for node"
required: true
deploy_stage:
type: string
description: "Deployment stage (Some tests need this varaible)"
default: ""
required: false
node_heap_size:
type: number
description: "Heap Size for node in MB"
required: false
default: 4096
skip_tests:
type: boolean
description: "Skip running the tests and just scan with sonarcloud"
required: false
default: false
timeout_minutes:
type: number
description: "Timout in minutes"
required: false
default: 10
env:
NODE_VERSION: ${{ inputs.node_version }} # needed for npm test
NODE_OPTIONS: "--max-old-space-size=${{ inputs.node_heap_size }}"
DEPLOY_STAGE: ${{ inputs.deploy_stage }}
jobs:
tests_sonarcloud:
name: Tests and Sonarcloud
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: ${{ inputs.timeout_minutes }}
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Docker check
run: docker --version
- name: Inject Secrets
uses: timheuer/base64-to-file@784a1a4a994315802b7d8e2084e116e783d157be #v1.2.4
with:
fileName: 'secrets.json'
fileDir: './config/'
# These are placeholder secrets without any significance
encodedString: ewogICAgIkRCIjogewogICAgICAgICJTRUNSRVQiOiAiVmVyeSBoaWRkZW4gc2VjcmV0IgogICAgfSwKICAgICJLRVlDTE9BSyI6IHsKICAgICAgICAiQURNSU5fU0VDUkVUIjogIkNsaWVudCBTZWNyZXQiCiAgICB9Cn0=
- name: Setup node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 #v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci --prefer-offline --no-audit
- name: Run tests
if: ${{ !inputs.skip_tests }}
run: npm run test:ci
- name: Save test artifacts
if: ${{ !inputs.skip_tests }}
run: |
mkdir -p coverage
mv ./coverage artifacts
- name: Upload test artifacts
if: ${{ !inputs.skip_tests }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 #v4.3.1
with:
name: test-artifacts
path: artifacts/
- name: SonarCloud upload
uses: SonarSource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 #v2.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}