Skip to content

Commit

Permalink
Add code coverage github action.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Dec 25, 2023
1 parent ffad841 commit 8a518b9
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
69 changes: 63 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,72 @@ env:
# A fixed version used for testing, so that the builds don't
# spontaneously break after a few years.
# Make sure to update this from time to time.
RUST_VERSION: "1.72.0"
RUST_VERSION: "1.74.0"
# This is the version currently used by `z3-sys`.
# If this ever changes, you might also need to increase
# the minimum macOS version below.
Z3_VERSION: "4.8.12"
MACOS_TARGET: "11.0"
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"
jobs:
linux:
test-with-coverage:
runs-on: macos-12
env:
RUSTFLAGS: '-C instrument-coverage --cfg=coverage --cfg=trybuild_no_target'
#LLVM_PROFILE_FILE: '/home/runner/work/biodivine-aeon-py/biodivine-aeon-py/target/biodivine-aeon-py-%p-%4m.profraw'
CARGO_LLVM_COV: 1
CARGO_LLVM_COV_SHOW_ENV: 1
#CARGO_LLVM_COV_TARGET_DIR: '/home/runner/work/biodivine-aeon-py/biodivine-aeon-py/target'
#CARGO_TARGET_DIR: $CARGO_LLVM_COV_TARGET_DIR
#CARGO_INCREMENTAL: 1
steps:
# Here, we don't need to bother with the `manylinux` container,
# since we are only testing, not building multiplatform `wheel` files.
- name: Checkout.
uses: actions/checkout@v4
- name: Setup Z3.
id: z3
uses: cda-tum/setup-z3@v1
with:
version: ${{ env.Z3_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Explicitly add z3 to include path (probably some bug in either
# `setup-z3` or `z3-sys` crate, because this should not be necessary).
- run: echo "CPATH=$CPATH:$Z3_ROOT/include" >> $GITHUB_ENV
- run: echo "LIBRARY_PATH=$LIBRARY_PATH:$Z3_ROOT/lib" >> $GITHUB_ENV
- run: echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$Z3_ROOT/lib" >> $GITHUB_ENV
- name: Setup Python.
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64
- name: Setup Rust toolchain.
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUST_VERSION }}
- run: rustup component add llvm-tools-preview
- run: cargo install cargo-llvm-cov
- run: python3 -m venv venv
- run: ./venv/bin/pip3 install -r dev-requirements.txt
- run: |
pwd
source venv/bin/activate
cargo llvm-cov clean --workspace
cargo test --features static-z3
maturin develop --features static-z3
echo $CARGO_TARGET_DIR
ls -la .
ls -la ./target
pytest ./tests --cov=biodivine_aeon --cov-report xml
echo $CARGO_LLVM_COV_TARGET_DIR
echo $LLVM_PROFILE_FILE
ls ./target
cargo llvm-cov report --lcov --output-path coverage.lcov
- uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
files: coverage.lcov,coverage.xml

build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout.
Expand All @@ -33,7 +90,7 @@ jobs:
name: wheels
path: target/dist

macos:
build-macos:
runs-on: macos-latest
steps:
- name: Checkout.
Expand Down Expand Up @@ -69,7 +126,7 @@ jobs:
name: wheels
path: target/dist

windows:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout.
Expand Down Expand Up @@ -97,7 +154,7 @@ jobs:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, windows, linux ]
needs: [ build-macos, build-windows, build-linux ]
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "biodivine_aeon"
crate-type = ["cdylib", "rlib"]

[features]
default = ['static-z3']
#default = ['static-z3']
# For releases, we want to include Z3 statically, so that users
# don't have to install it (or break compatibility with new versions).
# So for CI builds, this feature is enabled, but for local builds,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ available through an official installer or cannot be installed globally.

> In any case, on linux, you'll need typical "essential" build tools like `cmake` and `clang`
> to even build the Z3 dependency, regardless of the linking process. On debian-ish distros,
> `apt install build-essential clang` should be sufficient.
> `apt install build-essential cmake clang` should be sufficient.
> On Apple Silicon, dynamic linking for Z3 is currently not working out-of-the-box if
> you installed Z3 through `brew`, because the library files are not discoverable by `clang`
Expand Down
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest==7.4.3
pytest-cov==4.1.0
maturin==1.4.0
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=1.0.1,<1.1.0"]
requires = ["maturin>=1.4.0,<1.5.0"]
build-backend = "maturin"

[project]
Expand Down

0 comments on commit 8a518b9

Please sign in to comment.