Skip to content

Ping available I2C address #531

Ping available I2C address

Ping available I2C address #531

name: Regression Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pre-commit/action@v3.0.1
env:
SKIP: coverage # Run all normal formatting hooks in CI, but skip the local coverage hook because the coverage job handles it separately.
tests:
name: Python ${{matrix.python-version}} | ${{matrix.sim}}
runs-on: ubuntu-24.04
permissions:
contents: read
checks: write
env:
SIM: ${{matrix.sim}}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
include:
- sim: icarus
python-version: '3.10'
- sim: icarus
python-version: '3.11'
- sim: icarus
python-version: '3.12'
- sim: icarus
python-version: '3.13'
coverage: true
- sim: verilator
sim-version: 5.044
python-version: '3.10'
pytest-marker: "-m verilator"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
- name: Set up miniforge ${{matrix.python-version}}
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: ${{matrix.python-version}}
conda-remove-defaults: "true" # explicitly remove conda default channel in favor of conda-forge
- name: Install verilator
if: matrix.sim == 'verilator'
shell: bash -l {0}
run: |
conda install verilator==${{matrix.sim-version}}
- name: Install Icarus Verilog
if: matrix.sim == 'icarus'
run: |
sudo apt install -y --no-install-recommends iverilog
- name: Install Python dependencies
shell: bash -l {0}
run: |
pip install pyvisa pyvisa-sim pytest cocotb>=2 cocotb-bus
- name: Install coverage dependency
if: matrix.coverage
shell: bash -l {0}
run: |
pip install coverage diff-cover
- name: Install basil
shell: bash -l {0}
run: |
pip install -e .
- name: Test
if: ${{ !matrix.coverage }}
shell: bash -l {0}
run: |
pytest ${{matrix.pytest-marker}} tests/test_*.py examples/*/*/test_*.py
- name: Test with coverage
if: matrix.coverage
shell: bash -l {0}
run: |
coverage run --source=basil -m pytest ${{matrix.pytest-marker}} \
tests/test_*.py examples/*/*/test_*.py
coverage xml -o coverage.xml
coverage report --format=total | awk '{print "### Test coverage: " $1 "%"}' >> "$GITHUB_STEP_SUMMARY"
- name: Create differential coverage report
if: matrix.coverage && github.event_name == 'pull_request'
env:
BASE_REF: ${{github.base_ref}}
shell: bash -l {0}
run: |
diff-cover coverage.xml \
--compare-branch="origin/${BASE_REF}" \
--format=markdown:diff-cover.md
cat diff-cover.md >> "$GITHUB_STEP_SUMMARY"
- name: Publish differential coverage check
if: >-
matrix.coverage &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
env:
GH_TOKEN: ${{github.token}}
HEAD_SHA: ${{github.event.pull_request.head.sha}}
run: |
gh api --method POST \
--header "Accept: application/vnd.github+json" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"repos/${GITHUB_REPOSITORY}/check-runs" \
--raw-field name="Coverage (informational)" \
--raw-field head_sha="$HEAD_SHA" \
--raw-field status=completed \
--raw-field conclusion=neutral \
--raw-field "output[title]=Differential coverage" \
--field "output[summary]=@diff-cover.md" \
--silent