diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 76b465a..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: ESLint - -on: - pull_request: - -jobs: - eslint: - name: Run eslint scanning - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: npm ci - - - name: Run ESLint - run: npm run lint diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 07f155c..c72c014 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -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 @@ -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' @@ -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