-
Notifications
You must be signed in to change notification settings - Fork 4
172 lines (163 loc) · 5.24 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
name: Rust
on:
push:
pull_request:
release:
types: [released]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update -y && sudo apt-get install -y knot-dnsutils
- uses: dtolnay/rust-toolchain@stable
id: "rust-toolchain"
- name: install cargo-all-features
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-all-features
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} Lock ${{hashFiles('Cargo.lock')}}"
- run: cargo test-all-features --locked -- --include-ignored
env:
RUST_BACKTRACE: 1
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check
benchmark:
name: bench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust Bench ${{steps.rust-toolchain.outputs.cachekey}} Lock ${{hashFiles('Cargo.lock')}}"
- name: Run benchmark
run: cargo +nightly bench
cargo_publish:
if: ${{ github.event_name == 'release' }}
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: msrd0/cargo-publish-action@v1
with:
packages: crab-hole
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
cross_build:
strategy:
fail-fast: false
matrix:
target: [i686-unknown-linux-musl, x86_64-unknown-linux-musl, arm-unknown-linux-musleabihf, armv7-unknown-linux-musleabihf, aarch64-unknown-linux-musl, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-gnu]
roots: [native-roots, webpki-roots]
name: ${{ matrix.target }}--${{ matrix.roots }}
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
id: "rust-toolchain"
- name: install cross
uses: baptiste0928/cargo-install@v2
with:
crate: cross
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Target ${{ matrix.target }} Rust ${{steps.rust-toolchain.outputs.cachekey}} Lock ${{hashFiles('Cargo.lock')}}"
- run: cross build --release --locked --no-default-features --features ${{ matrix.roots }} --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- run: tree
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.target }}--${{ matrix.roots }}"
path: |
target/${{ matrix.target }}/release/crab-hole
target/${{ matrix.target }}/release/crab-hole.exe
build_x86_64-apple-darwin:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
roots: [native-roots, webpki-roots]
name: x86_64-apple-darwin--${{ matrix.roots }}
needs: [test]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
id: "rust-toolchain"
- uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}} Lock ${{hashFiles('Cargo.lock')}}"
- run: cargo build --release --all-features
env:
RUST_BACKTRACE: 1
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: "x86_64-apple-darwin--${{ matrix.roots }}"
path: target/release/crab-hole
docker:
runs-on: ubuntu-latest
needs: [cross_build]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: github_artifacts
- name: docker
uses: LuckyTurtleDev/easy-docker-action@main
with:
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
max_parallelism: 1
github_publish:
runs-on: ubuntu-latest
needs: [cross_build]
if: ${{ github.event_name == 'release' }}
steps:
- name: Checkout repository #needed to get github.event.release.tag_name
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: github_artifacts
- name: Upload Release Artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ github.event.release.tag_name }}
run: |
for dir in github_artifacts/*; do
dir=${dir#github_artifacts/}
cd github_artifacts
zip -r ${dir}.zip ${dir}
gh release upload ${RELEASE_NAME} ${dir}.zip
rm ${dir}.zip
cd ..
done