-
-
Notifications
You must be signed in to change notification settings - Fork 4
174 lines (156 loc) · 5.28 KB
/
CI.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
on:
push:
branches: [ main ]
pull_request:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
prepare:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: generate lock files
run: npm i
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- name: generate tests datas
run: |
npm run generate:data
npm list > dependencies.list
- uses: actions/upload-artifact@v3
with:
name: prepare
path: |
./dependencies.list
./package-lock.json
./tests/datas
# This workflow contains a single job called "build"
build:
permissions:
checks: write
needs: [prepare]
# The type of runner that the job will run on
runs-on: ubuntu-latest
# do a matrix test with different node versions
strategy:
fail-fast: false
matrix:
node-version: [ lts/*, 16 ]
#can't test on 5.6.42 because database is too up-to-date ( 5.12.72 )
unifi-version: [ latest, 7.3.83, 7.2.95, 7.1.68, 7.0.25, 6.5.55, 6.4.54, version-6.2.26, version-6.0.45 ]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: prepare
path: .
# try to perform a nodejs setup
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
# - name: install+run docker-unifi-controller
# run: |
# # install our own demo database
# mkdir unifi-storage
# sudo tar -C unifi-storage -xf $GITHUB_WORKSPACE/.github/workflows/db-demo-dump.tar.bz2
# # create docker-unifi-controller
# docker create --name=unifi-controller -e PUID=1001 -e PGID=116 -p 8443:8443 -v $GITHUB_WORKSPACE/unifi-storage:/config linuxserver/unifi-controller:${{ matrix.unifi-version }}
# docker start unifi-controller
# # wait for unifi-controller to be ready
# while ! curl -ks https://127.0.0.1:8443; do echo waiting for unifi-controller; sleep 2; done
# echo unifi-controller answer
- name: npm install, build, and test
run: |
npm install
npm run build
echo start tests
npm run test:CI:coverage
env:
CI: true
- uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true
with:
test-command: npm run test:CI:coverage
coverage-comment: false
- name: replace path in coverage files
run: find ./coverage -type f -exec sed -i -e "s@$(pwd)@<root>@g" {} \;
if: always()
- uses: actions/upload-artifact@v3
with:
name: coverage
path: |
./coverage/clover.xml
./coverage/coverage-final.json
./coverage/lcov.info
./coverage/junit.xml
./coverage/test-report.xml
if: always()
eslint:
name: eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install eslint
run: npm install
- name: run eslint
run: |
echo start eslint
mkdir coverage
npm run ci:eslint
continue-on-error: true
env:
CI: true
- name: replace path in coverage files
run: find ./coverage -type f -exec sed -i -e "s@$(pwd)@<root>@g" {} \;
- uses: actions/upload-artifact@v3
with:
name: coverage
path: ./coverage/eslint-report.json
send-coverage:
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: coverage
path: ./coverage/
- uses: codecov/codecov-action@v4
with:
#token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
# files: ./coverage/clover.xml # optional
fail_ci_if_error: false # optional (default = false)
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: [build, eslint]
if: always()
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@v3
with:
name: coverage
path: ./coverage/
- name: change coverage path in file
run: find ./coverage -type f -exec sed -i -e "s@<root>@/github/workspace@g" {} \;
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}