返回 CodeWhale
nightly.yml
根目录 / .github / workflows / nightly.yml
1 name: Nightly
2
3 # Manual artifact build for final release validation.
4 on:
5 workflow_dispatch:
6
7 permissions:
8 contents: read
9
10 concurrency:
11 group: nightly-${{ github.ref }}
12 cancel-in-progress: true
13
14 env:
15 CARGO_TERM_COLOR: always
16 CARGO_INCREMENTAL: 0
17 RUSTFLAGS: -Dwarnings
18 CODEWHALE_BUILD_SHA: ${{ github.sha }}
19
20 jobs:
21 build:
22 name: Build ${{ matrix.platform }}
23 # Native builds use the same finite cold-build allowance as release/CI.
24 timeout-minutes: 210
25 strategy:
26 fail-fast: false
27 matrix:
28 include:
29 - os: ubuntu-latest
30 target: x86_64-unknown-linux-gnu
31 platform: linux-x64
32 binary: codewhale
33 primary_artifact: codewhale-linux-x64
34 alias_artifact: codew-linux-x64
35 - os: ubuntu-24.04-arm
36 target: aarch64-unknown-linux-musl
37 platform: linux-arm64
38 binary: codewhale
39 primary_artifact: codewhale-linux-arm64
40 alias_artifact: codew-linux-arm64
41 - os: macos-latest
42 target: x86_64-apple-darwin
43 platform: macos-x64
44 binary: codewhale
45 primary_artifact: codewhale-macos-x64
46 alias_artifact: codew-macos-x64
47 - os: macos-latest
48 target: aarch64-apple-darwin
49 platform: macos-arm64
50 binary: codewhale
51 primary_artifact: codewhale-macos-arm64
52 alias_artifact: codew-macos-arm64
53 - os: windows-latest
54 target: x86_64-pc-windows-msvc
55 platform: windows-x64
56 binary: codewhale.exe
57 primary_artifact: codewhale-windows-x64.exe
58 alias_artifact: codew-windows-x64.exe
59 - os: windows-11-arm
60 target: aarch64-pc-windows-msvc
61 platform: windows-arm64
62 binary: codewhale.exe
63 primary_artifact: codewhale-windows-arm64.exe
64 alias_artifact: codew-windows-arm64.exe
65 runs-on: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu-24.04' || matrix.os }}
66 steps:
67 - uses: actions/checkout@v7
68 - uses: dtolnay/rust-toolchain@master
69 with:
70 toolchain: 1.100.0
71 targets: ${{ matrix.target }}
72 - uses: mozilla-actions/sccache-action@v0.0.11
73 with:
74 version: "v0.19.0"
75 id: sccache
76 continue-on-error: true
77 - name: Enable sccache
78 if: steps.sccache.outcome == 'success' && runner.os != 'Windows'
79 shell: bash
80 run: |
81 {
82 echo "SCCACHE_GHA_ENABLED=true"
83 echo "RUSTC_WRAPPER=sccache"
84 echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1"
85 echo "SCCACHE_IDLE_TIMEOUT=0"
86 } >> "${GITHUB_ENV}"
87 - uses: Swatinem/rust-cache@v2
88 with:
89 cache-bin: false
90 - name: Install Linux GNU system dependencies
91 if: matrix.target == 'x86_64-unknown-linux-gnu'
92 run: |
93 for i in 1 2 3 4 5; do
94 sudo apt-get update && break
95 echo "apt-get update failed (attempt $i); retrying in 15s"
96 sleep 15
97 done
98 sudo apt-get install -y libdbus-1-dev pkg-config
99 - name: Install Linux ARM64 musl toolchain
100 if: matrix.target == 'aarch64-unknown-linux-musl'
101 shell: bash
102 run: |
103 sudo apt-get update
104 sudo apt-get install -y binutils musl-tools
105 rustup target add aarch64-unknown-linux-musl
106 - name: Build
107 shell: bash
108 # Nightly artifacts are disposable smoke binaries (14-day retention),
109 # so skip fat LTO; tagged releases keep the full optimized profile via
110 # the Release workflow. (`codegen-units` is not overridden here --
111 # [profile.release] already sets 16, so restating it changed nothing.)
112 #
113 # RUST_MIN_STACK sizes the stack of the LLVM worker threads rustc
114 # spawns to run `optimize module <crate>-cgu.N`. With `lto=off` the
115 # per-CGU optimization pipeline runs while the *library* is compiled
116 # rather than being deferred to the ThinLTO stage, and one crates/tui
117 # codegen unit needs more stack than a 1 MiB thread provides. Measured
118 # on aarch64 by holding the crate and every flag fixed and varying only
119 # this value: 1 MiB crashes rustc, 2 MiB and 4 MiB succeed. Unix std
120 # defaults to 2 MiB and passes; windows-11-arm sat under the
121 # requirement and failed every nightly from 2026-08-16 with
122 # `thread 'optimize module codewhale_tui...-cgu.13' has overflowed its
123 # stack`, deterministically on the same codegen unit across all three
124 # build attempts. This is a property of the crate's size, not of
125 # Windows, so it is set for every target: at 788k lines in crates/tui
126 # the other platforms are one refactor away from crossing 2 MiB too.
127 # The value is reserved address space, not committed memory.
128 env:
129 CARGO_PROFILE_RELEASE_LTO: 'off'
130 RUST_MIN_STACK: '16777216'
131 run: |
132 for attempt in 1 2 3; do
133 if cargo build --release --locked --target ${{ matrix.target }} -p codewhale-cli; then
134 exit 0
135 fi
136 if [ "${attempt}" -lt 3 ]; then
137 echo "Build attempt ${attempt} failed; retrying in 30s..."
138 sleep 30
139 fi
140 done
141 echo "Build failed after 3 attempts" >&2
142 exit 1
143 - name: Verify static Linux ARM64 binary and launch
144 if: matrix.target == 'aarch64-unknown-linux-musl' && runner.arch == 'ARM64'
145 shell: bash
146 run: |
147 set -euo pipefail
148 bin_path="target/${{ matrix.target }}/release/${{ matrix.binary }}"
149 if readelf -l "${bin_path}" | grep -Fq 'INTERP'; then
150 echo "Expected a static musl binary, but ${bin_path} has an ELF interpreter" >&2
151 exit 1
152 fi
153 "${bin_path}" --version
154 - name: Smoke binary on matching native runners
155 if: >-
156 (startsWith(matrix.target, 'x86_64-') && runner.arch == 'X64') ||
157 (startsWith(matrix.target, 'aarch64-') && runner.arch == 'ARM64')
158 shell: bash
159 run: |
160 bin_dir="target/${{ matrix.target }}/release"
161 "${bin_dir}/${{ matrix.binary }}" --version
162 - name: Stage artifact
163 id: stage
164 shell: bash
165 run: |
166 short_sha="${GITHUB_SHA::12}"
167 bin_path="target/${{ matrix.target }}/release/${{ matrix.binary }}"
168 if [ ! -f "${bin_path}" ]; then
169 echo "Binary not at ${bin_path}; searching target/ for ${{ matrix.binary }}:"
170 find target -name "${{ matrix.binary }}" -type f
171 exit 1
172 fi
173
174 stage_copy() {
175 local artifact="$1"
176 local dir="$2"
177 mkdir -p "${dir}"
178 cp "${bin_path}" "${dir}/${artifact}"
179 cat > "${dir}/nightly-build-info.txt" <<INFO
180 repository=${GITHUB_REPOSITORY}
181 ref=${GITHUB_REF_NAME}
182 commit=${GITHUB_SHA}
183 artifact=${artifact}
184 profile=release-nightly-no-lto
185 INFO
186 }
187
188 stage_copy "${{ matrix.primary_artifact }}" nightly-primary
189 stage_copy "${{ matrix.alias_artifact }}" nightly-alias
190 cmp -s \
191 "nightly-primary/${{ matrix.primary_artifact }}" \
192 "nightly-alias/${{ matrix.alias_artifact }}"
193 echo "primary_name=${{ matrix.primary_artifact }}-${short_sha}" >> "${GITHUB_OUTPUT}"
194 echo "alias_name=${{ matrix.alias_artifact }}-${short_sha}" >> "${GITHUB_OUTPUT}"
195 - uses: actions/upload-artifact@v7
196 with:
197 name: ${{ steps.stage.outputs.primary_name }}
198 path: nightly-primary/*
199 retention-days: 14
200 - uses: actions/upload-artifact@v7
201 with:
202 name: ${{ steps.stage.outputs.alias_name }}
203 path: nightly-alias/*
204 retention-days: 14
205
205 lines YAML