-
-
Notifications
You must be signed in to change notification settings - Fork 277
166 lines (156 loc) · 6.05 KB
/
test.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Run tests
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.6
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install cffi and virtualenv
run: pip install cffi virtualenv
- uses: actions-rs/toolchain@v1
id: rustup
with:
profile: minimal
toolchain: stable
override: true
- name: Install aarch64-apple-darwin Rust target
if: matrix.os == 'macos-latest'
run: rustup target add aarch64-apple-darwin
# We use this target in the musl unit test
- name: Install x86_64-unknown-linux-musl Rust target
if: matrix.os == 'ubuntu-latest'
run: rustup target add x86_64-unknown-linux-musl
- name: Install musl tools
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y musl-tools
- name: Setup Xcode env
if: matrix.os == 'macos-latest'
shell: bash
run: |
echo "PYO3_CROSS_LIB_DIR=/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib" >> "${GITHUB_ENV}"
sudo xcode-select -s /Applications/Xcode_12.3.app
bindir="$(xcode-select --print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin"
echo "CC=${bindir}/clang" >> "${GITHUB_ENV}"
echo "CXX=${bindir}/clang++" >> "${GITHUB_ENV}"
echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" >> "${GITHUB_ENV}"
# Caching
# Install gnu-tar because BSD tar is buggy
# https://github.com/actions/cache/issues/403
- name: Install GNU tar (Macos)
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Cache cargo build
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ steps.rustup.outputs.rustc_hash }}-maturin-${{ hashFiles('Cargo.lock') }}
- name: Cache test crates cargo build
uses: actions/cache@v2
with:
path: test-crates/*/target
key: ${{ runner.os }}-${{ steps.rustup.outputs.rustc_hash }}-test-crates-${{ hashFiles('test-crates/*/Cargo.lock') }}
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
- name: cargo test with musl
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: test
args: --target x86_64-unknown-linux-musl
test-auditwheel:
name: Test Auditwheel
runs-on: ubuntu-latest
strategy:
matrix:
manylinux: [ '2010', '2014' ]
env:
# Install rust in the workspace so it gets mounted into the docker container
RUSTUP_HOME: .rustup
CARGO_HOME: .cargo
steps:
- uses: actions/checkout@v2
# actions-rs/toolchain@v1 has some hiccups with the custom installation locations
- run: curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
- run: echo "$(pwd)/.cargo/bin" >> $GITHUB_PATH
# Caching
- name: Cache cargo build
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: manylinux${{ matrix.manylinux }}-${{ steps.rustup.outputs.rustc_hash }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Cache test crates cargo build
uses: actions/cache@v2
with:
path: test-crates/*/target
key: manylinux${{ matrix.manylinux }}-${{ steps.rustup.outputs.rustc_hash }}-cargo-${{ hashFiles('test-crates/*/Cargo.lock') }}
# Do a bit of if-switching since the docker url doesn't support substitutions
- name: Compliant Build
if: matrix.manylinux == '2010'
uses: docker://quay.io/pypa/manylinux2010_x86_64
with:
entrypoint: /bin/bash
args: -c "PATH=/github/workspace/.cargo/bin:$PATH tests/manylinux_compliant.sh ${{ matrix.manylinux }}"
- name: Compliant Build
if: matrix.manylinux == '2014'
uses: docker://quay.io/pypa/manylinux2014_x86_64
with:
entrypoint: /bin/bash
args: -c "PATH=/github/workspace/.cargo/bin:$PATH tests/manylinux_compliant.sh ${{ matrix.manylinux }}"
- name: Incompliant Build
if: matrix.manylinux == '2014'
uses: docker://quay.io/pypa/manylinux2014_x86_64
with:
entrypoint: /bin/bash
args: -c "PATH=/github/workspace/.cargo/bin:$PATH tests/manylinux_incompliant.sh ${{ matrix.manylinux }}"
# Fix permissions from docker for caching
- run: sudo chown $(id -u):$(id -g) -R target test-crates/*/target
test-cross-compile:
name: Test Cross Compile
runs-on: ubuntu-latest
strategy:
matrix:
platform: [
{ target: "aarch64-unknown-linux-gnu", arch: "aarch64" },
{ target: "armv7-unknown-linux-gnueabihf", arch: "armv7" },
]
steps:
- uses: actions/checkout@v2
- name: Build Wheels
run: |
echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
source ~/.cargo/env
rustup target add ${{ matrix.platform.target }}
export PYO3_CROSS_LIB_DIR=/opt/python/cp36-cp36m/lib
cargo run --target x86_64-unknown-linux-gnu -- build -i python3.9 --release --out dist --no-sdist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml
' > build-wheel.sh
docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh