Repository navigation
Add backend test coverage support with c8 and CI integration #1893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,5 @@ node_modules | |
| */node_modules | ||
| .env | ||
| .development.env | ||
| coverage | ||
| */coverage | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "all": true, | ||
| "src": ["src"], | ||
| "include": ["src/**/*.ts"], | ||
| "exclude": ["src/main.ts", "src/migrations/**", "src/**/*.spec.ts", "src/**/*.d.ts"], | ||
| "exclude-after-remap": true, | ||
| "reporter": ["text-summary", "lcov", "json-summary"], | ||
| "reports-dir": "coverage" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,5 +3,25 @@ | |||||
| # DynamoDB, ClickHouse, Elasticsearch) are excluded so their heavy containers | ||||||
| # aren't needed. Pass an explicit glob to run a different subset locally, e.g. | ||||||
| # just test 'test/ava-tests/non-saas-tests/*mongo*.test.ts' | ||||||
| test args='test/ava-tests/non-saas-tests/!(*oracle*|*cassandra*|*elasticsearch*|*mssql*|*mongo*|*redis*|*dynamodb*|*clickhouse*).test.ts': | ||||||
| default_tests := 'test/ava-tests/non-saas-tests/!(*oracle*|*cassandra*|*elasticsearch*|*mssql*|*mongo*|*redis*|*dynamodb*|*clickhouse*).test.ts' | ||||||
|
|
||||||
| test args=default_tests: | ||||||
| EXTRA_ARGS="{{args}}" docker compose -f docker-compose.tst.yml up --abort-on-container-exit --force-recreate --build --attach=backend --no-log-prefix | ||||||
|
|
||||||
| # Coverage: TEST_SCRIPT switches the container to the package's | ||||||
| # test-all-parallel:coverage script (same suite under c8, backend/.c8rc.json). | ||||||
| # The report — coverage-summary.json, lcov.info, lcov-report/ — is copied out of | ||||||
| # the stopped backend container to backend/coverage/; only those items, because | ||||||
| # coverage/tmp (raw V8 dumps) runs to ~1 GB. The suite's exit status is kept. | ||||||
|
|
||||||
| # `just test` under c8; report copied out to backend/coverage/ (what CI runs) | ||||||
| test-coverage args=default_tests: | ||||||
| #!/usr/bin/env bash | ||||||
| set -uo pipefail | ||||||
| TEST_SCRIPT=test-all-parallel:coverage EXTRA_ARGS="{{args}}" docker compose -f docker-compose.tst.yml up --abort-on-container-exit --force-recreate --build --attach=backend --no-log-prefix | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Return the backend test exit code. If AVA fails but c8 writes all three reports, the copy steps can succeed. Proposed change--- "a/justfile"
+++ "b/justfile"
@@ -18,7 +18,7 @@
test-coverage args=default_tests:
#!/usr/bin/env bash
set -uo pipefail
- TEST_SCRIPT=test-all-parallel:coverage EXTRA_ARGS="{{args}}" docker compose -f docker-compose.tst.yml up --abort-on-container-exit --force-recreate --build --attach=backend --no-log-prefix
+ TEST_SCRIPT=test-all-parallel:coverage EXTRA_ARGS="{{args}}" docker compose -f docker-compose.tst.yml up --exit-code-from backend --force-recreate --build --attach=backend --no-log-prefix
status=$?
rm -rf backend/coverage && mkdir -p backend/coverage
for item in coverage-summary.json lcov.info lcov-report; do📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| status=$? | ||||||
| rm -rf backend/coverage && mkdir -p backend/coverage | ||||||
| for item in coverage-summary.json lcov.info lcov-report; do | ||||||
| docker compose -f docker-compose.tst.yml cp "backend:/app/backend/coverage/$item" "backend/coverage/$item" || status=1 | ||||||
| done | ||||||
| exit "$status" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Prevent older runs from replacing the current badge.
If two pushes to
mainrun tests at different speeds, the older run can reachcoverage-badgeafter the newer run. This concurrency group does not guarantee commit order. The older run can then force-push an outdated badge and summary. Before the push, compareGITHUB_SHAwith the current tip ofmain; skip publication if they differ. (docs.github.com)🧰 Tools
🪛 zizmor (1.30.1)
[warning] 1-93: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents