Skip to content

Cover the zero-file mooc submission restore in the integration tier #352

Cover the zero-file mooc submission restore in the integration tier

Cover the zero-file mooc submission restore in the integration tier #352

Workflow file for this run

name: Extension tests
on: push
permissions: read-all
jobs:
code_style:
name: Code style
permissions:
contents: read
env:
CI: true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.0
- name: Setup Node & pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint (oxlint)
run: pnpm run lint:ci
- name: Format check (oxfmt)
run: pnpm run format:check
- name: Typecheck (tsgo)
run: pnpm run typecheck
- name: Langs schema drift (generate:langs-schema)
run: |
pnpm run generate:langs-schema
git diff --exit-code -- shared/generated shared/bindings.schema.json
# The mooc mock's vendored OpenAPI spec is copied from secret-project-331,
# which CI has no checkout of, so it cannot re-vendor here. Instead assert
# the vendored spec still matches its committed provenance stamp
# (sha256 recorded at vendoring time) -- catches a hand-edit of the
# vendored spec that never went through `pnpm run vendor:langs-openapi`.
- name: Vendored OpenAPI spec stamp
run: pnpm run vendor:langs-openapi -- --check-stamp
unit_tests:
name: Unit tests
permissions:
contents: read
env:
CI: true
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.0
- name: Setup Node & pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# The vitest unit + webview-component tiers mock `vscode` and run in
# Node/jsdom, so they need neither a VS Code download nor xvfb.
- name: Unit tests (vitest)
run: pnpm test
mock_backend_tests:
name: Mooc mock backend tests
permissions:
contents: read
env:
CI: true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.0
- name: Setup Node & pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# These node:test suites check the mooc mock in `backend/mooc` against the
# vendored OpenAPI spec, so they are what stops it drifting from the real
# courses.mooc.fi API that every other mooc test tier trusts it to imitate.
# They talk to nothing but themselves: no submodules, no `backend` setup,
# no VS Code download, no xvfb.
#
# Run from `backend/` rather than via `pnpm --filter`: a filter that
# matches no package exits 0 with only a "No projects matched" line, and
# `node --test` likewise exits 0 when its glob matches no files. Asserting
# a non-zero pass count catches both. `set -euo pipefail` is what keeps a
# real test failure propagating through the `tee` instead of being
# overwritten by the exit code of the grep that follows it.
- name: Mock backend tests (node:test)
working-directory: backend
run: |
set -euo pipefail
pnpm test 2>&1 | tee "$RUNNER_TEMP/mock-backend-tests.log"
grep -Eq '^(ℹ|#) pass [1-9][0-9]*$' "$RUNNER_TEMP/mock-backend-tests.log"
integration_tests:
name: Integration tests
permissions:
contents: read
env:
CI: true
strategy:
# A platform-specific failure must not cancel the other two, or their real
# state is unknown on exactly the runs where it matters.
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.0
with:
submodules: "true"
- name: Setup Node & pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup backend
run: |
cd backend
pnpm run setup
chmod -R +x cli
cd ..
# The integration tier drives the real tmc-langs CLI inside the VS Code
# extension host (test-electron), so it keeps xvfb on Linux. The suite
# spawns the bundled mock backend itself; `pretest:integration` builds
# the extension + integration bundle.
- name: Integration tests (test-electron)
uses: coactions/setup-xvfb@v1.0.1
with:
run: pnpm run test:integration
playwright_tests:
name: Playwright tests
permissions:
contents: read
env:
CI: true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.0
with:
submodules: "true"
- name: Setup Node & pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Setup
run: |
pnpm install --frozen-lockfile
cd backend
pnpm run setup
chmod -R +x cli
cd ..
pnpm run pretest:integration
- name: Start backend
run: pnpm run backend:start &
- name: Playwright tests
run: pnpm run playwright-test
- uses: actions/upload-artifact@v4.4.0
if: failure()
with:
name: test-results
path: ./test-results/
if-no-files-found: ignore
- uses: actions/upload-artifact@v4.4.0
if: failure()
with:
name: playwright-html-report
path: ./playwright-report/index.html
if-no-files-found: ignore