-
Notifications
You must be signed in to change notification settings - Fork 110
197 lines (165 loc) · 5.53 KB
/
ci.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
on:
pull_request:
push:
branches: [main]
tags: ["v*"]
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTFLAGS: "-D warnings"
RUSTUP_MAX_RETRIES: 10
name: ci
jobs:
hygiene:
runs-on: ubuntu-22.04
steps:
- name: Setup | Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup | Checkout
uses: actions/checkout@v3
- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Setup | Tools
run: sudo apt-get install -y protobuf-compiler libtss2-dev
- name: Setup | Cache
uses: Swatinem/rust-cache@v2
- name: Build | Hygiene
run: |
cargo fmt -- --check
cargo clippy --all-features -- -D clippy::all
- name: Build | Test
run: |
cargo test
build:
runs-on: ubuntu-22.04
strategy:
matrix:
target:
- arm-unknown-linux-gnueabihf
- armv5te-unknown-linux-musleabi
- armv7-unknown-linux-musleabihf
- aarch64-unknown-linux-musl
- mips-unknown-linux-musl
- mipsel-unknown-linux-musl
- x86_64-unknown-debian-gnu
- x86_64-tpm-debian-gnu
steps:
- name: Setup | Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup | Checkout
uses: actions/checkout@v3
- name: Setup | Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup | Tools
uses: davidB/rust-cargo-make@v1
- name: Setup | Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Setup | Cross
uses: jaxxstorm/[email protected]
env:
## Allow cross install into PATH
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: rust-embedded/cross
- name: Build | Compile
run: cargo make --profile ${{ matrix.target }} build
- name: Buld | Package
run: cargo make --profile ${{ matrix.target }} pkg
- name: Build | Artifacts
uses: actions/upload-artifact@v3
with:
name: helium-gateway-${{ matrix.target }}
if-no-files-found: error
path: helium-gateway-*.tar.gz
release:
if: startsWith(github.ref, 'refs/tags')
needs: [hygiene, build]
runs-on: ubuntu-22.04
steps:
- name: Setup | Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup | Artifacts
uses: actions/download-artifact@v3
with:
path: helium-gateway-*.tar.gz
- name: Release | Artifacts
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fail_on_unmatched_files: true
files: |
**/helium-gateway-*.tar.gz
name: ${{github.ref_name}}
docker_buildx:
# Ensure we don't publish images until we pass clippy.
needs: [hygiene]
runs-on: ubuntu-22.04
steps:
- name: Setup | Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Setup | Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup | Docker
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Setup | Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_MINER_USER }}
password: ${{ secrets.QUAY_MINER_UPLOAD_TOKEN }}
- name: Setup | Image Tag
if: github.event_name == 'pull_request'
run: echo "image_tag=PR${{ github.event.pull_request.number }}-$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
- name: Setup | Image Tag
if: github.event_name != 'pull_request'
run: echo "image_tag=$(git describe)" >> $GITHUB_ENV
# We publish all builds to the test-images repo.
- name: Build | Test Image
uses: docker/build-push-action@v3
env:
# The attestation manifests cause build errors for some makers.
# See https://github.com/helium/gateway-rs/issues/409
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
with:
push: true
platforms: linux/amd64,linux/arm64
labels: VERSION=${{ env.image_tag }}
tags: quay.io/team-helium/test-images:gateway-${{ env.image_tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Publish to miner quay-repo on release only.
- name: Build | Release Image
if: startsWith(github.ref, 'refs/tags')
uses: docker/build-push-action@v3
env:
# The attestation manifests cause build errors for some makers.
# See https://github.com/helium/gateway-rs/issues/409
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
with:
push: true
platforms: linux/amd64,linux/arm64
labels: VERSION=${{ github.ref_name }}
tags: |
quay.io/team-helium/miner:gateway-${{ github.ref_name }}
quay.io/team-helium/miner:gateway-latest
cache-from: type=gha
cache-to: type=gha,mode=max