Skip to content
Draft
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
55 changes: 44 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,39 @@ jobs:
- name: Symlink node_modules
run: ln -sf out/node_modules .

- name: Build, lint, and test
- name: Clear stale generated reports
run: rm -rf out/coverage out/coverage-baseline out/e2e-report

- name: Build
run: just build

- name: Lint
run: just lint

- name: Test Rust with coverage
if: github.event_name == 'pull_request'
env:
ONLINE_TESTS: "1"
run: |
just build
just lint
if [ "${{ github.event_name }}" = "pull_request" ]; then
just test --coverage
else
just test
fi
run: just test-rust --coverage

- name: Test Python with coverage
if: github.event_name == 'pull_request'
env:
ONLINE_TESTS: "1"
COVERAGE_RCFILE: tools/coverage/setup.ci.cfg
run: just test-py --coverage

- name: Test TypeScript with coverage
if: github.event_name == 'pull_request'
env:
ONLINE_TESTS: "1"
run: just test-ts --coverage

- name: Test without coverage
if: github.event_name != 'pull_request'
env:
ONLINE_TESTS: "1"
run: just test

- name: Ensure libs importable
env:
Expand All @@ -130,14 +152,25 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@v2
if: github.event_name != 'pull_request' || steps.rust-deps.outputs.any_changed == 'true'

- name: Profile CI output sizes
if: always()
shell: bash
run: |
for path in out out/coverage out/bin out/playwright-browsers; do
if [ -e "$path" ]; then
du -sh "$path"
fi
done

# out/pyenv contains a venv with absolute Python paths that break
# across runs. out/build.ninja is regenerated by configure each time.
# Remove both before saving so the cache stays portable.
# Coverage and browser reports are generated outputs, and should not be
# restored as part of the general build cache.
- name: Clean non-cacheable state
if: always()
shell: bash
run: |
rm -rf out/pyenv
rm -rf out/pyenv out/coverage out/coverage-baseline out/e2e-report
rm -f out/build.ninja

- name: Save build output cache
Expand Down
7 changes: 5 additions & 2 deletions tools/coverage/coverage-rust
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ LLVMCOVPATH="out/bin"

mkdir -p $outdir $LLVMCOVPATH
test -x $LLVMCOVPATH/cargo-llvm-cov || cargo install cargo-llvm-cov --version 0.8.4 --locked --root out
ANKI_TEST_MODE=1 $LLVMCOVPATH/cargo-llvm-cov llvm-cov --workspace --locked --json --summary-only \
--output-path $outdir/coverage-summary.json --fail-under-lines 60
test -x $LLVMCOVPATH/cargo-nextest || cargo install cargo-nextest --version 0.9.99 --locked --no-default-features --features default-no-update --root out
export PATH="$LLVMCOVPATH:$PATH"
ANKI_TEST_MODE=1 $LLVMCOVPATH/cargo-llvm-cov llvm-cov nextest --workspace --locked --json --summary-only \
--output-path $outdir/coverage-summary.json --fail-under-lines 60 \
--color=always --failure-output=final --status-level=none

if [ "$html" = "--html" ]; then
ANKI_TEST_MODE=1 $LLVMCOVPATH/cargo-llvm-cov llvm-cov report --html --output-dir $outdir/html
Expand Down
9 changes: 7 additions & 2 deletions tools/coverage/coverage-rust.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ if not exist %LLVMCOVPATH% mkdir %LLVMCOVPATH%
if not exist %LLVMCOVPATH%\cargo-llvm-cov.exe (
cargo install cargo-llvm-cov --version 0.8.4 --locked --root out || exit /b 1
)
if not exist %LLVMCOVPATH%\cargo-nextest.exe (
cargo install cargo-nextest --version 0.9.99 --locked --no-default-features --features default-no-update --root out || exit /b 1
)

set "ANKI_TEST_MODE=1"
%LLVMCOVPATH%\cargo-llvm-cov llvm-cov --workspace --locked --json --summary-only ^
--output-path %outdir%\coverage-summary.json --fail-under-lines 60 || exit /b 1
set "PATH=%LLVMCOVPATH%;%PATH%"
%LLVMCOVPATH%\cargo-llvm-cov llvm-cov nextest --workspace --locked --json --summary-only ^
--output-path %outdir%\coverage-summary.json --fail-under-lines 60 ^
--color=always --failure-output=final --status-level=none || exit /b 1

if "%1"=="--html" (
%LLVMCOVPATH%\cargo-llvm-cov llvm-cov report --html --output-dir %outdir%\html || exit /b 1
Expand Down
6 changes: 6 additions & 0 deletions tools/coverage/setup.ci.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[coverage:run]
core = sysmon

[coverage:report]
show_missing = True
skip_covered = True
Loading