-
Notifications
You must be signed in to change notification settings - Fork 67
181 lines (152 loc) · 4.51 KB
/
rust.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
name: Rust bindings
on:
push:
branches:
- main
release:
types: [published]
pull_request:
branches:
- "**"
permissions:
id-token: write
contents: read
jobs:
fuzz_targets:
name: Run fuzzers
runs-on: ubuntu-latest
env:
CARGO_PROFILE_RELEASE_LTO: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo +nightly install cargo-fuzz
- name: Cargo fuzz
run: |
cd rust_bindings
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=600 || exit 255"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Rustfmt
run: cargo fmt -- --files-with-diff --check
- name: Clippy
run: cargo clippy
test:
name: Test (${{ matrix.os.name }} ${{ matrix.arch.name }})
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
strategy:
fail-fast: false
matrix:
os:
- name: macOS
matrix: macos
runs-on:
arm: [macos-13-arm64]
intel: [macos-13]
cibw-archs-macos:
arm: arm64
intel: x86_64
- name: Ubuntu
matrix: ubuntu
runs-on:
arm: [Linux, ARM64]
intel: [ubuntu-latest]
- name: Windows
matrix: windows
runs-on:
intel: [windows-latest]
arch:
- name: ARM
matrix: arm
- name: Intel
matrix: intel
exclude:
- os:
name: Windows
matrix: windows
runs-on:
intel: [windows-latest]
arch:
name: ARM
matrix: arm
steps:
- uses: actions/checkout@v4
- name: Setup library path on MacOS
if: matrix.os.name == 'macOS'
run: echo "LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH" >> $GITHUB_ENV
- name: Install MPIR on Windows
if: matrix.os.name == 'Windows'
run: |
git clone https://github.com/Chia-Network/mpir_gc_x64.git
echo 0
"$(Get-Location)/mpir_gc_x64" | Out-File -Append -FilePath $env:GITHUB_PATH
echo X
echo $GITHUB_PATH
echo Y
echo $Env:PATH
echo Z
echo $Env:GITHUB_PATH
echo A
echo $Env:GITHUB_ENV
- name: Check if MPIR DLL is on the PATH
if: matrix.os.name == 'Windows'
run: |
$pathList = $Env:PATH -split ";"
foreach ($path in $pathList) {
if (Test-Path "$path\mpir.dll") {
Write-Output "Found mpir.dll in $path"
}
}
- name: Install libclang-dev on Linux
if: matrix.os.name == 'Ubuntu'
run: sudo apt-get install libclang-dev -y
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Tests
run: cargo test && cargo test --release
build_crate:
name: Build crate
needs: [lint, test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --release
- name: Prepare for publish
run: |
cd rust_bindings
cp -r ../src cpp
git clone https://github.com/Chia-Network/mpir_gc_x64.git
- name: Publish to crates.io (dry run)
# We use `--allow-dirty` because the `cpp` folder is copied into the working directory.
# This is necessary because the `cpp` folder is not part of the crate otherwise.
run: cargo publish --dry-run -p chiavdf --allow-dirty
- name: Upload crate artifacts
uses: actions/upload-artifact@v4
with:
name: crate
path: ./target/package/*-*.crate
- name: Set Env
uses: Chia-Network/actions/setjobenv@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to crates.io
if: env.RELEASE == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }}
# See comment above for why `--allow-dirty` is used.
run: |
cp -r src rust_bindings/cpp
cargo publish -p chiavdf --allow-dirty