name: ext-vscode-test-e2e on: push: branches: - main pull_request: types: [opened, reopened, synchronize, ready_for_review] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true permissions: contents: read pull-requests: read jobs: detect-changes: runs-on: ubuntu-latest name: Detect Changes outputs: e2e: ${{ steps.force.outputs.run_all == 'true' || steps.filter.outputs.e2e == 'true' }} steps: - id: force if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' run: echo "run_all=true" >> "$GITHUB_OUTPUT" - uses: actions/checkout@v4 if: steps.force.outputs.run_all != 'true' - uses: dorny/paths-filter@v3 if: steps.force.outputs.run_all != 'true' id: filter with: filters: | e2e: - 'apps/vscode/src/**' - 'apps/vscode/webview-ui/**' - 'apps/vscode/proto/**' - 'apps/vscode/tests/**' - 'apps/vscode/scripts/**' - 'apps/vscode/standalone/**' - 'apps/vscode/assets/**' - 'apps/vscode/walkthrough/**' - 'apps/vscode/package.json' - 'apps/vscode/webview-ui/package.json' # Root bun lockfile is authoritative for the whole workspace (incl. apps/vscode). - 'bun.lock' # SDK source packages are local workspace symlinks (@cline/*), so SDK changes affect the build. - 'sdk/packages/**' - 'apps/vscode/buf.yaml' - 'apps/vscode/tsconfig*.json' - 'apps/vscode/biome.jsonc' - 'apps/vscode/esbuild.mjs' - 'apps/vscode/bunfig.toml' - 'apps/vscode/.vscode-test.mjs' - 'apps/vscode/playwright*.ts' - '.github/workflows/ext-vscode-test-e2e.yml' matrix_prep: needs: detect-changes if: needs.detect-changes.outputs.e2e == 'true' runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - id: set-matrix run: | echo 'matrix=[{"runner":"ubuntu"},{"runner":"windows"},{"runner":"macos"}]' >> $GITHUB_OUTPUT e2e: needs: [detect-changes, matrix_prep] if: needs.detect-changes.outputs.e2e == 'true' strategy: fail-fast: false matrix: include: ${{ fromJson(needs.matrix_prep.outputs.matrix) }} runs-on: ${{ matrix.runner }}-latest timeout-minutes: 20 # Nothing in this job uses OIDC, so it does not need an id-token # permission. permissions: contents: read defaults: run: working-directory: apps/vscode steps: - uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: "1.4.2" # Bun's install cache is not cached. On every runner, restoring it # and then installing took about as long as installing without it, # as ext-vscode-test does. # Cache VS Code installation. The key is exact-match only (no # restore-keys prefix fallbacks); a miss just downloads VS Code. - name: Cache VS Code uses: actions/cache@v4 id: vscode-cache with: path: apps/vscode/.vscode-test key: vscode-${{ runner.os }}-stable-${{ hashFiles('apps/vscode/.vscode-test.mjs', 'apps/vscode/package.json') }} # Single root install resolves the entire bun workspace at once (replaces # the per-package `npm ci` steps for apps/vscode + webview-ui). - name: Install workspace dependencies working-directory: ${{ github.workspace }} run: bun install --frozen-lockfile env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # @cline/* are local workspace symlinks to source packages; build dist/ # before building the extension for E2E. - name: Build SDK packages working-directory: ${{ github.workspace }} run: bun run build:sdk - name: Assert better-sqlite3 native binary present # Force bash: the Windows runner defaults to pwsh, which can't parse this # POSIX test. Git Bash ships on GitHub's windows-latest images. shell: bash run: | NODE_FILE="node_modules/better-sqlite3/build/Release/better_sqlite3.node" if [ ! -f "$NODE_FILE" ]; then echo "ERROR: better-sqlite3 native binary missing at apps/vscode/$NODE_FILE" echo "(bun trustedDependencies postinstall likely did not run)" exit 1 fi echo "Found better-sqlite3 native binary: $NODE_FILE" - name: Install xvfb on Linux if: matrix.runner == 'ubuntu' run: sudo apt-get update && sudo apt-get install -y xvfb # Type checks and lint run in ext-vscode-test's Quality Checks job; # test:e2e builds the extension without them. - name: Run E2E tests - Linux if: matrix.runner == 'ubuntu' run: xvfb-run -a bun run test:e2e - name: Run E2E tests - Non-Linux if: matrix.runner != 'ubuntu' run: bun run test:e2e # Repo-root relative: the job's `working-directory` default applies to `run` # steps only, so an apps/vscode-relative path here silently matches nothing # and every failing run uploads no recordings at all. - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: playwright-recordings-${{ matrix.runner }} path: | apps/vscode/test-results/