-
-
Notifications
You must be signed in to change notification settings - Fork 2
183 lines (152 loc) · 4.56 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
on:
pull_request:
workflow_dispatch:
name: Test code
env:
JAX_PLATFORM_NAME: cpu
jobs:
pytest:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
pyversion: ['3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.pyversion }}
cache: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
pdm install -G test,github-action
- name: Run Pytest
run: |
pdm run pytest -Werror -n auto
cargo-test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
pyversion: ['3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.pyversion }}
cache: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
pdm install --no-self
- name: Run Cargo test
run: |
pdm run cargo test
python-benchmark:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.11'
cache: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
pdm install -G test,github-action
- name: Run Benchmarks on changes
run: pdm run pytest --benchmark-only --benchmark-save=changes
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
clean: false
- name: Run Benchmarks before changes
run: pdm run pytest --benchmark-only --benchmark-save=before
- name: Compare benchmarks
run: |
echo 'results<<EOF' >> $GITHUB_OUTPUT
pdm run pytest-benchmark compare before changes >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: compare
- name: Comment PR with benchmarks
uses: thollander/actions-comment-pull-request@v2
continue-on-error: true
with:
message: |
Python benchmark results:
```
${{ steps.compare.outputs.results }}
```
comment_tag: python-benchmarks
id: comment
- name: If PR comment failed, write to PR summary
if: steps.comment.outcome != 'success'
run: |
echo '### Python benchmark results' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.compare.outputs.results }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
rust-benchmark:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.11'
cache: true
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: Install dependencies
run: |
pdm install --no-self
cargo install cargo-benchcmp
- name: Run Benchmarks on changes
run: pdm run cargo bench > changes
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
clean: false
- name: Run Benchmarks before changes
run: pdm run cargo bench > before
- name: Compare benchmarks
run: |
echo 'results<<EOF' >> $GITHUB_OUTPUT
cargo benchcmp before changes >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: compare
- name: Comment PR with benchmarks
uses: thollander/actions-comment-pull-request@v2
continue-on-error: true
with:
message: |
Rust benchmark results:
```
${{ steps.compare.outputs.results }}
```
comment_tag: rust-benchmarks
id: comment
- name: If PR comment failed, write to PR summary
if: steps.comment.outcome != 'success'
run: |
echo '### Rust benchmark results' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.compare.outputs.results }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY