ci: added sonar action and separated e2e action from the rest #58
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
webview-ui/build | |
webview-ui/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 | |
- name: Install Mocha reporters | |
run: npm install -d mocha-multi-reporters mocha-junit-reporter mocha-sonarqube-reporter | |
if: runner.os == 'Linux' && matrix.node-version == '22.x' | |
- name: create mocha config | |
run: | | |
echo '{ | |
"reporterEnabled": "spec, mocha-junit-reporter, mocha-sonarqube-reporter" | |
}' > config.json | |
if: runner.os == 'Linux' && matrix.node-version == '22.x' | |
- run: xvfb-run -a npm test | |
if: runner.os == 'Linux' && matrix.node-version != '22.x' | |
- run: npm test | |
if: runner.os != 'Linux' | |
- 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 | |
if: runner.os == 'Linux' && matrix.node-version == '22.x' | |
- name: Upload coverage as artifact | |
uses: actions/upload-artifact@v4 | |
if: runner.os == 'Linux' && matrix.node-version == '22.x' | |
with: | |
name: coverage | |
path: coverage/lcov.info | |
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: Restore cached node_modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
webview-ui/build | |
webview-ui/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 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 | |
webview-ui/build | |
webview-ui/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: Download node_modules artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage | |
path: coverage/lcov.info | |
- name: exists coverage | |
run: ls -R coverage | |
- 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 | |
-Dsonar.tests=src/test |