-
Notifications
You must be signed in to change notification settings - Fork 5
100 lines (88 loc) · 3.02 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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
# define when this workflow is triggered
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
# cancel any currently running workflows in this same PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Use bash by default in all jobs
defaults:
run:
shell: bash -el {0}
jobs:
# run pre-commit which includes many formatting and linting tools
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: pipx run nox -s pylint -- --output-format=github
# Run tests and upload to codecov
test:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
if: |
${{!startsWith(github.event.head_commit.message, 'docs:') }} ||
${{!startsWith(github.event.head_commit.message, 'style:') }}
needs: [pre-commit]
strategy:
# Otherwise, the workflow would stop if a single job fails. We want to
# run all of them to catch failures in different combinations.
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
env:
FORCE_COLOR: 3
NUMBA_DISABLE_JIT: "1"
timeout-minutes: 30
steps:
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Switch to Current Branch
run: git checkout ${{ env.BRANCH }}
- name: Get current week number of year
id: date
run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19
# Install Micromamba with conda-forge dependencies
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: env/testing_env.yml
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: "all"
cache-downloads: false
# environment cache is persistent for one week.
cache-environment-key:
micromamba-environment-${{ steps.date.outputs.date }}
# Install the package that we want to test
- name: Install the package
run: pip install --no-deps -e .
- name: Run the tests
run: >-
pytest -m "not fetch and not issue" -ra --cov --cov-report=xml
--cov-report=term --durations=20
- name: Upload coverage report
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}