Skip to content

Commit

Permalink
chore(test): Enable code coverage measurement (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllexVeldman authored Aug 7, 2024
1 parent 8775faa commit 19179ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: actions/cache@v4
with:
path: |
Expand All @@ -29,4 +30,9 @@ jobs:
run: just build

- name: Test
run: cargo test
run: just test-coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build/
/target
node_modules/
.venv/
lcov.info
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Publish and download (private) python packages using an OCI registry for storage
[![Test](https://github.com/AllexVeldman/pyoci/actions/workflows/test.yaml/badge.svg)](https://github.com/AllexVeldman/pyoci/actions/workflows/test.yaml)
[![Examples](https://github.com/AllexVeldman/pyoci/actions/workflows/examples.yaml/badge.svg)](https://github.com/AllexVeldman/pyoci/actions/workflows/examples.yaml)
[![Deploy](https://github.com/AllexVeldman/pyoci/actions/workflows/deploy.yaml/badge.svg)](https://github.com/AllexVeldman/pyoci/actions/workflows/deploy.yaml)
[![codecov](https://codecov.io/github/AllexVeldman/pyoci/graph/badge.svg?token=SXFCPX8M22)](https://codecov.io/github/AllexVeldman/pyoci)

## Introduction
Most subscriptions with cloud providers include an [OCI](https://opencontainers.org/) (docker image) registry where private containers can be published and distributed from.
Expand Down Expand Up @@ -66,7 +67,7 @@ To prevent having to check-in [encrypted secrets](https://docs.renovatebot.com/g
you can:
1. Self-host renovate as a github workflow
2. Set `package: read` permissions for the workflow
3. Pass the `GITHUB_TOKEN` as an environment variable to Renovate
3. Pass the `GITHUB_TOKEN` as an environment variable to Renovate
4. Add a hostRule for the Renovate runner to apply basic auth for pyoci using the environment variable
5. In the [package settings](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#ensuring-workflow-access-to-your-package) of the private package give the repository running renovate `read` access.

Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comment:
layout: "condensed_header, condensed_files, condensed_footer"
hide_project_coverage: true
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ build *args:
cp ./src/js/cf_worker.js ./build/
cd ./build && npx esbuild --external:./pyoci_bg.wasm --external:cloudflare:sockets --external:cloudflare:workers --format=esm --bundle ./cf_worker.js --outfile=cf_worker.mjs --minify

# Run tests with coverage, requires cargo-llvm-cov. Add `--open` to open the report in the browser.
[group("ci")]
test-coverage *args:
cargo llvm-cov --lcov --output-path lcov.info
cargo llvm-cov report {{args}}

# Recreate the OCI registry, clears it's package cache
[group("setup")]
refresh-registry:
Expand Down

0 comments on commit 19179ff

Please sign in to comment.