Add code coverage github action. #227
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
pull_request: | |
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.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.12" | |
jobs: | |
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. | |
uses: actions/checkout@v4 | |
# On linux, everything is installed in the container, | |
# so we don't really need any dependencies here. | |
- name: Maturin build. | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x86_64 | |
container: daemontus/manylinux-aeon:latest | |
args: "--release --features static-z3 --compatibility manylinux_2_28 --out=target/dist" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/dist | |
build-macos: | |
runs-on: macos-latest | |
steps: | |
- 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 }} | |
- 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 }} | |
# 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=$Z3_ROOT/include" >> $GITHUB_ENV | |
# The considered version of z3 needs at least this version of macOS. | |
- run: echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV | |
- run: echo "CMAKE_OSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV | |
- name: Maturin build. | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: build | |
args: "--release --target universal2-apple-darwin --features static-z3 --out=target/dist" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/dist | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout. | |
uses: actions/checkout@v4 | |
- 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 }} | |
# Surprisingly, windows is the easiest. Just build the thing. | |
- name: Maturin build. | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x64 | |
args: "--release --features static-z3 --out=target/dist" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/dist | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: [ build-macos, build-windows, build-linux ] | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
- name: Publish to PyPI | |
uses: PyO3/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --skip-existing * | |
conda_deployment_with_new_tag: | |
name: Conda deployment (${{ matrix.os }}) | |
if: "startsWith(github.ref, 'refs/tags/')" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# For now, windows builds are broken... | |
os: [macos-latest, ubuntu-latest] | |
python: ["3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Conda environment creation and activation | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: ${{ matrix.python }} | |
environment-file: conda_env.yaml | |
auto-update-conda: false | |
auto-activate-base: false | |
show-channel-urls: true | |
- name: Build and upload the conda packages | |
uses: uibcdf/[email protected] | |
with: | |
python-version: ${{ matrix.python }} | |
meta_yaml_dir: "conda" | |
user: daemontus | |
label: main | |
overwrite: false | |
token: ${{ secrets.ANACONDA_TOKEN }} |