-
Notifications
You must be signed in to change notification settings - Fork 11
132 lines (114 loc) · 3.33 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
name: Rust bindings
on:
push:
branches:
- main
release:
types: [published]
pull_request:
branches:
- "**"
concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true
jobs:
build:
name: Build - ${{ 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, ARM64]
intel: [macos-12]
- 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
defaults:
run:
working-directory: ./rust-bindings
steps:
- uses: actions/checkout@v4
- name: Set Env
uses: Chia-Network/actions/setjobenv@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Clang on Ubuntu ARM
if: matrix.os.name == 'Ubuntu' && matrix.arch.name == 'ARM'
run: sudo apt-get install -y clang
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build
run: cargo build --release
- name: Test
run: cargo test
- name: Test (Release)
run: cargo test --release
- name: Check formatting
run: cargo fmt -- --check
- name: Check clippy
run: cargo clippy --all-targets --all-features -- -D warnings
fuzz_targets:
name: Run Fuzzer
runs-on: ubuntu-latest
env:
CARGO_PROFILE_RELEASE_LTO: false
defaults:
run:
working-directory: ./rust-bindings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: cargo-fuzz
run: cargo +nightly install cargo-fuzz
- name: cargo fuzz
run: |
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=120 || exit 255"
publish:
name: Publish to Crates.io
needs: [build, fuzz_targets]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./rust-bindings
steps:
- uses: actions/checkout@v4
- name: Set Env
uses: Chia-Network/actions/setjobenv@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Create release
if: env.RELEASE == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
ln -s ../src ./cpp
cargo publish --allow-dirty