From 2b3f8c8b05d873c9895aa9d6575f5fe0da3e5b2a Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Tue, 25 Jun 2024 14:28:52 -0700 Subject: [PATCH] fix: make install.dependencies on Windows This change fixes make install.dependencies on Windows. The Windows platform relies on sha512sum tool instead of shasum tool which is available on macOS. This change also adds a spot check for make install.dependencies on macOS 13 and Windows to CI. Signed-off-by: Austin Vazquez --- .github/workflows/ci.yaml | 27 +++++++++++++++++++++++++++ deps/install.sh | 12 +++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0e1580e3..93e9f4b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,6 +20,33 @@ concurrency: cancel-in-progress: true jobs: + install-dependencies: + # This is a spot check for make install.dependencies on macOS and Windows platforms. + # Finch-core provides the core dependencies needed to run Finch such as the base OS + # image, rootfs, and Lima bundle. Validate the mechanism used to install the core + # dependencies works on the respective platforms. + strategy: + fail-fast: false + matrix: + os: [macos-13, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + persist-credentials: false + submodules: true + - name: Setup go + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: e2e/go.mod + cache-dependency-path: e2e/go.sum + - name: Install platform dependencies + run: make install.dependencies + - name: Clean up dependencies + run: make clean + e2e-tests: strategy: fail-fast: false diff --git a/deps/install.sh b/deps/install.sh index b0308e36..aef42944 100644 --- a/deps/install.sh +++ b/deps/install.sh @@ -71,6 +71,16 @@ esac # pull artifact from dependency repository curl -L --fail "${url}/${artifact}" > "${file}" +shasum_command=() +if hash sha512sum; then + shasum_command=(sha512sum) +elif hash shasum; then + shasum_command=(shasum --algorithm 512) +else + echo "error: shasum dependency not found" && exit 1 +fi + # validate shasum for downloaded artifact -(shasum --algorithm 512 "${file}" | cut -d ' ' -f 1 | grep -xq "^${digest}$") || \ +shasum=$("${shasum_command[@]}" "${file}") +(echo "${shasum}" | cut -d ' ' -f 1 | grep -xq "^${digest}$") || \ (echo "error: shasum verification failed for dependency" && rm -f "${file}" && exit 1)