From bd1f72e08840c49b89d6a1b59ab8f9bc131d48bb Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 19 Jul 2022 14:30:34 +1200 Subject: [PATCH 1/5] FIX Allow different node versions for admin vs module --- action.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index ded8feb..becb5f6 100644 --- a/action.yml +++ b/action.yml @@ -180,16 +180,23 @@ runs: export NVM_DIR="$HOME/.nvm" # this loads nvm into the current terminal [[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" - nvm install - nvm use - rm -rf client/dist - npm install -g yarn - yarn install --network-concurrency 1 + ADMIN_NPM_VERSION= if [[ -d vendor/silverstripe/admin ]]; then cd vendor/silverstripe/admin + nvm install + nvm use + ADMIN_NPM_VERSION=$(npm -v) + npm install -g yarn yarn install --network-concurrency 1 cd ../../.. fi + nvm install + nvm use + rm -rf client/dist + if [[ $(npm -v) != $ADMIN_NPM_VERSION ]]; then + npm install -g yarn; + fi + yarn install --network-concurrency 1 if [[ $(cat package.json | jq -r '.scripts.build') != 'null' ]]; then echo "Running yarn build" yarn run build From af95bba203a25cd5620a0e9764380eae3e0571fc Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 19 Jul 2022 14:57:29 +1200 Subject: [PATCH 2/5] FIX Output git diff --- action.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index becb5f6..1939c47 100644 --- a/action.yml +++ b/action.yml @@ -197,12 +197,23 @@ runs: npm install -g yarn; fi yarn install --network-concurrency 1 - if [[ $(cat package.json | jq -r '.scripts.build') != 'null' ]]; then + if [[ $(cat package.json | jq -r '.scripts.build') != 'null' ]]; then echo "Running yarn build" yarn run build echo "Running git diff" - git diff-files --quiet -w --relative=client - git diff --name-status --relative=client + GIT_DIFF_FILES=$(git diff-files --ignore-all-space --relative=client) + GIT_DIFF=$(git diff --name-status --relative=client) + if [[ $GIT_DIFF_FILES != "" ]]; then + echo "git diff files:" + echo $GIT_DIFF_FILES + fi + if [[ $GIT_DIFF != "" ]]; then + echo "git diff:" + echo $GIT_DIFF + fi + if [[ $GIT_DIFF_FILES != "" ]] || [[ $GIT_DIFF != "" ]]; then + exit 1 + fi fi if [[ $(cat package.json | jq -r '.scripts.test') != 'null' ]]; then echo "Running yarn test" From c67388496c47cfa3ac83badb11f95577f5736a39 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 19 Jul 2022 16:01:57 +1200 Subject: [PATCH 3/5] FIX Only use git diff --- action.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 1939c47..1a08c46 100644 --- a/action.yml +++ b/action.yml @@ -201,17 +201,11 @@ runs: echo "Running yarn build" yarn run build echo "Running git diff" - GIT_DIFF_FILES=$(git diff-files --ignore-all-space --relative=client) - GIT_DIFF=$(git diff --name-status --relative=client) - if [[ $GIT_DIFF_FILES != "" ]]; then - echo "git diff files:" - echo $GIT_DIFF_FILES - fi + git add . + GIT_DIFF=$(git diff --name-status --relative=client && git diff --cached --name-status --relative=client) if [[ $GIT_DIFF != "" ]]; then echo "git diff:" echo $GIT_DIFF - fi - if [[ $GIT_DIFF_FILES != "" ]] || [[ $GIT_DIFF != "" ]]; then exit 1 fi fi From fc97d9248a8ec6f617823a8fd88f1301b19af475 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 19 Jul 2022 16:21:25 +1200 Subject: [PATCH 4/5] FIX Only git add client folder --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1a08c46..7317ca1 100644 --- a/action.yml +++ b/action.yml @@ -201,7 +201,7 @@ runs: echo "Running yarn build" yarn run build echo "Running git diff" - git add . + git add client GIT_DIFF=$(git diff --name-status --relative=client && git diff --cached --name-status --relative=client) if [[ $GIT_DIFF != "" ]]; then echo "git diff:" From dcf16c3c22edb084decbad575f61bfe5bbf64aaa Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 25 Jul 2022 16:33:06 +1200 Subject: [PATCH 5/5] FIX Ensure client directory exists before running git diff --- action.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 7317ca1..5952450 100644 --- a/action.yml +++ b/action.yml @@ -192,19 +192,30 @@ runs: fi nvm install nvm use - rm -rf client/dist if [[ $(npm -v) != $ADMIN_NPM_VERSION ]]; then npm install -g yarn; fi yarn install --network-concurrency 1 if [[ $(cat package.json | jq -r '.scripts.build') != 'null' ]]; then + DIST_DIR= + if [[ -d client/dist ]]; then + DIST_DIR=client/dist + elif [[ -d dist ]]; then + DIST_DIR=dist + else + echo "No dist directory found" + exit 1 + fi + echo "Deleting $DIST_DIR" + rm -rf $DIST_DIR echo "Running yarn build" yarn run build echo "Running git diff" - git add client - GIT_DIFF=$(git diff --name-status --relative=client && git diff --cached --name-status --relative=client) + # Add all files to ensure that any new files previously uncommitted are tracked + git add $DIST_DIR + GIT_DIFF=$(git diff --cached --name-status --relative=$DIST_DIR) if [[ $GIT_DIFF != "" ]]; then - echo "git diff:" + echo "git diff found modified files when it should not have:" echo $GIT_DIFF exit 1 fi