Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 14 additions & 70 deletions .github/actions/build-rust-binary/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ inputs:
triple:
description: Rust target triple
required: true
dev-shell:
description: Nix development shell used to build the binary
required: true
cargo-version:
description: Cargo package version embedded in the binary
required: true
Expand All @@ -32,20 +29,16 @@ inputs:
description: Additional flags passed to cargo build
required: false
default: ""
interpreter:
description: ELF interpreter for a dynamically linked Linux binary
required: false
default: ""

runs:
using: composite
steps:
- name: Hash development shell
id: dev-shell
shell: bash
env:
DEV_SHELL: ${{ inputs.dev-shell }}
run: echo "hash=$(nix hash file --type sha256 --base16 "$(nix eval --raw "${DEV_SHELL}.drvPath")")" >> "$GITHUB_OUTPUT"
run: |
shell_drv=$(nix eval --raw --impure .#devShells --apply 'shells: shells.${builtins.currentSystem}.default.drvPath')
echo "hash=$(nix hash file --type sha256 --base16 "$shell_drv")" >> "$GITHUB_OUTPUT"

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
Expand All @@ -54,90 +47,41 @@ runs:
cache-on-failure: "true"
cache-workspace-crates: "true"
cache-bin: "false"
cmd-format: nix develop ${{ inputs.dev-shell }} -c {0}
cmd-format: nix develop -c {0}

- name: Set version
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
shell: nix develop -c bash -euo pipefail {0}
env:
INPUTS_CARGO_VERSION: ${{ inputs.cargo-version }}
run: sed -i "s/^version = \"0\\.0\\.0\"$/version = \"${INPUTS_CARGO_VERSION}\"/" Cargo.toml

- name: Build ${{ inputs.binary }}
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
shell: nix develop -c bash -euo pipefail {0}
env:
GIT_DIR: /nonexistent
OPENSHELL_IMAGE_TAG: ${{ inputs.image-tag }}
INPUTS_PACKAGE: ${{ inputs.package }}
INPUTS_BINARY: ${{ inputs.binary }}
INPUTS_TRIPLE: ${{ inputs.triple }}
INPUTS_EXTRA_CARGO_FLAGS: ${{ inputs.extra-cargo-flags }}
run: GIT_DIR=/nonexistent cargo auditable build --release --package "${INPUTS_PACKAGE}" --bin "${INPUTS_BINARY}" ${INPUTS_EXTRA_CARGO_FLAGS}

- name: Normalize Darwin dynamic binary
if: endsWith(inputs.triple, '-apple-darwin')
shell: bash -euo pipefail {0}
env:
INPUTS_BINARY: ${{ inputs.binary }}
run: |
binary=target/release/${INPUTS_BINARY}
nix_iconv_paths=$(otool -L "$binary" | awk '$1 ~ "^/nix/store/.*/lib/libiconv\\.2\\.dylib$" { print $1 }')
if [[ -n "$nix_iconv_paths" ]]; then
while IFS= read -r nix_iconv_path; do
install_name_tool -change "$nix_iconv_path" /usr/lib/libiconv.2.dylib "$binary"
done <<< "$nix_iconv_paths"
codesign --force --sign - "$binary"
fi

- name: Verify Darwin portability
if: endsWith(inputs.triple, '-apple-darwin')
shell: bash -euo pipefail {0}
env:
INPUTS_BINARY: ${{ inputs.binary }}
run: |
binary=target/release/${INPUTS_BINARY}
nix_dependencies=$(otool -L "$binary" | awk '$1 ~ "^/nix/store/" { print $1 }')
if [[ -n "$nix_dependencies" ]]; then
echo "error: $binary has non-portable Nix store dependencies:" >&2
printf ' %s\n' "$nix_dependencies" >&2
exit 1
fi
codesign --verify --verbose=2 "$binary"
run: cargo auditable build --release --target "${INPUTS_TRIPLE}" --package "${INPUTS_PACKAGE}" --bin "${INPUTS_BINARY}" ${INPUTS_EXTRA_CARGO_FLAGS}

- name: Verify ${{ inputs.binary }}
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
shell: nix develop -c bash -euo pipefail {0}
env:
INPUTS_BINARY: ${{ inputs.binary }}
INPUTS_TRIPLE: ${{ inputs.triple }}
run: |
# Confirm the binary runs and reports the expected name.
target/release/${INPUTS_BINARY} --version | grep -q "^${INPUTS_BINARY} "
target/${INPUTS_TRIPLE}/release/${INPUTS_BINARY} --version | grep -q "^${INPUTS_BINARY} "
# Confirm Syft can decode the embedded cargo-auditable metadata.
SYFT_CHECK_FOR_APP_UPDATE=false syft file:target/release/${INPUTS_BINARY} -o cyclonedx-json | grep 'pkg:cargo/' > /dev/null

- name: Verify static linkage
if: endsWith(inputs.triple, '-linux-musl')
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
env:
INPUTS_BINARY: ${{ inputs.binary }}
run: tasks/scripts/verify-static-binary.sh target/release/${INPUTS_BINARY}

- name: Normalize Linux dynamic binary
if: endsWith(inputs.triple, '-linux-gnu')
shell: nix develop ${{ inputs.dev-shell }} -c bash -euo pipefail {0}
env:
INPUTS_BINARY: ${{ inputs.binary }}
INPUTS_INTERPRETER: ${{ inputs.interpreter }}
run: |
binary=target/release/${INPUTS_BINARY}
# Remove Nix store paths so the binary can run on other distributions.
patchelf --set-interpreter "${INPUTS_INTERPRETER}" --remove-rpath "$binary"
# Z3 must be embedded instead of loaded from the target system.
test -z "$(patchelf --print-needed "$binary" | grep '^libz3')"
# Reject symbols introduced after glibc 2.28.
tasks/scripts/verify-glibc-symbols.sh 2.28 "$binary"
SYFT_CHECK_FOR_APP_UPDATE=false syft file:target/${INPUTS_TRIPLE}/release/${INPUTS_BINARY} -o cyclonedx-json | grep 'pkg:cargo/' > /dev/null

- name: Upload ${{ inputs.binary }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ inputs.artifact-name || format('{0}-{1}', inputs.binary, inputs.triple) }}
path: target/release/${{ inputs.binary }}
path: target/${{ inputs.triple }}/release/${{ inputs.binary }}
compression-level: 0
retention-days: 5
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/branch-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
- runner: macos-15-xlarge
system: aarch64-darwin
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
timeout-minutes: 90
defaults:
run:
shell: nix develop .#devShells.${{ matrix.system }}.default -c bash -euo pipefail {0}
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/branch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,15 @@ jobs:
include:
- triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.musl
- triple: aarch64-unknown-linux-musl
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.musl
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-conformance-cli
binary: openshell-conformance
artifact-name: openshell-conformance-${{ matrix.triple }}
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ needs.version.outputs.cargo }}
secrets: inherit

