From 63c4e2456b560e7ac5c56fe05cf109da5ae36d06 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 29 Jun 2023 00:29:16 +0530 Subject: [PATCH] build: follow up to #5449. implementing suggestions and deduplication (#5464) ## Additional Information * Based on suggestions by @knst made [here](https://github.com/dashpay/dash/pull/5449#issuecomment-1609937147) and [here](https://github.com/dashpay/dash/pull/5426#discussion_r1241789033) --- .github/workflows/guix-build.yml | 17 +++++----------- contrib/containers/guix/scripts/guix-check | 23 ++++++++++++++++------ contrib/containers/guix/scripts/guix-start | 21 +++++++++++++++----- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 9e5328e213..ceeffec953 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -51,11 +51,11 @@ jobs: run: | docker run --privileged -d --rm -t \ --name guix-daemon \ - -e ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=32' \ + -e ADDITIONAL_GUIX_COMMON_FLAGS="--max-jobs=$(nproc --all)" \ -v ${{ github.workspace }}:/src/dash \ -w /src/dash \ guix_ubuntu:latest && \ - docker exec guix-daemon bash -c "/usr/local/bin/guix-start" + docker exec guix-daemon bash -c '/usr/local/bin/guix-start' - name: Ensure build passes run: | @@ -63,14 +63,7 @@ jobs: echo "Guix build failed!" exit 1 fi - - name: Compute SHA256 checksums for binaries + + - name: Compute SHA256 checksums run: | - ( \ - SRC_PATH_PREFIX=guix-build-$(git rev-parse --short=12 HEAD)/distsrc- && \ - sha256sum ${SRC_PATH_PREFIX}*/src/dash{d,-cli,-tx,-wallet}{,.exe} && \ - sha256sum ${SRC_PATH_PREFIX}*/src/qt/dash-qt{,.exe} && \ - sha256sum ${SRC_PATH_PREFIX}*/src/test/test_dash{,.exe} \ - ) | sort -k 2 - - name: Compute SHA256 checksums for archives - run: | - find guix-build-"$(git rev-parse --short=12 HEAD)"/output -type f | grep -v SHA256 | xargs sha256sum | sort -k 2 + ./contrib/containers/guix/scripts/guix-check ${{ github.workspace }} diff --git a/contrib/containers/guix/scripts/guix-check b/contrib/containers/guix/scripts/guix-check index e70170066a..e16891bc72 100755 --- a/contrib/containers/guix/scripts/guix-check +++ b/contrib/containers/guix/scripts/guix-check @@ -2,16 +2,27 @@ set -eo pipefail -cd /src/dash -COMMIT_ID=$(git rev-parse --short=12 HEAD) +if [[ -n "${1}" ]]; then + WORKSPACE_PATH="$1" +else + WORKSPACE_PATH="/src/dash" +fi -printf "Binaries:\n" +if [[ ! -d "$WORKSPACE_PATH" ]]; then + echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" + exit 1 +fi + +cd "$WORKSPACE_PATH" +COMMIT_ID="$(git rev-parse --short=12 HEAD)" + +printf "\nBinaries:\n\n" ( \ -SRC_PATH_PREFIX=guix-build-${COMMIT_ID}/distsrc- && \ +SRC_PATH_PREFIX="guix-build-${COMMIT_ID}/distsrc-" && \ sha256sum ${SRC_PATH_PREFIX}*/src/dash{d,-cli,-tx,-wallet}{,.exe} && \ sha256sum ${SRC_PATH_PREFIX}*/src/qt/dash-qt{,.exe} && \ sha256sum ${SRC_PATH_PREFIX}*/src/test/test_dash{,.exe} \ ) | sort -k 2 -printf "Archives:\n" -find guix-build-"${COMMIT_ID}"/output -type f | grep -v SHA256 | xargs sha256sum | sort -k 2 +printf "\nArchives:\n\n" +find "guix-build-${COMMIT_ID}/output" -type f | grep -v SHA256 | xargs sha256sum | sort -k 2 diff --git a/contrib/containers/guix/scripts/guix-start b/contrib/containers/guix/scripts/guix-start index 0e1e1eaf49..7d0f27d811 100755 --- a/contrib/containers/guix/scripts/guix-start +++ b/contrib/containers/guix/scripts/guix-start @@ -2,19 +2,30 @@ set -eo pipefail +if [[ -n "${1}" ]]; then + WORKSPACE_PATH="$1" +else + WORKSPACE_PATH="/src/dash" +fi + +if [[ ! -d "$WORKSPACE_PATH" ]]; then + echo "$0: $WORKSPACE_PATH is not a valid directory, exiting!" + exit 1 +fi + XCODE_VERSION="12.1" XCODE_RELEASE="12A7403" XCODE_ARCHIVE="Xcode-${XCODE_VERSION}-${XCODE_RELEASE}-extracted-SDK-with-libcxx-headers" # Check if macOS SDK is present, if not, download it -if [ ! -d "/src/dash/depends/SDKs/${XCODE_ARCHIVE}" ] +if [ ! -d "${WORKSPACE_PATH}/depends/SDKs/${XCODE_ARCHIVE}" ] then - mkdir -p /src/dash/depends/SDKs - curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C /src/dash/depends/SDKs + mkdir -p "${WORKSPACE_PATH}/depends/SDKs" + curl -L https://bitcoincore.org/depends-sources/sdks/${XCODE_ARCHIVE}.tar.gz | tar -xz -C "${WORKSPACE_PATH}/depends/SDKs" fi -cd /src/dash +cd "${WORKSPACE_PATH}" +git config --global --add safe.directory "${WORKSPACE_PATH}" git status >> /dev/null -git config --global --add safe.directory /src/dash ./contrib/guix/guix-build