-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (116 loc) · 4.73 KB
/
nodejs.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
name: Build Project
on:
pull_request:
jobs:
build:
strategy:
matrix:
# No windows runner, because in this extension, we have a lot of tests that need docker in the WSL.
# Sadly, the setup-wsl (https://github.com/Vampire/setup-wsl) and the current windows runners only support WSL 1.
# Therefore, we can not install and start a docker container in the WSL.
# Currently, no macOS runner, because during the setup of docker, this runner hangs: https://github.com/douglascamata/setup-docker-macos-action/issues/37
os: [ubuntu-latest]
node-version: [18.x, 20.x, 22.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Set up JDK for Liquibase CLI
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Check Docker Version
run: docker --version
- name: Check npm versions
run: npm -v
- name: Cache node_modules
uses: actions/cache@v4
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
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
e2e-tests:
needs: build
strategy:
matrix:
# No windows runner, because in this extension, we have a lot of tests that need docker in the WSL.
# Sadly, the setup-wsl (https://github.com/Vampire/setup-wsl) and the current windows runners only support WSL 1.
# Therefore, we can not install and start a docker container in the WSL.
# Currently, no macOS runner, because during the setup of docker, this runner hangs: https://github.com/douglascamata/setup-docker-macos-action/issues/37
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Set up JDK for Liquibase CLI
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: run e2e tests
run: xvfb-run -a npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }}
if: runner.os == 'Linux'
- name: npm e2e tests
run: npm run test:e2e -- --storage ./out/test-resources/${{ matrix.os }}/${{ matrix.node-version }}
if: runner.os != 'Linux'
- name: "Upload e2e screenshots"
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-screenshots-${{ matrix.os }}-${{ matrix.node-version }}
path: ./out/test-resources/**/screenshots/**
retention-days: 5
if-no-files-found: ignore
sonar:
name: Run eslint and sonar scanning
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Restore cached node_modules
uses: actions/cache@v4
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: Install Mocha reporters
run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter
- 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/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: -Dsonar.projectKey=aditosoftware_vscode-liquibase
-Dsonar.organization=aditosoftware
-Dsonar.eslint.reportPaths=eslint-results.json
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info