Repository navigation
Fix macOS ARM64 smoke test: permissions, Docker, and AWF install #16910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,10 @@ | |
| # Arguments: | ||
| # VERSION - AWF version to install (e.g., v0.10.0) | ||
| # | ||
| # Platform support: | ||
| # - Linux (x64, arm64): Downloads pre-built binary | ||
| # - macOS (x64, arm64): Downloads pre-built binary | ||
| # | ||
| # Security features: | ||
| # - Downloads binary directly from GitHub releases | ||
| # - Verifies SHA256 checksum against official checksums.txt | ||
|
|
@@ -19,7 +23,6 @@ set -euo pipefail | |
| # Configuration | ||
| AWF_VERSION="${1:-}" | ||
| AWF_REPO="github/gh-aw-firewall" | ||
| AWF_BINARY="awf-linux-x64" | ||
| AWF_INSTALL_DIR="/usr/local/bin" | ||
| AWF_INSTALL_NAME="awf" | ||
|
|
||
|
|
@@ -29,49 +32,120 @@ if [ -z "$AWF_VERSION" ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| echo "Installing awf binary with checksum verification (version: ${AWF_VERSION})" | ||
| # Detect OS and architecture | ||
| OS="$(uname -s)" | ||
| ARCH="$(uname -m)" | ||
|
|
||
| echo "Installing awf with checksum verification (version: ${AWF_VERSION}, os: ${OS}, arch: ${ARCH})" | ||
|
|
||
| # Download URLs | ||
| BASE_URL="https://github.com/${AWF_REPO}/releases/download/${AWF_VERSION}" | ||
| BINARY_URL="${BASE_URL}/${AWF_BINARY}" | ||
| CHECKSUMS_URL="${BASE_URL}/checksums.txt" | ||
|
|
||
| # Platform-portable SHA256 function | ||
| sha256_hash() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice cross-platform |
||
| local file="$1" | ||
| if command -v sha256sum &>/dev/null; then | ||
| sha256sum "$file" | awk '{print $1}' | ||
| elif command -v shasum &>/dev/null; then | ||
| shasum -a 256 "$file" | awk '{print $1}' | ||
| else | ||
| echo "ERROR: No sha256sum or shasum found" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # Create temp directory | ||
| TEMP_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$TEMP_DIR"' EXIT | ||
|
|
||
| # Download binary and checksums | ||
| echo "Downloading binary from ${BINARY_URL@Q}..." | ||
| curl -fsSL -o "${TEMP_DIR}/${AWF_BINARY}" "${BINARY_URL}" | ||
|
|
||
| # Download checksums | ||
| echo "Downloading checksums from ${CHECKSUMS_URL@Q}..." | ||
| curl -fsSL -o "${TEMP_DIR}/checksums.txt" "${CHECKSUMS_URL}" | ||
|
|
||
| # Verify checksum | ||
| echo "Verifying SHA256 checksum..." | ||
| cd "${TEMP_DIR}" | ||
| EXPECTED_CHECKSUM=$(awk -v fname="${AWF_BINARY}" '$2 == fname {print $1; exit}' checksums.txt | tr 'A-F' 'a-f') | ||
|
|
||
| if [ -z "$EXPECTED_CHECKSUM" ]; then | ||
| echo "ERROR: Could not find checksum for ${AWF_BINARY} in checksums.txt" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ACTUAL_CHECKSUM=$(sha256sum "${AWF_BINARY}" | awk '{print $1}' | tr 'A-F' 'a-f') | ||
|
|
||
| if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | ||
| echo "ERROR: Checksum verification failed!" | ||
| echo " Expected: $EXPECTED_CHECKSUM" | ||
| echo " Got: $ACTUAL_CHECKSUM" | ||
| echo " The downloaded file may be corrupted or tampered with" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✓ Checksum verification passed" | ||
|
|
||
| # Make binary executable and install | ||
| chmod +x "${AWF_BINARY}" | ||
| sudo mv "${AWF_BINARY}" "${AWF_INSTALL_DIR}/${AWF_INSTALL_NAME}" | ||
| verify_checksum() { | ||
| local file="$1" | ||
| local fname="$2" | ||
|
|
||
| echo "Verifying SHA256 checksum for ${fname}..." | ||
| EXPECTED_CHECKSUM=$(awk -v fname="${fname}" '$2 == fname {print $1; exit}' "${TEMP_DIR}/checksums.txt" | tr 'A-F' 'a-f') | ||
|
|
||
| if [ -z "$EXPECTED_CHECKSUM" ]; then | ||
| echo "ERROR: Could not find checksum for ${fname} in checksums.txt" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ACTUAL_CHECKSUM=$(sha256_hash "$file" | tr 'A-F' 'a-f') | ||
|
|
||
| if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | ||
| echo "ERROR: Checksum verification failed!" | ||
| echo " Expected: $EXPECTED_CHECKSUM" | ||
| echo " Got: $ACTUAL_CHECKSUM" | ||
| echo " The downloaded file may be corrupted or tampered with" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✓ Checksum verification passed for ${fname}" | ||
| } | ||
|
|
||
| install_linux_binary() { | ||
| # Determine binary name based on architecture | ||
| local awf_binary | ||
| case "$ARCH" in | ||
| x86_64|amd64) awf_binary="awf-linux-x64" ;; | ||
| aarch64|arm64) awf_binary="awf-linux-arm64" ;; | ||
| *) echo "ERROR: Unsupported Linux architecture: ${ARCH}"; exit 1 ;; | ||
| esac | ||
|
|
||
| local binary_url="${BASE_URL}/${awf_binary}" | ||
| echo "Downloading binary from ${binary_url@Q}..." | ||
| curl -fsSL -o "${TEMP_DIR}/${awf_binary}" "${binary_url}" | ||
|
|
||
| # Verify checksum | ||
| verify_checksum "${TEMP_DIR}/${awf_binary}" "${awf_binary}" | ||
|
|
||
| # Make binary executable and install | ||
| chmod +x "${TEMP_DIR}/${awf_binary}" | ||
| sudo mv "${TEMP_DIR}/${awf_binary}" "${AWF_INSTALL_DIR}/${AWF_INSTALL_NAME}" | ||
| } | ||
|
|
||
| install_darwin_binary() { | ||
| # Determine binary name based on architecture | ||
| local awf_binary | ||
| case "$ARCH" in | ||
| x86_64) awf_binary="awf-darwin-x64" ;; | ||
| arm64) awf_binary="awf-darwin-arm64" ;; | ||
| *) echo "ERROR: Unsupported macOS architecture: ${ARCH}"; exit 1 ;; | ||
| esac | ||
|
|
||
| echo "Note: AWF uses iptables for network firewalling, which is not available on macOS." | ||
| echo " The AWF CLI will be installed but container-based firewalling will not work natively." | ||
| echo "" | ||
|
|
||
| local binary_url="${BASE_URL}/${awf_binary}" | ||
| echo "Downloading binary from ${binary_url@Q}..." | ||
| curl -fsSL -o "${TEMP_DIR}/${awf_binary}" "${binary_url}" | ||
|
|
||
| # Verify checksum | ||
| verify_checksum "${TEMP_DIR}/${awf_binary}" "${awf_binary}" | ||
|
|
||
| # Make binary executable and install | ||
| chmod +x "${TEMP_DIR}/${awf_binary}" | ||
| sudo mv "${TEMP_DIR}/${awf_binary}" "${AWF_INSTALL_DIR}/${AWF_INSTALL_NAME}" | ||
| } | ||
|
|
||
| case "$OS" in | ||
| Linux) | ||
| install_linux_binary | ||
| ;; | ||
| Darwin) | ||
| install_darwin_binary | ||
| ;; | ||
| *) | ||
| echo "ERROR: Unsupported operating system: ${OS}" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Verify installation | ||
| which awf | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/env bash | ||
| # Install Docker on macOS GitHub Actions runners via colima | ||
| # Usage: install_docker_macos.sh | ||
| # | ||
| # macOS GHA runners (macos-latest / macos-15-arm64) do not include Docker. | ||
| # This script installs colima (a lightweight Docker runtime for macOS) and the | ||
| # Docker CLI via Homebrew, then starts colima with Apple's Virtualization | ||
| # framework (vz) for native ARM64 performance. | ||
| # | ||
| # On Linux runners, Docker is pre-installed so this script exits early. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Skip on non-macOS systems (Linux runners already have Docker) | ||
| if [ "$(uname -s)" != "Darwin" ]; then | ||
| echo "Not macOS — skipping Docker installation (Docker is pre-installed on Linux runners)" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Check if Docker is already available and running | ||
| if command -v docker &>/dev/null && docker info &>/dev/null; then | ||
| echo "Docker is already installed and running — skipping installation" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Installing Docker on macOS via colima..." | ||
|
|
||
| # Install colima and docker CLI via Homebrew | ||
| echo "Installing colima and docker CLI..." | ||
| brew install colima docker | ||
|
|
||
| # Start colima with ARM64 architecture and Apple Virtualization framework | ||
| # - --arch aarch64: native ARM64 for Apple Silicon runners | ||
| # - --vm-type vz: Apple's Virtualization.framework (faster than QEMU) | ||
| # - --memory 4: 4GB RAM for the VM (sufficient for agent containers) | ||
| echo "Starting colima..." | ||
| colima start --arch aarch64 --vm-type=vz --memory 4 | ||
|
|
||
| # Verify Docker is working | ||
| echo "Verifying Docker installation..." | ||
| if ! docker info &>/dev/null; then | ||
| echo "ERROR: Docker is not responding after colima start" | ||
| colima status || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker version | ||
| echo "Docker installation complete" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
create_dirhelper cleanly abstracts the macOSsudorequirement. Consider adding a comment clarifying why ownership must be transferred back to the current user (so subsequent non-sudo writes succeed).