Skip to content

feat(setup): add arm64 support and runner.arch input#208

Open
alexFilichkin wants to merge 1 commit into
snyk:masterfrom
alexFilichkin:feat-arm64-support
Open

feat(setup): add arm64 support and runner.arch input#208
alexFilichkin wants to merge 1 commit into
snyk:masterfrom
alexFilichkin:feat-arm64-support

Conversation

@alexFilichkin
Copy link
Copy Markdown

Problem

setup/setup_snyk.sh branches only on runner.os and unconditionally downloads the amd64 binary (e.g. snyk-linux). On arm64 runners — increasingly common with AWS CodeBuild, Apple Silicon self-hosted runners, and the GA ubuntu-24.04-arm images — the binary cannot exec:

/usr/local/bin/snyk: line 5: /usr/local/bin/snyk-linux: cannot execute binary file: Exec format error
Installed Snyk v        # empty version

Subsequent snyk invocations exit with code 126 (command found but not executable) in ~9 ms, masking the real failure. This was first hit in a real downstream workflow on a CodeBuild ARM64 runner.

Snyk already publishes arm64 binaries at the same CDN — snyk-linux-arm64, snyk-macos-arm64, snyk-alpine-arm64 (all return HTTP 200 from https://downloads.snyk.io/cli/latest/) — they're just never selected.

Change

  1. setup/setup_snyk.sh — accepts an optional 3rd positional arg for CPU architecture. When omitted, falls back to uname -m, so existing 2-arg callers keep working. New case statement maps:

    • X64 / x86_64 / amd64"" (default binary, unchanged behavior)
    • ARM64 / aarch64 / arm64-arm64
    • anything else → die with a clear message
    • arm64 is only accepted for platforms where Snyk publishes a binary (linux, macos, alpine).
    • Introduces BINARY="snyk-${PREFIX}${ARCH_SUFFIX}" so download/checksum/move all stay consistent.
  2. setup/action.yml — new optional arch input defaulting to ${{ runner.arch }}, plumbed through as the third arg.

Backwards compatibility

Runner OS Runner Arch Resolves to vs. today
Linux X64 / x86_64 snyk-linux unchanged
Linux ARM64 / aarch64 snyk-linux-arm64 fix
macOS X64 snyk-macos unchanged
macOS ARM64 snyk-macos-arm64 fix
Alpine X64 snyk-alpine unchanged
Alpine ARM64 snyk-alpine-arm64 fix
Windows * die (existing behavior) unchanged

Existing callers that pass only 2 args (version, OS) keep working because the script falls back to uname -m for the arch. The action's arch input defaults to runner.arch, so existing workflows that only set os (or accept the default) are unaffected.

Test plan

  • Smoke-tested all 8 OS×arch combinations through the case logic locally.
  • Verified the three new arm64 URLs (snyk-linux-arm64, snyk-macos-arm64, snyk-alpine-arm64) all return HTTP 200 from downloads.snyk.io/cli/latest/.
  • bash -n setup_snyk.sh passes.
  • CI on this PR.

The setup script previously branched only on `runner.os` and always
downloaded the amd64 binary (e.g. `snyk-linux`). On arm64 runners the
binary cannot exec, producing:

    /usr/local/bin/snyk: line 5: /usr/local/bin/snyk-linux: cannot execute binary file: Exec format error
    Installed Snyk v        # empty version

This change:

- Adds a third positional arg to setup_snyk.sh for the CPU architecture.
  When omitted, the script falls back to `uname -m` so existing 2-arg
  callers keep working.
- Maps X64/x86_64/amd64 → "" (default amd64 binary) and
  ARM64/aarch64/arm64 → "-arm64". arm64 binaries are downloaded only for
  platforms where Snyk publishes them (linux, macos, alpine — all
  verified against downloads.snyk.io/cli/latest).
- Adds an `arch` input on the composite action defaulting to
  `${{ runner.arch }}`, plumbed through as the new third arg.

Backwards compatible: existing X64/X86 Linux/macOS runners resolve to
the same binaries as before. The arch input is optional.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alexFilichkin alexFilichkin requested review from a team as code owners May 14, 2026 10:16
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented May 14, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant