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