Skip to content

CI

CI #1086

Workflow file for this run

name: CI
on:
# Run CI when changes are pushed to master
push:
branches:
- master
# Run CI when a PR is openend or changes are pushed to the PR
pull_request:
types:
- opened
- synchronize
- reopened
# Run CI every Monday at 7AM to catch bugs due to changes in the ecosystem
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: "0 7 * * 1"
# Run CI whenever someone with the appropriate privileges requests it
workflow_dispatch:
defaults:
run:
shell: sh
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
compiler: [g++, clang++]
build_type: [Debug, Release]
include:
- os: macos-latest
compiler: clang++
build_type: Release
runs-on: ${{ matrix.os }}
name: ${{ matrix.build_type }} build with ${{ matrix.compiler }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install system packages
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y \
build-essential \
ccache \
cmake \
cxxtest \
protobuf-compiler \
libprotoc-dev
- name: Install system packages
if: runner.os == 'macOS'
run: |
brew install \
ccache \
cmake \
cxxtest \
protobuf-c
- name: Install Python packages
run: |
python -m pip install --user --upgrade pip
python -m pip install --user --upgrade setuptools
python -m pip install --user wheel
python -m pip install --user bumpver
python -m pip install --user -r maraboupy/test_requirements.txt --cache-dir $HOME/.pip-cache
echo "/usr/lib/ccache" >> $GITHUB_PATH
- name: Test BumpVer Configuration
run: python -m bumpver update --patch --no-fetch --dry
- name: Create Build Environment
run: cmake -E make_directory build
# ---------------------------- CACHING ----------------------------------
# GitHub actions currently does not support modifying an already existing
# cache. Hence, we create a new cache for each commit with key
# cache-${{ runner.os }}-${{ matrix.cache-key }}-${{ github.sha }}. This
# will result in an initial cache miss. However, restore-keys will search
# for the most recent cache with prefix
# ${{ env.cache-name }}-${{ matrix.compiler }}-, and if found uses it as
# a base for the new cache.
# Add ${{ matrix.cache-key }}- to the key pattern if matrix grows
- name: Restore ccache
id: ccache
uses: actions/cache@v4
env:
cache-name: ccache-
with:
path: ccache-dir
key: ${{ env.cache-name }}-${{ matrix.compiler }}-${{ github.sha }}
restore-keys: ${{ env.cache-name }}-${{ matrix.compiler }}-
# ---------------------------- END CACHE RESTORE -------------------------
- name: Configure ccache
run: |
ccache --set-config=cache_dir=${{ github.workspace }}/ccache-dir
ccache --set-config=compression=true
ccache --set-config=compression_level=6
ccache -M 500M
ccache -z
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable bb
# access regardless of the host operating system
shell: bash
working-directory: build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_PYTHON=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=${{ matrix.compiler }}
- name: Build
run: make -j2
working-directory: build
- name: ccache statistics
run: ccache -s
- name: Run system tests
run: ctest -L system -j 2
working-directory: build
- name: Run regression tests
if: runner.os == 'Linux'
run: ctest -L regress[0-1] -j 2
working-directory: build
- name: Python Bindings Install Check
run: |
export PYTHONPATH="$PYTHONPATH:$(dirname $(find $GITHUB_WORKSPACE -name "maraboupy" -type d))"
python -c "import maraboupy"
- name: Run Python API examples
run: |
export PYTHONPATH="$PYTHONPATH:../../"
for file in *py; do python -u $file; done
working-directory: maraboupy/examples
- name: Generate Python Code Coverage
if: ${{ ( matrix.compiler == 'g++' ) && ( matrix.build_type == 'Debug' ) }}
run: python -m pytest --cov=maraboupy --cov-report=xml maraboupy/test
- name: Upload coverage to Codecov
if: ${{ ( matrix.compiler == 'g++' ) && ( matrix.build_type == 'Debug' ) }}
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml