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 checks: write # Needed to report test results pull-requests: write # Needed to add comments/annotations to PRs 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 - name: Cache root dependencies uses: actions/cache@v4 id: root-cache with: path: node_modules key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} - name: Cache webview-ui dependencies uses: actions/cache@v4 id: webview-cache with: path: webview-ui/node_modules key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }} - name: Install root dependencies if: steps.root-cache.outputs.cache-hit != 'true' run: npm ci - name: Install webview-ui dependencies if: steps.webview-cache.outputs.cache-hit != 'true' run: cd webview-ui && npm ci - name: Run Quality Checks (Parallel) run: npm run ci:check-all test: needs: quality-checks 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 - name: Cache root dependencies uses: actions/cache@v4 id: root-cache with: path: node_modules key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} - name: Cache webview-ui dependencies uses: actions/cache@v4 id: webview-cache with: path: webview-ui/node_modules key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }} - name: Install root dependencies if: steps.root-cache.outputs.cache-hit != 'true' run: npm ci - name: Install webview-ui dependencies if: steps.webview-cache.outputs.cache-hit != 'true' 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" # 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: npm run test:integration - name: Webview Tests with Coverage id: webview_tests if: ${{ !cancelled() && steps.build_step.outcome == 'success' }} run: | cd webview-ui npm run test:coverage - 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 - name: Cache root dependencies uses: actions/cache@v4 id: root-cache with: path: node_modules key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} - name: Cache webview-ui dependencies uses: actions/cache@v4 id: webview-cache with: path: webview-ui/node_modules key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }} # Cache testing-platform dependencies - name: Cache testing-platform dependencies uses: actions/cache@v4 id: testing-platform-cache with: path: testing-platform/node_modules key: ${{ runner.os }}-npm-testing-platform-${{ hashFiles('testing-platform/package-lock.json') }} - name: Install root dependencies if: steps.root-cache.outputs.cache-hit != 'true' run: npm ci - name: Install webview-ui dependencies if: steps.webview-cache.outputs.cache-hit != 'true' run: cd webview-ui && npm ci - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.24' cache-dependency-path: cli/go.sum - name: Build CLI binaries run: npm run compile-cli-all-platforms - name: Download ripgrep binaries run: npm run download-ripgrep - name: Compile NPM package run: npm run compile-standalone-npm - name: Install testing platform dependencies if: steps.testing-platform-cache.outputs.cache-hit != 'true' run: cd testing-platform && npm ci - name: Running testing platform integration spec tests continue-on-error: true timeout-minutes: 7 # Temporarily wrapping the test command to always return a neutral exit code. # This prevents the job from showing as failed and avoids distracting developers # until the integration tests are ready to be enforced. run: | npm run test:tp-orchestrator -- tests/specs/ --count=1 --coverage || true - 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