this repo has no description

Refactored by duplicating expected binary architectures and verification script accross all three GitHub workflows as per Louis preference

authored by

Diemo Gebhardt and committed by
Louis Pilfold
706c9d09 b9d5916b

+41 -50
+15 -1
.github/workflows/ci.yaml
··· 40 include: 41 - os: ubuntu-latest 42 target: x86_64-unknown-linux-gnu 43 use-cross: false 44 run-integration-tests: true 45 - os: ubuntu-latest 46 target: x86_64-unknown-linux-musl 47 use-cross: true 48 run-integration-tests: true 49 - os: ubuntu-latest 50 target: aarch64-unknown-linux-gnu 51 use-cross: true 52 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 53 - os: ubuntu-latest 54 target: aarch64-unknown-linux-musl 55 use-cross: true 56 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 57 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 58 - os: macos-13 # intel 59 target: x86_64-apple-darwin 60 use-cross: false 61 run-integration-tests: true 62 - os: macos-latest # aarch64 63 toolchain: stable 64 target: aarch64-apple-darwin 65 use-cross: false 66 run-integration-tests: true 67 - os: windows-latest 68 target: x86_64-pc-windows-msvc 69 use-cross: false 70 run-integration-tests: true 71 steps: ··· 120 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 121 BINARY_PATH="${BINARY_PATH}.exe" 122 fi 123 - ./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH" 124 if: ${{ matrix.run-integration-tests }} 125 126 - name: Run tests
··· 40 include: 41 - os: ubuntu-latest 42 target: x86_64-unknown-linux-gnu 43 + binary: x86-64 44 use-cross: false 45 run-integration-tests: true 46 - os: ubuntu-latest 47 target: x86_64-unknown-linux-musl 48 + binary: x86-64 49 use-cross: true 50 run-integration-tests: true 51 - os: ubuntu-latest 52 target: aarch64-unknown-linux-gnu 53 + binary: aarch64 54 use-cross: true 55 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 56 - os: ubuntu-latest 57 target: aarch64-unknown-linux-musl 58 + binary: aarch64 59 use-cross: true 60 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 61 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 62 - os: macos-13 # intel 63 target: x86_64-apple-darwin 64 + binary: x86_64 65 use-cross: false 66 run-integration-tests: true 67 - os: macos-latest # aarch64 68 toolchain: stable 69 target: aarch64-apple-darwin 70 + binary: arm64 71 use-cross: false 72 run-integration-tests: true 73 - os: windows-latest 74 target: x86_64-pc-windows-msvc 75 + binary: x86-64 76 use-cross: false 77 run-integration-tests: true 78 steps: ··· 127 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 128 BINARY_PATH="${BINARY_PATH}.exe" 129 fi 130 + 131 + if ! file -b "$BINARY_PATH" | grep -q "${{ matrix.binary }}"; then 132 + echo "error: Architecture mismatch" 133 + echo "Expected architecture: '${{ matrix.binary }}'" 134 + echo "Found binary type: '$(file -b "$BINARY_PATH")'" 135 + exit 1 136 + fi 137 + echo "ok: Architecture match" 138 if: ${{ matrix.run-integration-tests }} 139 140 - name: Run tests
+13 -1
.github/workflows/release-nightly.yaml
··· 62 include: 63 - os: ubuntu-latest 64 target: x86_64-unknown-linux-musl 65 use-cross: true 66 - os: ubuntu-latest 67 target: aarch64-unknown-linux-musl 68 use-cross: true 69 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 70 - os: macos-13 71 target: x86_64-apple-darwin 72 use-cross: false 73 - os: macos-latest 74 target: aarch64-apple-darwin 75 use-cross: false 76 - os: windows-latest 77 target: x86_64-pc-windows-msvc 78 use-cross: false 79 steps: 80 - name: Checkout repository ··· 110 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 111 BINARY_PATH="${BINARY_PATH}.exe" 112 fi 113 - ./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH" 114 115 - name: Build archive 116 shell: bash
··· 62 include: 63 - os: ubuntu-latest 64 target: x86_64-unknown-linux-musl 65 + binary: x86-64 66 use-cross: true 67 - os: ubuntu-latest 68 target: aarch64-unknown-linux-musl 69 + binary: aarch64 70 use-cross: true 71 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 72 - os: macos-13 73 target: x86_64-apple-darwin 74 + binary: x86_64 75 use-cross: false 76 - os: macos-latest 77 target: aarch64-apple-darwin 78 + binary: arm64 79 use-cross: false 80 - os: windows-latest 81 target: x86_64-pc-windows-msvc 82 + binary: x86-64 83 use-cross: false 84 steps: 85 - name: Checkout repository ··· 115 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 116 BINARY_PATH="${BINARY_PATH}.exe" 117 fi 118 + 119 + if ! file -b "$BINARY_PATH" | grep -q "${{ matrix.binary }}"; then 120 + echo "error: Architecture mismatch" 121 + echo "Expected architecture: '${{ matrix.binary }}'" 122 + echo "Found binary type: '$(file -b "$BINARY_PATH")'" 123 + exit 1 124 + fi 125 + echo "ok: Architecture match" 126 127 - name: Build archive 128 shell: bash
+13 -1
.github/workflows/release.yaml
··· 24 include: 25 - os: ubuntu-latest 26 target: x86_64-unknown-linux-musl 27 use-cross: true 28 - os: ubuntu-latest 29 target: aarch64-unknown-linux-musl 30 use-cross: true 31 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 32 - os: macos-13 33 target: x86_64-apple-darwin 34 use-cross: false 35 - os: macos-latest 36 target: aarch64-apple-darwin 37 use-cross: false 38 - os: windows-latest 39 target: x86_64-pc-windows-msvc 40 use-cross: false 41 steps: 42 - name: Checkout repository ··· 67 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 68 BINARY_PATH="${BINARY_PATH}.exe" 69 fi 70 - ./bin/verify-binary-architecture.sh "${{ matrix.target }}" "$BINARY_PATH" 71 72 - name: Build archive 73 shell: bash
··· 24 include: 25 - os: ubuntu-latest 26 target: x86_64-unknown-linux-musl 27 + binary: x86-64 28 use-cross: true 29 - os: ubuntu-latest 30 target: aarch64-unknown-linux-musl 31 + binary: aarch64 32 use-cross: true 33 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64 34 - os: macos-13 35 target: x86_64-apple-darwin 36 + binary: x86_64 37 use-cross: false 38 - os: macos-latest 39 target: aarch64-apple-darwin 40 + binary: arm64 41 use-cross: false 42 - os: windows-latest 43 target: x86_64-pc-windows-msvc 44 + binary: x86-64 45 use-cross: false 46 steps: 47 - name: Checkout repository ··· 72 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 73 BINARY_PATH="${BINARY_PATH}.exe" 74 fi 75 + 76 + if ! file -b "$BINARY_PATH" | grep -q "${{ matrix.binary }}"; then 77 + echo "error: Architecture mismatch" 78 + echo "Expected architecture: '${{ matrix.binary }}'" 79 + echo "Found binary type: '$(file -b "$BINARY_PATH")'" 80 + exit 1 81 + fi 82 + echo "ok: Architecture match" 83 84 - name: Build archive 85 shell: bash
-47
bin/verify-binary-architecture.sh
··· 1 - #!/usr/bin/env bash 2 - set -xeuo pipefail 3 - 4 - if [ $# -ne 2 ]; then 5 - echo "Usage: $0 <target-triple> <binary-path>" 6 - exit 1 7 - fi 8 - TARGET_TRIPLE="$1" 9 - BINARY_PATH="$2" 10 - BINARY_FILE_TYPE=$(file -b "$BINARY_PATH") 11 - 12 - # Architecture patterns 13 - ARCHITECTURE_PATTERNS_FOR_AARCH64='aarch64|Aarch64|arm64' 14 - ARCHITECTURE_PATTERNS_FOR_X86_64='x86-64|x86_64' 15 - 16 - # Architecture helper functions 17 - parse_architecture() { 18 - grep -Eo \ 19 - -e "$ARCHITECTURE_PATTERNS_FOR_AARCH64" \ 20 - -e "$ARCHITECTURE_PATTERNS_FOR_X86_64" \ 21 - | head -n1 22 - } 23 - normalize_architecture() { 24 - sed -E \ 25 - -e "s/($ARCHITECTURE_PATTERNS_FOR_AARCH64)/AArch64/" \ 26 - -e "s/($ARCHITECTURE_PATTERNS_FOR_X86_64)/x86-64/" 27 - } 28 - 29 - # Parse and normalize architectures 30 - TARGET_ARCHITECTURE=$( 31 - echo "$TARGET_TRIPLE" | parse_architecture | normalize_architecture \ 32 - || echo "unknown (target)" 33 - ) 34 - BINARY_ARCHITECTURE=$( 35 - echo "$BINARY_FILE_TYPE" | parse_architecture | normalize_architecture \ 36 - || echo "unknown (binary)" 37 - ) 38 - 39 - # Verify that binary architecture matches target architecture 40 - if [ "$BINARY_ARCHITECTURE" != "$TARGET_ARCHITECTURE" ]; then 41 - echo "error: Architecture mismatch for '$TARGET_TRIPLE'" 42 - echo "Expected architecture: '$TARGET_ARCHITECTURE'" 43 - echo "Found architecture: '$BINARY_ARCHITECTURE'" 44 - exit 1 45 - fi 46 - echo "ok: Architecture match for '$TARGET_TRIPLE'" 47 - exit 0
···