Repository navigation
102 lines (87 loc) · 3.83 KB
/
Copy pathci.yml
File metadata and controls
102 lines (87 loc) · 3.83 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
# - quality: Linux と macOS で make setup と make ci だけを呼ぶ (検査の中身は Makefile の ci が決める)。
# macOS の make ci は apple-ai (fm-rs の Swift) もビルドするので、ランナーの Xcode (macOS 26 SDK 以降) を使う
# - build: release.yml の build と同じ組 (os / target) でビルドする。release.yml の dry_run では build が
# 走らないので、配布物を作れることはここで確かめる。Windows はここでテストも回す
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
quality:
name: Quality (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Windows は入れない。ランナーの make は MinGW の mingw32-make の写しで、レシピの POSIX シェル前提
# ($$(...) や [ -n ... ]) の解釈に癖がある。Windows のテストは build で cargo を直接呼ぶ
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
# ツールの版は mise.toml が正。mise 本体は公開から 14 日以上たった最新の版を、署名付きの checksum で
# 確かめて入れる。cache は切る (効いた回だけ clippy / rustfmt が欠ける。jdx/mise-action#215)
- uses: jdx/mise-action@v4
with:
minimum_release_age: 14d
cache: false
# target/ と ~/.cargo のキャッシュ (鍵に rustc の版が入るので、mise.toml の rust を上げると作り直す)
- uses: Swatinem/rust-cache@v2
- run: make setup
- run: make ci
build:
name: Build (${{ matrix.target }})
needs: quality
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# release.yml の build と同じ組 (行を足したら両方に足す)
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
# Windows のランナーは既定で LF を CRLF に変えて checkout する。release.yml の build と同じく LF のまま取り、
# テストの期待値や include_str! で埋め込むファイルの改行を配布物とそろえる
- name: Keep LF line endings
run: git config --global core.autocrlf false
- uses: actions/checkout@v7
with:
persist-credentials: false
# ビルドに効く環境変数 (MACOSX_DEPLOYMENT_TARGET など) は mise.toml の [env] に置く。mise-action が
# 後続のステップへ渡すので、ci.yml と release.yml と手元の make で同じ値になる
- uses: jdx/mise-action@v4
with:
minimum_release_age: 14d
cache: false
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# mise.toml の rust はホストのツールチェーンと components だけを入れるので、配布のターゲットを足す
- name: Add the Rust target
run: rustup target add ${{ matrix.target }}
# Windows は quality で make ci を回さないので、配る OS の裏付けとしてここでテストする
# (Makefile の test と同じく既定の feature で動かす)
- name: Test (Windows)
if: runner.os == 'Windows'
run: cargo test --locked
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}