Skip to content

ci

ci #1370

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: ci
on:
push:
branches: [ "*" ]
schedule:
# Every day at 2:34.
- cron: '34 2 * * *'
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 10 # stop runaway job after 10 minutes
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -qq
sudo apt-get -y install graphviz graphviz-dev valgrind
pip install --require-hashes -r ./ci/requirements-dev.txt -r ./ci/requirements-demonet.txt
- name: Install dependencies (MacOS/Windows)
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest'
run: |
pip install --require-hashes -r ./ci/requirements-dev.txt
- name: Lint Check
run: |
ruff check --exit-zero .
pylint --fail-under 9.0 finsy
pyright || echo "Errors ignored for now."
- name: Run Tests
run: |
GRPC_VERBOSITY=INFO pytest
- name: Run Code Coverage
run: |
FINSY_TEST_NO_BENCHMARK=1 COVERAGE_RUN=true pytest --cov finsy
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.FINSY_CODECOV_TOKEN }}
- name: Format Check
run: |
black --check .
isort --check .
- name: Type Check
run: |
PYTHONPATH=. pyright --ignoreexternal --verifytypes finsy || echo "Not yet 100%."
- name: MemCheck Tests (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
FINSY_TEST_NO_BENCHMARK=1 valgrind pytest -k 'not test_p4info_repr'
test-examples:
runs-on: ubuntu-latest
needs: build
container:
image: ghcr.io/byllyfish/demonet:24.04
options: --privileged
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install dependencies
run: |
. /etc/os-release
echo "$PRETTY_NAME"
mn --version
python3 -m venv venv
. venv/bin/activate
pip install --require-hashes --no-cache-dir -r ./ci/requirements-dev.txt
- name: Run tests
env:
FINSY_TEST_NO_BENCHMARK: 1
PYTHONWARNDEFAULTENCODING: 1
run: |
. venv/bin/activate
pytest
- name: Run example tests
run: |
. venv/bin/activate
cd examples
export PYTHONPATH=..
pytest -v -s || (echo "::warning title=Run Examples Warning::Re-running failed tests" && pytest -v -s --last-failed)
- name: Run example tests with coverage (simple only)
run: |
. venv/bin/activate
cd examples; PYTHONPATH=.. COVERAGE_RUN=true pytest -k simple --cov ../finsy --cov-report xml --cov-config ../.coveragerc
- name: Upload Coverage to Codecov
# Revert codecov-action here due to failure running in container with v4.0.1.
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
with:
token: ${{ secrets.FINSY_CODECOV_TOKEN }}
directory: ./examples/
root_dir: ${{ github.workspace }}
verbose: true