-
Notifications
You must be signed in to change notification settings - Fork 175
212 lines (170 loc) · 6.59 KB
/
build.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#
# Copyright © 2019-today Peter M. Stahl [email protected]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: build
on:
push:
branches:
- main
paths:
- 'Cargo.lock'
- 'Cargo.toml'
- 'src/**'
- 'tests/**'
- '**.yml'
pull_request:
branches:
- main
paths:
- 'Cargo.lock'
- 'Cargo.toml'
- 'src/**'
- 'tests/**'
- '**.yml'
jobs:
rust-build:
name: Rust on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
name: Linux 64-Bit
target: x86_64-unknown-linux-musl
- os: macos-latest
name: MacOS 64-Bit
target: x86_64-apple-darwin
target2: aarch64-apple-darwin
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
- os: windows-latest
name: Windows 64-Bit
target: x86_64-pc-windows-msvc
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Add rustup default target
run: rustup target add ${{ matrix.target }}
- name: Add rustup Apple ARM64 target
if: ${{ matrix.os == 'macos-latest' }}
run: rustup target add ${{ matrix.target2 }}
- name: Install apt packages
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install musl-tools libssl-dev
# needed to fix file corruption of cache
# https://github.com/actions/cache/issues/403
- name: Install GNU tar
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Install wasm-pack
if: ${{ matrix.os == 'macos-latest' }}
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Enable Safari web driver
if: ${{ matrix.os == 'macos-latest' }}
run: sudo safaridriver --enable
- name: Store or retrieve cargo caches
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build default target in debug mode
run: cargo build --target ${{ matrix.target }} --locked
- name: Build Apple ARM64 target in debug mode
if: ${{ matrix.os == 'macos-latest' }}
run: cargo build --target ${{ matrix.target2 }} --locked
- name: Test default target in debug mode
run: cargo test --target ${{ matrix.target }}
- name: Run WASM integration tests on NodeJS
if: ${{ matrix.os == 'macos-latest' }}
run: wasm-pack test --node -- --no-default-features
- name: Run WASM integration tests in Chrome
if: ${{ matrix.os == 'macos-latest' }}
run: wasm-pack test --headless --chrome -- --no-default-features
- name: Run WASM integration tests in Firefox
if: ${{ matrix.os == 'macos-latest' }}
run: wasm-pack test --headless --firefox -- --no-default-features
- name: Run WASM integration tests in Safari
if: ${{ matrix.os == 'macos-latest' }}
run: wasm-pack test --headless --safari -- --no-default-features
- name: Create code coverage report
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'push' }}
# NOTE: actions-rs is unmaintained, using fork with fix for update to node 16
# https://github.com/actions-rs/tarpaulin/pull/22
uses: FreeMasen/tarpaulin-action@9f7e03f06fea8f374c85a95c2ecff6a4d5805845
with:
version: '0.22.0'
args: '--ignore-config --ignore-panics --ignore-tests --exclude-files src/main.rs src/wasm.rs'
timeout: 900 # increase timeout for long-running property tests
- name: Upload code coverage report to Codecov
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'push' }}
uses: codecov/codecov-action@v3
python-build:
name: Python ${{ matrix.python-version }} on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
include:
- os: ubuntu-latest
name: Linux 64-Bit
- os: macos-latest
name: MacOS 64-Bit
- os: windows-latest
name: Windows 64-Bit
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install maturin and pytest
run: pip install maturin pytest
- name: Build Python extension
run: maturin build
- name: Install Python extension
run: pip install target/wheels/grex*.whl
- name: Run Python unit tests
run: pytest tests/python/test_grex.py
#- name: Create virtual environment for Maturin
# run: python -m venv .venv
#- name: Activate virtual environment on Linux and MacOS #source .venv/bin/activate
# if: ${{ matrix.os != 'windows-latest' }}
# run: echo "PYTHON_PATH=.venv/bin" >> "$GITHUB_ENV"
#- name: Activate virtual environment on Windows #.venv\Scripts\activate.bat
# if: ${{ matrix.os == 'windows-latest' }}
# run: echo "PYTHON_PATH=.venv\Scripts" >> "$GITHUB_ENV"
#- name: Install Maturin
# run: $PYTHON_PATH/pip install maturin
#- name: Build Python extension and install pytest
# run: $PYTHON_PATH/python -m maturin develop --extras=test
#- name: Build Python extension and install pytest
# uses: PyO3/maturin-action@v1
# with:
# command: develop
# args: --extras=test
#- name: Run Python unit tests
# run: $PYTHON_PATH/python -m pytest tests/python/test_grex.py