Skip to content

ci: skip macOS work on PRs (#15) #15

ci: skip macOS work on PRs (#15)

ci: skip macOS work on PRs (#15) #15

Workflow file for this run

name: test native
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test Rust
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-24.04' || 'macos-15' }}
steps:
- uses: actions/checkout@v4
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}-test
repository-cache: true
- name: Test
run: bazel test //...
build:
name: Build native CLI binaries
needs: test
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-24.04' || 'macos-15' }}
steps:
- uses: actions/checkout@v4
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}-build
repository-cache: true
- name: Build native CLI binaries
run: |
set -euo pipefail
targets=(
//crates/codescythe_cli:release_binary_linux_amd64
//crates/codescythe_cli:release_binary_linux_arm64
)
if [ "${{ github.event_name }}" != "pull_request" ]; then
targets+=(//crates/codescythe_cli:release_binary_darwin_arm64)
fi
bazel build "${targets[@]}"
- name: Prepare smoke artifacts
run: |
set -euo pipefail
mkdir -p artifacts/binaries
copy_binary() {
local target="$1"
local output="$2"
local built_binary
built_binary="$(bazel cquery --output=files "$target" | tail -n 1)"
cp "$built_binary" "artifacts/binaries/$output"
chmod +x "artifacts/binaries/$output"
}
copy_binary //crates/codescythe_cli:release_binary_linux_amd64 codescythe-linux-amd64
copy_binary //crates/codescythe_cli:release_binary_linux_arm64 codescythe-linux-arm64
if [ "${{ github.event_name }}" != "pull_request" ]; then
copy_binary //crates/codescythe_cli:release_binary_darwin_arm64 codescythe-darwin-arm64
fi
- name: Upload Darwin arm64 binary
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: codescythe-binary-darwin-arm64
path: artifacts/binaries/codescythe-darwin-arm64
retention-days: 7
- name: Upload Linux amd64 binary
uses: actions/upload-artifact@v4
with:
name: codescythe-binary-linux-amd64
path: artifacts/binaries/codescythe-linux-amd64
retention-days: 7
- name: Upload Linux arm64 binary
uses: actions/upload-artifact@v4
with:
name: codescythe-binary-linux-arm64
path: artifacts/binaries/codescythe-linux-arm64
retention-days: 7
smoke:
name: Smoke test native CLI (${{ matrix.name }})
needs: build
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
runner: ubuntu-24.04
binary_artifact: codescythe-binary-linux-amd64
binary: codescythe-linux-amd64
- name: linux-arm64
runner: ubuntu-24.04-arm
binary_artifact: codescythe-binary-linux-arm64
binary: codescythe-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Download static binary
uses: actions/download-artifact@v4
with:
name: ${{ matrix.binary_artifact }}
path: smoke/bin
- name: Smoke test static binary
run: |
set -euo pipefail
binary="smoke/bin/${{ matrix.binary }}"
chmod +x "$binary"
file "$binary"
"$binary" --version
"$binary" --help
set +e
output="$("$binary" --json -C tests/fixtures/knip-export-basics)"
status="$?"
set -e
if [ "$status" -ne 1 ]; then
echo "expected fixture analysis to exit with 1, got $status" >&2
echo "$output"
exit 1
fi
echo "$output" | grep '"dangling.ts"'
if [ "${{ runner.os }}" = "Linux" ]; then
ldd_output="$(ldd "$binary" 2>&1 || true)"
echo "$ldd_output"
if echo "$ldd_output" | grep -Eq "not a dynamic executable|statically linked"; then
echo "$binary is static"
elif strings "$binary" | grep -q 'GLIBC_'; then
echo "$binary unexpectedly references glibc symbols" >&2
exit 1
else
echo "$binary has no GLIBC_ symbol references"
fi
fi
smoke_darwin:
name: Smoke test native CLI (darwin-arm64)
needs: build
if: ${{ github.event_name != 'pull_request' }}
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Download static binary
uses: actions/download-artifact@v4
with:
name: codescythe-binary-darwin-arm64
path: smoke/bin
- name: Smoke test static binary
run: |
set -euo pipefail
binary="smoke/bin/codescythe-darwin-arm64"
chmod +x "$binary"
file "$binary"
"$binary" --version
"$binary" --help
set +e
output="$("$binary" --json -C tests/fixtures/knip-export-basics)"
status="$?"
set -e
if [ "$status" -ne 1 ]; then
echo "expected fixture analysis to exit with 1, got $status" >&2
echo "$output"
exit 1
fi
echo "$output" | grep '"dangling.ts"'