ci #1484
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
# 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", "3.13" ] | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.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@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.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 | |
timeout-minutes: 15 # stop runaway job after 15 minutes | |
needs: build | |
container: | |
image: ghcr.io/byllyfish/demonet:24.04 | |
options: --privileged | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- 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 |