1
+ name : CI
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ pull_request :
8
+
9
+ env :
10
+ CARGO_TERM_COLOR : always
11
+
12
+ jobs :
13
+ fmt :
14
+ runs-on : ubuntu-latest
15
+ steps :
16
+ - uses : actions/checkout@v2
17
+ - uses : actions/setup-python@v2
18
+ - run : pip install black==19.10b0
19
+ - uses : actions-rs/toolchain@v1
20
+ with :
21
+ toolchain : stable
22
+ profile : minimal
23
+ components : rustfmt
24
+ - name : Check python formatting (black)
25
+ run : black --check .
26
+ - name : Check rust formatting (rustfmt)
27
+ run : cargo fmt --all -- --check
28
+
29
+ clippy :
30
+ runs-on : ubuntu-latest
31
+ steps :
32
+ - uses : actions/checkout@v2
33
+ - uses : actions-rs/toolchain@v1
34
+ with :
35
+ toolchain : stable
36
+ profile : minimal
37
+ components : clippy
38
+ - run : make clippy
39
+
40
+ build :
41
+ needs : [fmt] # don't wait for clippy as fails rarely and takes longer
42
+ name : python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
43
+ runs-on : ${{ matrix.platform.os }}
44
+ strategy :
45
+ fail-fast : false # If one platform fails, allow the rest to keep testing.
46
+ matrix :
47
+ rust : [stable]
48
+ python-version : [3.6, 3.7, 3.8, 3.9, 3.10-dev, pypy-3.6]
49
+ platform : [
50
+ { os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
51
+ { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
52
+ { os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
53
+ { os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
54
+ ]
55
+ exclude :
56
+ # There is no 64-bit pypy on windows
57
+ - python-version : pypy-3.6
58
+ platform : { os: "windows-latest", python-architecture: "x64" }
59
+ include :
60
+ # Test minimal supported Rust version
61
+ - rust : 1.45.0
62
+ python-version : 3.9
63
+ platform : { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
64
+ msrv : " MSRV"
65
+
66
+ steps :
67
+ - uses : actions/checkout@v2
68
+
69
+ - name : Set up Python ${{ matrix.python-version }}
70
+ uses : actions/setup-python@v2
71
+ with :
72
+ python-version : ${{ matrix.python-version }}
73
+ architecture : ${{ matrix.platform.python-architecture }}
74
+
75
+ - name : Install Rust toolchain
76
+ uses : actions-rs/toolchain@v1
77
+ with :
78
+ toolchain : ${{ matrix.rust }}
79
+ target : ${{ matrix.platform.rust-target }}
80
+ profile : minimal
81
+ default : true
82
+
83
+ - if : matrix.platform.os == 'ubuntu-latest'
84
+ name : Prepare LD_LIBRARY_PATH (Ubuntu only)
85
+ run : echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
86
+
87
+ - name : Build docs
88
+ run : cargo doc --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
89
+
90
+ - name : Build (no features)
91
+ run : cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
92
+
93
+ - name : Build (all additive features)
94
+ run : cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
95
+
96
+ # Run tests (except on PyPy, because no embedding API).
97
+ - if : matrix.python-version != 'pypy-3.6'
98
+ name : Test
99
+ run : cargo test --no-default-features --target ${{ matrix.platform.rust-target }}
100
+
101
+ # Run tests again, but in abi3 mode
102
+ - if : matrix.python-version != 'pypy-3.6'
103
+ name : Test (abi3)
104
+ run : cargo test --no-default-features --target ${{ matrix.platform.rust-target }}
105
+
106
+ # Run tests again, for abi3-py36 (the minimal Python version)
107
+ - if : (matrix.python-version != 'pypy-3.6') && (matrix.python-version != '3.6')
108
+ name : Test (abi3-py36)
109
+ run : cargo test --no-default-features --target ${{ matrix.platform.rust-target }}
110
+
111
+ - name : Install python test dependencies
112
+ run : |
113
+ python -m pip install -U pip setuptools
114
+ pip install setuptools-rust pytest pytest-benchmark tox tox-venv
115
+ - name : Test example extension modules
116
+ shell : bash
117
+ run : |
118
+ for example_dir in examples/*; do
119
+ tox --discover $(which python) -c $example_dir -e py
120
+ done
121
+ env :
122
+ RUST_BACKTRACE : 1
123
+ RUSTFLAGS : " -D warnings"
124
+ # TODO: this is a hack to workaround compile_error! warnings about auto-initialize on PyPy
125
+ # Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this.
126
+ PYO3_CI : 1
127
+
128
+ coverage :
129
+ needs : [fmt]
130
+ runs-on : ubuntu-latest
131
+ steps :
132
+ - uses : actions/checkout@v2
133
+ - uses : actions-rs/toolchain@v1
134
+ with :
135
+ toolchain : nightly
136
+ override : true
137
+ profile : minimal
138
+ - uses : actions-rs/cargo@v1
139
+ with :
140
+ command : test
141
+ args :
142
+ env :
143
+ CARGO_INCREMENTAL : 0
144
+ RUSTFLAGS : " -Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
145
+ RUSTDOCFLAGS : " -Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
146
+ -
uses :
actions-rs/[email protected]
147
+ id : coverage
148
+ - uses : codecov/codecov-action@v1
149
+ with :
150
+ file : ${{ steps.coverage.outputs.report }}
0 commit comments