Expand Down Expand Up @@ -158,23 +155,17 @@ jobs:
include:
- triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.glibc-2-28
interpreter: /lib64/ld-linux-x86-64.so.2
- triple: aarch64-unknown-linux-gnu
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.glibc-2-28
interpreter: /lib/ld-linux-aarch64.so.1
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-gateway
binary: openshell-gateway
artifact-name: openshell-gateway-plain-${{ matrix.triple }}
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ needs.version.outputs.cargo }}
extra-cargo-flags: --no-default-features
interpreter: ${{ matrix.interpreter }}
secrets: inherit

build-driver-docker:
Expand All @@ -188,9 +179,7 @@ jobs:
binary: openshell-driver-docker
triple: aarch64-unknown-linux-gnu
runner: linux-arm64-cpu8
dev-shell: .#devShells.aarch64-linux.glibc-2-28
cargo-version: ${{ needs.version.outputs.cargo }}
interpreter: /lib/ld-linux-aarch64.so.1
secrets: inherit

build-driver-podman:
Expand All @@ -204,9 +193,7 @@ jobs:
binary: openshell-driver-podman
triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev-shell: .#devShells.x86_64-linux.glibc-2-28
cargo-version: ${{ needs.version.outputs.cargo }}
interpreter: /lib64/ld-linux-x86-64.so.2
secrets: inherit

build-driver-kubernetes:
Expand All @@ -220,9 +207,7 @@ jobs:
binary: openshell-driver-kubernetes
triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev-shell: .#devShells.x86_64-linux.glibc-2-28
cargo-version: ${{ needs.version.outputs.cargo }}
interpreter: /lib64/ld-linux-x86-64.so.2
secrets: inherit

