Skip to content

Commit

Permalink
ci: Add codecov flags and run test on different os.
Browse files Browse the repository at this point in the history
  • Loading branch information
EltonChou committed Sep 11, 2024
1 parent 4da8f7a commit c498510
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,48 @@ name: Test

on:
push:
branches: [master, dev, fix_ci]
branches: [master, dev]
tags-ignore:
- "**"
- "*.*.*"
pull_request:
branches: [master]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
name: test with python${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint code
run: |
flake8
- name: Type check
run: |
mypy
- name: Format check
run: |
black --check .
- name: Install tox
run: python -m pip install tox-gh>=1.2

- name: Run pytest
run: |
coverage run -m pytest
coverage xml
- name: Run test
run: tox

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ format('python{0} ({1})', matrix.python-version, matrix.os) }}
17 changes: 17 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[gh]
python =
3.12 = py312, gh-cov-report
3.11 = py311, lint, type, gh-cov-report
3.10 = py310, gh-cov-report
3.9 = py39, gh-cov-report
3.8 = py38, gh-cov-report

[tox]
skipsdist = true
isolated_build = true
Expand Down Expand Up @@ -38,6 +46,15 @@ commands =
coverage report
coverage html

[testenv:gh-cov-report]
depends = py{38, 39, 310, 311, 312}
description = combine coverage
skip_install = true
deps = coverage[toml]
commands =
coverage combine
coverage xml

[testenv:clean]
deps = coverage[toml]
skip_install = true
Expand Down

0 comments on commit c498510

Please sign in to comment.