-
Notifications
You must be signed in to change notification settings - Fork 53
306 lines (252 loc) · 9.11 KB
/
Copy pathelixir.yml
File metadata and controls
306 lines (252 loc) · 9.11 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
name: elixir
on:
push:
branches:
- main
tags:
- v*
pull_request:
workflow_dispatch:
inputs:
hex_repo:
description: "hex repo to publish to"
default: staging
required: true
options:
- staging
- prod
permissions:
contents: read
env:
# cache-busting key -- change it if the build changes in a way that invalidates old
# cached state
cache_key: init
package_artifact_base: ts_elixir-${{ github.sha }}
is_tag_push: ${{ startsWith(github.ref, 'refs/tags/') }}
is_dispatch: ${{ github.event_name == 'workflow_dispatch' }}
hex_environment: &hex_environment ${{ case(inputs.hex_repo == 'prod', 'hex.pm', startsWith(github.ref, 'refs/tags/'), 'hex.pm', 'staging.hex.pm') }}
latest_elixir: &latest_elixir 1.19.5
latest_otp: &latest_otp 28.4.2
latest_rust: &latest_rust 1.95.0
defaults:
run:
working-directory: ts_elixir
shell: bash
jobs:
build_test:
name: compile, test, static checks (elixir ${{ matrix.elixir.label }}, otp ${{ matrix.otp.label }}, rust ${{ matrix.rust_toolchain.label }}, platform ${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
elixir:
- version: *latest_elixir
label: latest
otp:
- version: *latest_otp
label: latest
rust_toolchain:
- version: *latest_rust
label: latest
platform:
- name: linux (x86_64)
runner: linux-x86_64-16cpu
triple: x86_64-unknown-linux-gnu
- name: linux (aarch64)
runner: linux-arm64-16cpu
triple: aarch64-unknown-linux-gnu
- name: macos
runner: macos-26
triple: aarch64-apple-darwin
- name: windows (x86_64)
runner: windows-8vcpu
triple: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Cache mix
id: cache-mix
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.mix
ts_elixir/_build/
ts_elixir/deps/
key: ${{ matrix.platform.triple }}-mix-${{ env.cache_key }}-elixir-${{ matrix.elixir.version }}-otp-${{ matrix.otp.version }}-${{ hashFiles('**/mix.lock') }}
# The setup-beam action uses the `ImageOS` env var to select the dependency bundle to
# download from Hex, and so it needs to be one of a few blessed values. GitHub seems
# to have changed how they set this variable recently, including `-arm` for aarch64
# linux. This broke `setup-beam`, so we put it back how it was here and restore
# afterwards.
- name: Override ImageOS
if: ${{ matrix.platform.runner == 'linux-arm64-16cpu' }}
run: |-
echo ImageOSPrev="$ImageOS" >> $GITHUB_ENV
echo ImageOS=ubuntu24 >> $GITHUB_ENV
- name: Install elixir
id: install-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # 1.24.0
with:
otp-version: ${{ matrix.otp.version }}
elixir-version: ${{ matrix.elixir.version }}
- name: Restore ImageOS
if: ${{ matrix.platform.runner == 'linux-arm64-16cpu' }}
run: |-
echo ImageOS="$ImageOSPrev" >> $GITHUB_ENV
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain-version: ${{ matrix.rust_toolchain.version }}
builder-triple: ${{ matrix.platform.triple }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Compile (MIX_ENV=dev)
run: mix compile --warnings-as-errors
- name: Compile (MIX_ENV=prod)
run: mix compile --warnings-as-errors
env:
MIX_ENV: prod
- name: Test
run: mix test
env:
# TODO(npry): testing tailnet + set TS_RS_TEST_AUTHKEY
TS_RS_TEST_NET: 0
- &detach_cargo_toml
name: Detach Cargo.toml from workspace
working-directory: ts_elixir/native/ts_elixir
run: |
pip install tomli-w
python deworkspace_cargo_toml.py \
--root ../../../Cargo.toml \
--repo_sha ${{ github.sha }} \
< Cargo.toml > Cargo.toml.new
mv Cargo.toml.new Cargo.toml
echo generated Cargo.toml:
cat Cargo.toml
- name: Build Hex package (no publish)
run: mix hex.build --unpack -o tailscale
env:
MIX_ENV: prod
- name: Upload package tarball
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.package_artifact_base }}-${{ matrix.platform.triple }}
path: ts_elixir/tailscale
arch_independent:
name: arch-independent checks
runs-on: linux-x86_64-16cpu
env:
target_triple: x86_64-unknown-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Cache mix
id: cache-mix
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.mix
ts_elixir/_build/
ts_elixir/deps/
key: ${{ env.target_triple }}-mix-${{ env.cache_key }}-elixir-${{ env.latest_elixir }}-otp-${{ env.latest_otp }}-${{ hashFiles('**/mix.lock') }}
- name: Install elixir
id: install-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # 1.24.0
with:
otp-version: ${{ env.latest_otp }}
elixir-version: ${{ env.latest_elixir }}
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain-version: ${{ env.latest_rust }}
builder-triple: ${{ env.target_triple }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Format
run: mix format --check-formatted
- name: Dialyzer
run: mix dialyzer --format github
- name: Credo
run: mix credo list --format oneline
- name: Docs
run: mix docs --warnings-as-errors
- name: Upload docs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: exdoc-${{ github.sha }}
path: ts_elixir/doc
retention-days: 7
publish:
name: publish
runs-on: linux-x86_64-16cpu
needs:
- build_test
- arch_independent
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
environment: *hex_environment
env:
target_triple: x86_64-unknown-linux-gnu
# Artifact generation, signing, upload, respectively
permissions:
attestations: write
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Cache mix
id: cache-mix
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.mix
ts_elixir/_build/
ts_elixir/deps/
key: ${{ runner.os }}-mix-${{ env.cache_key }}-elixir-${{ env.latest_elixir }}-otp-${{ env.latest_otp }}-${{ hashFiles('**/mix.lock') }}
- name: Install elixir
id: install-elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # 1.24.0
with:
otp-version: ${{ env.latest_otp }}
elixir-version: ${{ env.latest_elixir }}
- name: Setup rust
id: setup-rust
uses: ./.github/actions/setup-rust
with:
toolchain-version: ${{ env.latest_rust }}
builder-triple: ${{ env.target_triple }}
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
run: mix deps.compile
- name: Download built package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.package_artifact_base }}-${{ env.target_triple }}
path: ts_elixir/tailscale
- name: Generate attestation
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: ts_elixir/tailscale
- *detach_cargo_toml
- name: Publish deps to staging.hex.pm
if: ${{ env.hex_environment == 'staging.hex.pm' }}
run: python staging_publish_deps.py
env:
HEX_API_URL: ${{ vars.HEX_API_URL }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
- name: Publish (dry run)
run: mix hex.publish --dry-run --yes
env:
HEX_API_URL: ${{ vars.HEX_API_URL }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
- name: Publish
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
HEX_API_URL: ${{ vars.HEX_API_URL }}