name: Tests on: push: branches: - main workflow_dispatch: pull_request: branches: - main workflow_call: # Set default permissions for all jobs permissions: contents: read # Needed to check out code jobs: quality-checks: runs-on: ubuntu-latest name: Quality Checks steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment uses: actions/setup-node@v4 with: node-version: 22 cache: 'npm' cache-dependency-path: | package-lock.json webview-ui/package-lock.json - name: Install root dependencies run: npm ci env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install webview-ui dependencies run: cd webview-ui && npm ci - name: Run Quality Checks (Parallel) run: npm run ci:check-all test: needs: quality-checks env: VSCODE_TEST_VERSION: 1.103.0 strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} name: ${{ matrix.os == 'ubuntu-latest' && 'test' || format('test ({0})', matrix.os) }} defaults: run: shell: bash steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment uses: actions/setup-node@v4 with: node-version: 22 cache: 'npm' cache-dependency-path: | package-lock.json webview-ui/package-lock.json - name: Install root dependencies run: npm ci env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install webview-ui dependencies run: cd webview-ui && npm ci - name: Set up NPM on Windows if: runner.os == 'Windows' run: | npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe" - name: Cache VS Code test runtime if: runner.os == 'Windows' uses: actions/cache@v4 with: path: .vscode-test key: vscode-test-runtime-${{ runner.os }}-${{ env.VSCODE_TEST_VERSION }} # Build the extension and tests (without redundant checks) - name: Build Tests and Extension id: build_step run: npm run ci:build - name: Unit Tests with coverage - Linux id: unit_tests_linux if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }} run: | npx nyc --nycrc-path .nycrc.unit.json --reporter=lcov npm run test:unit - name: Unit Tests - Non-Linux id: unit_tests_non_linux if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }} run: | npm run test:unit - name: Extension Integration Tests - Linux id: integration_tests_linux if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }} run: xvfb-run -a npm run test:coverage - name: Extension Integration Tests - Non-Linux id: integration_tests_non_linux if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }} run: | for attempt in 1 2 3; do echo "Running extension integration tests (attempt ${attempt}/3)" if npm run test:integration; then exit 0 fi if [ "$attempt" -eq 3 ]; then echo "Extension integration tests failed after 3 attempts" exit 1 fi echo "Extension integration tests failed; retrying after short delay" sleep 5 done - name: Webview Tests with Coverage id: webview_tests if: ${{ !cancelled() && steps.build_step.outcome == 'success' }} run: | cd webview-ui npm run test:coverage - name: CLI Tests id: cli_tests if: ${{ !cancelled() && steps.build_step.outcome == 'success' }} run: cd cli && npm run test:run - name: Save Coverage Reports uses: actions/upload-artifact@v4 # Only upload artifacts on Linux - We only need coverage from one OS if: runner.os == 'Linux' with: name: pr-coverage-reports path: | coverage-unit/lcov.info webview-ui/coverage/lcov.info test-platform-integration: needs: quality-checks runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment uses: actions/setup-node@v4 with: node-version: 22 cache: 'npm' cache-dependency-path: | package-lock.json webview-ui/package-lock.json testing-platform/package-lock.json - name: Install root dependencies run: npm ci env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install webview-ui dependencies run: cd webview-ui && npm ci - name: Download ripgrep binaries run: npm run download-ripgrep - name: Compile Standalone run: npm run compile-standalone - name: Install testing platform dependencies run: cd testing-platform && npm ci - name: Running testing platform integration spec tests timeout-minutes: 7 run: npm run test:tp-orchestrator -- tests/specs/ --count=1 --coverage - name: Save Coverage Reports uses: actions/upload-artifact@v4 with: name: test-platform-integration-core-coverage path: coverage/**/lcov.info qlty: needs: [test, test-platform-integration] runs-on: ubuntu-latest # Run on PRs to main, pushes to main, and manual dispatches steps: - name: Checkout code uses: actions/checkout@v4 - name: Download unit tests coverage reports uses: actions/download-artifact@v4 with: name: pr-coverage-reports path: . - name: Upload core unit tests coverage to Qlty uses: qltysh/qlty-action/coverage@v2 with: token: ${{ secrets.QLTY_COVERAGE_TOKEN }} # we can merge multiple files if necessary files: | coverage-unit/lcov.info tag: unit:core - name: Upload webview-ui unit tests coverage to Qlty uses: qltysh/qlty-action/coverage@v2 with: token: ${{ secrets.QLTY_COVERAGE_TOKEN }} # we can merge multiple files if necessary files: | webview-ui/coverage/lcov.info tag: unit:webview-ui add-prefix: webview-ui/ - name: Download test platform integration core coverage artifact uses: actions/download-artifact@v4 continue-on-error: true id: download-integration-coverage with: name: test-platform-integration-core-coverage path: integration-core-coverage-reports - name: Upload core integration tests coverage to Qlty if: steps.download-integration-coverage.outcome == 'success' uses: qltysh/qlty-action/coverage@v2 with: token: ${{ secrets.QLTY_COVERAGE_TOKEN }} files: integration-core-coverage-reports/**/lcov.info tag: integration:core