Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
python-tests:
name: Python tests
runs-on: ubuntu-latest
# Safety net: fail fast instead of burning the default 6h runner budget
# if a test ever hangs (e.g. a stuck subprocess) rather than failing.
timeout-minutes: 15
steps:
- uses: actions/checkout@v7

Expand All @@ -30,11 +33,23 @@ jobs:
run: uv sync

- name: Run Python tests
run: uv run pytest src/test/python_tests -v
run: uv run pytest src/test/python_tests -v --cov=bundled/tool --cov-report=term-missing

- name: Generate Python coverage LCOV report
run: uv run coverage lcov

- name: Report Python coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
flag-name: python
format: lcov
file: .coverage/python/lcov.info
parallel: true

extension-tests:
name: Extension (TypeScript) tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7

Expand Down Expand Up @@ -66,5 +81,24 @@ jobs:

- name: Run extension tests
# @vscode/test-electron launches a real (headless) VS Code instance,
# which needs a virtual display on Linux runners.
run: xvfb-run -a pnpm test
# which needs a virtual display on Linux runners. test:coverage runs
# the same suite as `pnpm test`, instrumented with c8.
run: xvfb-run -a pnpm run test:coverage

- name: Report TypeScript coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
flag-name: typescript
format: lcov
file: .coverage/typescript/reports/lcov.info
parallel: true

coveralls-finish:
name: Finish Coveralls build
needs: [python-tests, extension-tests]
if: always()
runs-on: ubuntu-latest
steps:
- uses: coverallsapp/github-action@v2
with:
parallel-finished: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ node_modules
bundled/libs/
**/__pycache__
**/.pytest_cache
**/.vs
**/.vs

# Coverage output (opt-in, see `pnpm run test:coverage` / `pytest --cov`)
.coverage/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
- Removed unused `nox` dependency
- Improved test infrastructure: fixed and expanded Python tests, added Typescript extension tests (using Mocha + `@vscode/test-electron`), and added GitHub Actions workflow to run tests
- Removed unused glob pattern `'build/**/*.yml'` from `package.json` `format-check` command
- Added test coverage tracking
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ it as `xvfb-run -a pnpm test`.
Both test suites also run automatically in CI on every pull request and push to `main`; see
`.github/workflows/test.yml`.

#### Coverage

Coverage is opt-in and not part of the default test commands above. Both sides write their
reports under a single `.coverage/` directory (gitignored).

For Python, add `--cov` to the normal `pytest` invocation, e.g.
`uv run pytest src/test/python_tests --cov=bundled/tool --cov-report=term-missing` (add
`--cov-report=html` for an HTML report at `.coverage/python/html/index.html`). This also measures
coverage inside the LSP server subprocess that the test client spawns, not just the test process
itself.

For the extension's TypeScript tests, run `pnpm run test:coverage`. This runs the same suite as
`pnpm test` under [c8](https://github.com/bcoe/c8) and writes a report to
`.coverage/typescript/reports/index.html` (a text summary is also printed to the console).

In CI, both suites run with coverage enabled and upload their results to
[Coveralls](https://coveralls.io) as a single combined build (one job per language, reported
under separate flags, merged in a final job); see `.github/workflows/test.yml`. This requires the
repository to be enabled on Coveralls; no extra secrets are needed for public GitHub repos using
Coveralls' GitHub App integration, but a private repo (or one not using that integration) will
need a `COVERALLS_REPO_TOKEN` secret set and passed via `github-token:`/`repo-token:` in the
workflow.

## Linting

To lint the Typescript code, run `pnpm run lint`.
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"format-check": "prettier --check src/**/*.ts .github/**/*.yml",
"format": "prettier --write src/**/*.ts .github/**/*.yml",
"test": "node ./out/test/runTest.js",
"pretest:coverage": "pnpm run compile-tests",
"test:coverage": "node scripts/run-coverage.js",
"vsce-package": "vsce package -o python-ta.vsix"
},
"contributes": {
Expand Down Expand Up @@ -165,6 +167,7 @@
"@typescript-eslint/parser": "^8.65.0",
"@vscode/test-electron": "^3.1.0",
"@vscode/vsce": "^3.7.1",
"c8": "^12.0.0",
"eslint": "^10.3.0",
"glob": "^13.0.6",
"mocha": "^11.8.0",
Expand Down
Loading