build-vm-driver:
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ on:
runner:
required: true
type: string
dev-shell:
required: true
type: string
cargo-version:
required: true
type: string
Expand All @@ -36,10 +33,6 @@ on:
required: false
type: string
default: ""
interpreter:
required: false
type: string
default: ""
checkout-ref:
required: false
type: string
Expand Down Expand Up @@ -70,9 +63,7 @@ jobs:
package: ${{ inputs.package }}
binary: ${{ inputs.binary }}
triple: ${{ inputs.triple }}
dev-shell: ${{ inputs['dev-shell'] }}
cargo-version: ${{ inputs['cargo-version'] }}
image-tag: ${{ inputs['image-tag'] }}
artifact-name: ${{ inputs['artifact-name'] }}
extra-cargo-flags: ${{ inputs['extra-cargo-flags'] }}
interpreter: ${{ inputs.interpreter }}
4 changes: 0 additions & 4 deletions .github/workflows/build-cli-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ jobs:
include:
- triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.musl
- triple: aarch64-unknown-linux-musl
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.musl
- triple: aarch64-apple-darwin
runner: macos-15-xlarge
dev_shell: .#devShells.aarch64-darwin.default
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-cli
binary: openshell
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ inputs.cargo-version }}
image-tag: ${{ inputs.image-tag }}
checkout-ref: ${{ inputs.checkout-ref }}
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/build-gateway-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,17 @@ jobs:
include:
- triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.glibc-2-28
interpreter: /lib64/ld-linux-x86-64.so.2
- triple: aarch64-unknown-linux-gnu
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.glibc-2-28
interpreter: /lib/ld-linux-aarch64.so.1
- triple: aarch64-apple-darwin
runner: macos-15-xlarge
dev_shell: .#devShells.aarch64-darwin.default
interpreter: ""
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-gateway
binary: openshell-gateway
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ inputs.cargo-version }}
image-tag: ${{ inputs.image-tag }}
interpreter: ${{ matrix.interpreter }}
checkout-ref: ${{ inputs.checkout-ref }}
secrets: inherit
3 changes: 0 additions & 3 deletions .github/workflows/build-sandbox-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@ jobs:
include:
- triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.musl
- triple: aarch64-unknown-linux-musl
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.musl
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-sandbox
binary: openshell-sandbox
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ inputs.cargo-version }}
image-tag: ${{ inputs.image-tag }}
checkout-ref: ${{ inputs.checkout-ref }}
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/build-vm-driver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,17 @@ jobs:
- arch: x86_64
triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.glibc-2-28
interpreter: /lib64/ld-linux-x86-64.so.2
- arch: aarch64
triple: aarch64-unknown-linux-gnu
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.glibc-2-28
interpreter: /lib/ld-linux-aarch64.so.1
- arch: aarch64
triple: aarch64-apple-darwin
runner: macos-15-xlarge
dev_shell: .#devShells.aarch64-darwin.default
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults:
run:
shell: nix develop ${{ matrix.dev_shell }} -c bash -euo pipefail {0}
shell: nix develop -c bash -euo pipefail {0}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -82,7 +77,5 @@ jobs:
package: openshell-driver-vm
binary: openshell-driver-vm
triple: ${{ matrix.triple }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ inputs['cargo-version'] }}
image-tag: ${{ inputs['image-tag'] }}
interpreter: ${{ matrix.interpreter }}
4 changes: 0 additions & 4 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
binary: openshell
triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev-shell: .#devShells.x86_64-linux.musl
cargo-version: ${{ needs.version.outputs.cargo }}
checkout-ref: ${{ github.sha }}
secrets: inherit
Expand All @@ -79,7 +78,6 @@ jobs:
binary: openshell-conformance
triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev-shell: .#devShells.x86_64-linux.musl
cargo-version: ${{ needs.version.outputs.cargo }}
checkout-ref: ${{ github.sha }}
secrets: inherit
Expand All @@ -94,10 +92,8 @@ jobs:
binary: openshell-gateway
triple: x86_64-unknown-linux-gnu
runner: linux-amd64-cpu8
dev-shell: .#devShells.x86_64-linux.glibc-2-28
cargo-version: ${{ needs.version.outputs.cargo }}
image-tag: dev
interpreter: /lib64/ld-linux-x86-64.so.2
checkout-ref: ${{ github.sha }}
secrets: inherit

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@ jobs:
include:
- triple: x86_64-unknown-linux-musl
runner: linux-amd64-cpu8
dev_shell: .#devShells.x86_64-linux.musl
- triple: aarch64-unknown-linux-musl
runner: linux-arm64-cpu8
dev_shell: .#devShells.aarch64-linux.musl
uses: ./.github/workflows/build-binaries.yml
with:
package: openshell-conformance-cli
binary: openshell-conformance
artifact-name: openshell-conformance-${{ matrix.triple }}
triple: ${{ matrix.triple }}
runner: ${{ matrix.runner }}
dev-shell: ${{ matrix.dev_shell }}
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
secrets: inherit

Expand Down
Loading
Loading