diff --git a/.github/scripts/smoke.sh b/.github/scripts/smoke.sh new file mode 100755 index 0000000..0b67559 --- /dev/null +++ b/.github/scripts/smoke.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Runs a freshly built floci binary through the paths a native image can get wrong while the JVM +# build stays green: startup, every product tree's command wiring, a Jackson read, and the +# parameter-error path. No emulator or Docker daemon is needed. +# +# .github/scripts/smoke.sh [expected-version] +set -euo pipefail + +bin="$1" +expected="${2:-}" + +"$bin" version + +if [ -n "$expected" ]; then + reported=$("$bin" version -o json | tr -d ' \r\n') + case "$reported" in + *"\"cli\":\"$expected\""*) ;; + *) echo "::error::$bin reports $reported, expected cli version $expected"; exit 1 ;; + esac +fi + +for tree in aws gcp az oci; do + "$bin" "$tree" --help > /dev/null +done + +"$bin" config profile list -o json > /dev/null + +# An unknown profile is a usage error: exit 2, not a crash. +set +e +"$bin" start --profile floci-smoke-no-such-profile > /dev/null 2>&1 +code=$? +set -e +if [ "$code" -ne 2 ]; then + echo "::error::'start --profile ' exited $code, expected 2" + exit 1 +fi + +echo "smoke test passed: $bin" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b69a0a..f0daa03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,8 +67,30 @@ jobs: awk -v b="$bytes" -v max="$NATIVE_SIZE_BUDGET_MB" 'BEGIN { exit (b / 1048576 > max) }' \ || { echo "::error::Native binary is ${mb} MB, over the ${NATIVE_SIZE_BUDGET_MB} MB budget."; exit 1; } - - name: Smoke test — version - run: ./target/floci version + - name: Smoke test + run: .github/scripts/smoke.sh ./target/floci - name: Smoke test — doctor run: ./target/floci doctor || true + + # The release builds linux/amd64 too; building it here catches an amd64-only native failure in + # review instead of at release time. + native-linux-amd64: + name: Native image (linux/amd64) + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '25' + distribution: 'graalvm-community' + cache: maven + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build native binary + run: mvn clean package -Pnative -DskipTests -B + + - name: Smoke test + run: .github/scripts/smoke.sh ./target/floci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae0b945..6980d10 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,8 @@ name: Release # Triggered when a SemVer tag (e.g. 0.1.0) is pushed. -# Builds native binaries for 4 platform targets and creates a GitHub Release. +# Builds native binaries for 5 platform targets, runs each one (.github/scripts/smoke.sh) and +# creates a GitHub Release. A binary that does not start fails its job before anything is published. on: push: @@ -30,6 +31,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - run: mvn clean package -Pnative -DskipTests -B - run: mv target/floci target/floci-linux-amd64 + - name: Smoke test + run: .github/scripts/smoke.sh target/floci-linux-amd64 "$GITHUB_REF_NAME" - uses: actions/upload-artifact@v4 with: name: floci-linux-amd64 @@ -49,6 +52,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - run: mvn clean package -Pnative -DskipTests -B - run: mv target/floci target/floci-linux-arm64 + - name: Smoke test + run: .github/scripts/smoke.sh target/floci-linux-arm64 "$GITHUB_REF_NAME" - uses: actions/upload-artifact@v4 with: name: floci-linux-arm64 @@ -68,6 +73,8 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - run: mvn clean package -Pnative -DskipTests -B - run: mv target/floci target/floci-darwin-arm64 + - name: Smoke test + run: .github/scripts/smoke.sh target/floci-darwin-arm64 "$GITHUB_REF_NAME" - uses: actions/upload-artifact@v4 with: name: floci-darwin-arm64 @@ -107,6 +114,8 @@ jobs: run: file target/floci | grep -q x86_64 - run: mv target/floci target/floci-darwin-amd64 + - name: Smoke test + run: .github/scripts/smoke.sh target/floci-darwin-amd64 "$GITHUB_REF_NAME" - uses: actions/upload-artifact@v4 with: name: floci-darwin-amd64 @@ -126,6 +135,9 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - run: mvn clean package -Pnative -DskipTests -B - run: mv target/floci.exe target/floci-windows-amd64.exe + - name: Smoke test + shell: bash + run: .github/scripts/smoke.sh target/floci-windows-amd64.exe "$GITHUB_REF_NAME" - uses: actions/upload-artifact@v4 with: name: floci-windows-amd64