Skip to content

Commit

Permalink
ci: added sonar action and separated e2e action from the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
rH4rtinger committed Oct 9, 2024
1 parent c9da951 commit d8092fd
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 24 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/lint.yml

This file was deleted.

79 changes: 76 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ jobs:
- name: Check Docker Version
run: docker --version

- name: Check Node.js version
run: node -v

- 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

Expand All @@ -45,6 +50,31 @@ jobs:
- 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'
Expand All @@ -61,3 +91,46 @@ jobs:
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

0 comments on commit d8092fd

Please sign in to comment.