-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (69 loc) · 2.49 KB
/
nodejs.yml
File metadata and controls
78 lines (69 loc) · 2.49 KB
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
name: Build Project
on:
push:
branches: ["main"]
pull_request:
jobs:
build:
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Cache node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
node_modules-${{ matrix.os }}-node-${{ matrix.node-version }}
- name: Run clean install
run: npm ci --ignore-scripts
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
sonar:
name: Run eslint and sonar scanning
runs-on: ubuntu-latest
needs: build
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22.x
- name: Restore cached node_modules
uses: actions/cache@v5
with:
path: node_modules
key: node_modules-ubuntu-latest-node-22.x-${{ hashFiles('package-lock.json') }}
restore-keys: |
node_modules-ubuntu-latest-node-22.x
- name: Run ESLint
run: npm run lint -- --format json --output-file eslint-results.json || true
- name: create mocha config
run: |
echo '{
"reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter"
}' > config.json
- name: Run tests with coverage
run: xvfb-run -a npm test -- --coverage --coverage-output ./coverage --coverage-reporter lcovonly --reporter mocha-multi-reporters --reporter-options configFile=config.json
- name: Analyze with SonarCloud
uses: SonarSource/sonarqube-scan-action@7006c4492b2e0ee0f816d36501671557c97f5995
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: -Dsonar.projectKey=aditosoftware_vscode-input
-Dsonar.organization=aditosoftware
-Dsonar.eslint.reportPaths=eslint-results.json
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info