Skip to content

Merge pull request #181 from B612-Asteroid-Institute/kk/variant_fix #631

Merge pull request #181 from B612-Asteroid-Institute/kk/variant_fix

Merge pull request #181 from B612-Asteroid-Institute/kk/variant_fix #631

name: CI
on:
push:
branches: [ main, "v*" ]
pull_request:
branches: [ main, "v*" ]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
- name: Install test dependencies
run: pdm install -G test
- name: Lint
run: pdm run lint
# - name: Typecheck
# run: pdm run typecheck
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.11', '3.12' ]
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install test dependencies
run: pdm install -G test
- name: Run tests (no coverage)
if: matrix.python-version != '3.12'
run: pdm run test
- name: Run tests with coverage
if: matrix.python-version == '3.12'
run: pdm run coverage
- name: Upload coverage artifact
if: matrix.python-version == '3.12' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
- name: Coverage report to coveralls
if: matrix.python-version == '3.12'
uses: coverallsapp/[email protected]
with:
path-to-lcov: coverage.xml
benchmark:
runs-on: ubuntu-latest
needs: [ test ]
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
- name: Install test dependencies
run: pdm install -G test
- name: Run benchmarks
run: pdm run benchmark --benchmark-json bench.json
- name: Upload benchmark artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: bench-json
path: bench.json
- name: Store main benchmark result
if: github.ref == 'refs/heads/main'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark
tool: 'pytest'
output-file-path: bench.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
gh-pages-branch: gh-pages
- name: Compare benchmarks
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark
tool: 'pytest'
output-file-path: bench.json
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
fail-threshold: '200%'
alert-threshold: '150%'
auto-push: false