Skip to content

Github Actions

Github Actions #5

name: Simulation Bridge CI
on:
pull_request:
paths:
- "simulation_bridge/**"
- ".github/workflows/simulation-bridge-ci.yml"
jobs:
# ────────────────────────── 1. Formatting (autopep8) ──────────────────────────
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
env:
POETRY_HOME: ${{ runner.temp }}/poetry
run: |
python -m pip install -U pip
curl -sSL https://install.python-poetry.org | python -
- name: Add Poetry to PATH (Linux/macOS)
if: runner.os != 'Windows'
run: echo "${{ runner.temp }}/poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: echo "${{ runner.temp }}\poetry\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Install dev deps
run: poetry install --with dev
- name: Check formatting (non-blocking)
run: poetry run autopep8 --recursive --diff simulation_bridge
# ───────────────────────────── 2. Lint (pylint) ───────────────────────────────
lint:
needs: format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
env:
POETRY_HOME: ${{ runner.temp }}/poetry
run: |
python -m pip install -U pip
curl -sSL https://install.python-poetry.org | python -
- name: Add Poetry to PATH (Linux/macOS)
if: runner.os != 'Windows'
run: echo "${{ runner.temp }}/poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: echo "${{ runner.temp }}\poetry\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Install dev deps
run: poetry install --with dev
- name: Run pylint (threshold 8.0)
run: poetry run pylint simulation_bridge --fail-under=8
# ─────────────────── 3. Tests (matrix on 3 OS) + coverage xml ──────────────────
test:
needs: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
env:
POETRY_HOME: ${{ runner.temp }}/poetry
run: |
python -m pip install -U pip
curl -sSL https://install.python-poetry.org | python -
- name: Add Poetry to PATH (Linux/macOS)
if: runner.os != 'Windows'
run: echo "${{ runner.temp }}/poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: echo "${{ runner.temp }}\poetry\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Install dev deps
run: poetry install --with dev
- name: Run pytest + coverage
run: poetry run pytest --cov=simulation_bridge --cov-report=xml
- name: Upload coverage file (per-OS)
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}
path: coverage.xml
# ───────────────────── 4. Merge coverage & send to Codecov ─────────────────────
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
path: coverages
- name: Combine xml files
run: |
python -m pip install coverage
coverage combine coverages/**/coverage.xml
coverage xml -o coverage.xml
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
# ────────────────── 5. Build wheel/zip & upload as artifacts ───────────────────
build:
needs: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
env:
POETRY_HOME: ${{ runner.temp }}/poetry
run: |
python -m pip install -U pip
curl -sSL https://install.python-poetry.org | python -
- name: Add Poetry to PATH (Linux/macOS)
if: runner.os != 'Windows'
run: echo "${{ runner.temp }}/poetry/bin" >> $GITHUB_PATH
- name: Add Poetry to PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: echo "${{ runner.temp }}\poetry\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Install runtime deps
run: poetry install --only main
- name: Build wheel + sdist
run: |
poetry build --format wheel
poetry build --format sdist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: simulation-bridge-dist
path: dist/*.whl,dist/*.tar.gz