Browse Source

factor out computing runtime shasum to a script file

Mokhtar Naamani 4 years ago
parent
commit
7873133e66

+ 1 - 4
.github/workflows/run-network-tests-pull-request.yml

@@ -34,10 +34,7 @@ jobs:
       - id: compute_shasum
         name: Compute runtime code shasum
         run: |
-          export RUNTIME_CODE_SHASUM=`tar -c \
-            --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
-            Cargo.lock Cargo.toml \
-            runtime runtime-modules utils/chain-spec-builder | shasum | cut -d " " -f 1`
+          export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
           echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
 
       - name: Check if we have a pre-built image in Artifacts

+ 1 - 4
.github/workflows/run-network-tests-push.yml

@@ -19,10 +19,7 @@ jobs:
       - id: docker_build
         name: Build and publish docker images
         run: |
-          export RUNTIME_CODE_SHASUM=`tar -c \
-            --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
-            Cargo.lock Cargo.toml \
-            runtime runtime-modules utils/chain-spec-builder | shasum | cut -d " " -f 1`
+          export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
           function docker_tag_exists() {
             curl --silent -f -lSL https://index.docker.io/v1/repositories/joystream/node/tags/$1 > /dev/null
           }

+ 16 - 0
scripts/runtime-code-shasum.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# Cargo workspace root
+export WORKSPACE_ROOT=`cargo metadata --offline --no-deps --format-version 1 | jq .workspace_root -r`
+
+cd ${WORKSPACE_ROOT}
+
+# srot/owner/group/mtime arguments only work with gnu version of tar.
+# So if you run this on Mac the default version of tar is `bsdtar`
+# and you will not get an idempotent result.
+# Install gnu-tar with brew
+#   brew install gnu-tar
+#   export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"
+tar -c --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' Cargo.lock Cargo.toml \
+    runtime runtime-modules utils/chain-spec-builder | shasum | cut -d " " -f 1
+