-
Notifications
You must be signed in to change notification settings - Fork 73
151 lines (122 loc) · 4.27 KB
/
Copy pathpython-ci.yml
File metadata and controls
151 lines (122 loc) · 4.27 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Python CI
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
RUST_BACKTRACE: full
CARGO_TERM_COLOR: always
FORCE_COLOR: 1
IN_CI: 1
# Only include the debug info necessary for backtraces (file names and line numbers). Any extra
# debug info provided by `debuginfo=1` or `debuginfo=2` require an interactive debugger like
# `lldb` or `gdb`.
RUSTFLAGS: -C debuginfo=line-tables-only
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Update Rust
run: rustup update stable && rustup default stable && rustup component add llvm-tools
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov@0.8
- name: Create virtual environment
run: python -m venv --upgrade-deps .venv
- name: Activate virtual environment and code coverage (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Activate virtual environment.
Add-Content -Value "VIRTUAL_ENV=$PWD\.venv" -Path $Env:GITHUB_ENV
Add-Content -Value "$PWD\.venv\Scripts" -Path $Env:GITHUB_PATH
# Activate code coverage.
cargo llvm-cov show-env >> $Env:GITHUB_ENV
- name: Activate virtual environment and code coverage (non-Windows)
if: ${{ matrix.os != 'windows-latest' }}
run: |
# Activate virtual environment.
echo "VIRTUAL_ENV=$(pwd)/.venv" >> "${GITHUB_ENV}"
echo "$(pwd)/.venv/bin" >> "${GITHUB_PATH}"
# Activate code coverage. We remove single quotes from `llvm-cov`'s output, as Github
# Actions does not understand them.
cargo llvm-cov show-env | tr -d "'" >> "${GITHUB_ENV}"
- name: Build package
uses: PyO3/maturin-action@v1
with:
command: develop
args: --group=cov --locked
- name: Run tests
run: pytest --cov=python/sprocket_bio --cov-report=json:codecov-py.json
- name: Generate llvm-cov report
run: cargo llvm-cov report -p sprocket-py -p wdl-diagnostics -p wdl-grammar -p wdl-ast --codecov --output-path=codecov-rust.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov-py.json,codecov-rust.json
fail_ci_if_error: true
type-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Update Rust
run: rustup update stable && rustup default stable
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Create virtual environment
run: python -m venv --upgrade-deps .venv
- name: Activate virtual environment
run: |
echo "VIRTUAL_ENV=$(pwd)/.venv" >> "${GITHUB_ENV}"
echo "$(pwd)/.venv/bin" >> "${GITHUB_PATH}"
- name: Build package
uses: PyO3/maturin-action@v1
with:
command: develop
args: --locked
- name: Check types
run: mypy python
- name: Check stubs
run: python -m mypy.stubtest sprocket_bio
format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Check formatting
uses: psf/black@stable
with:
use_pyproject: true
sort-imports:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
# `isort` requires third-party dependencies to be installed before running. We skip this
# because `sprocket_bio` doesn't have any dependencies.
- name: Check import sorting
run: |
python -m pip install "isort~=8.0"
isort --check-only --diff python/