gh-actions
: doing the job of a package manager instead of brew
#20
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: Unit tests (fast suite) | |
on: | |
push: | |
branches: [main, dev] | |
pull_request: | |
branches: [main, dev] | |
types: [ opened, synchronize, reopened, ready_for_review ] | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -e {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.9', '3.10', '3.11'] | |
os: [ubuntu-latest, macos-latest] | |
env: | |
OS: ${{ matrix.os }} | |
PYTHON: ${{ matrix.python }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@main | |
- name: Install graphviz headers | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y graphviz graphviz-dev | |
- name: Install graphviz headers | |
if: ${{ matrix.os == 'macos-latest' }} | |
run: | | |
brew install graphviz | |
echo "PATH=\"$(brew --prefix graphviz):$PATH\"" >> $GITHUB_ENV | |
echo "CFLAGS=\"-I $(brew --prefix graphviz)/include\"" >> $GITHUB_ENV | |
echo "LDFLAGS=\"-L $(brew --prefix graphviz)/lib\"" >> $GITHUB_ENV | |
- name: Setup Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Install library | |
run: poetry install --no-interaction | |
- name: Tests and coverage | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
poetry run pytest -v --cov --color=yes --durations=0 | |
- name: Tests | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
poetry run pytest -v --cov --color=yes --durations=0 | |
- name: Upload coverage reports to Codecov | |
if: ${{ github.event_name == 'push' }} | |
env: | |
CODECOV_NAME: ${{ matrix.python }}-${{ matrix.os }} | |
run: | | |
curl -Os https://uploader.codecov.io/latest/linux/codecov | |
chmod +x codecov | |
./codecov --no-color --required -F fast -t ${{ secrets.CODECOV_TOKEN }} |