From 83f94c51b5257b2a461b004f652b176412545a2b Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Thu, 1 Aug 2024 15:51:18 +0500 Subject: [PATCH] ci: use gacts/run-and-post-run@v1 for commands in run and post-run --- .github/actions/restore-node/action.yml | 22 ++++++++-------------- .github/actions/with-post-step/action.yml | 21 --------------------- .github/actions/with-post-step/main.cjs | 22 ---------------------- 3 files changed, 8 insertions(+), 57 deletions(-) delete mode 100644 .github/actions/with-post-step/action.yml delete mode 100644 .github/actions/with-post-step/main.cjs diff --git a/.github/actions/restore-node/action.yml b/.github/actions/restore-node/action.yml index 6d7740325b3b..66755f823e2d 100644 --- a/.github/actions/restore-node/action.yml +++ b/.github/actions/restore-node/action.yml @@ -181,28 +181,22 @@ runs: mkdir -p node_modules/.cache/agoric date > node_modules/.cache/agoric/yarn-built - # Refs: https://github.com/orgs/community/discussions/45342 - - name: Validate Git Tree in Root Directory - if: inputs.path == '.' - uses: ./.github/actions/with-post-step + - name: Validate Git Tree Cleanliness + uses: gacts/run-and-post-run@v1 with: - main: echo "Checking Git tree for changes in the root directory..." - post: | + working-directory: ${{ inputs.path }} + shell: bash + run: | set -x - if [ -n "$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^[?][?] endo-sha.txt$|^.'; true)" ]; then + if [ -n "$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^\?\? endo-sha.txt$')" ]; then git status - echo "Unexpected dirty git status in default path" 1>&2 + echo "Unexpected dirty git status in Agoric SDK path" 1>&2 exit 1 fi - - name: Validate Git Tree in Agoric SDK Directory - if: inputs.path == './agoric-sdk' - uses: ./agoric-sdk/.github/actions/with-post-step - with: - main: echo "Checking Git tree for changes in the root directory..." post: | set -x - if [ -n "$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^[?][?] endo-sha.txt$|^.'; true)" ]; then + if [ -n "$(git status --porcelain | grep -vE 'junit.xml$' | grep -vE '^\?\? endo-sha.txt$')" ]; then git status echo "Unexpected dirty git status in Agoric SDK path" 1>&2 exit 1 diff --git a/.github/actions/with-post-step/action.yml b/.github/actions/with-post-step/action.yml deleted file mode 100644 index 9e1295380c8a..000000000000 --- a/.github/actions/with-post-step/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: With Post Step - -description: > - JavaScript Action to run a main command and a subsequent post command. - -inputs: - main: - description: 'Primary command or script to execute.' - required: true - post: - description: 'Command or script to run after the main command.' - required: true - key: - description: 'State variable name to identify the post step.' - required: false - default: POST - -runs: - using: 'node20' - main: 'main.cjs' - post: 'main.cjs' diff --git a/.github/actions/with-post-step/main.cjs b/.github/actions/with-post-step/main.cjs deleted file mode 100644 index 15390bc4bb4a..000000000000 --- a/.github/actions/with-post-step/main.cjs +++ /dev/null @@ -1,22 +0,0 @@ -// Ref: https://github.com/pyTooling/Actions/blob/main/with-post-step/main.js -const { spawn } = require('child_process'); -const { appendFileSync } = require('fs'); -const { EOL } = require('os'); - -const run = cmd => { - const subprocess = spawn(cmd, { stdio: 'inherit', shell: true }); - subprocess.on('exit', exitCode => { - process.exitCode = exitCode; - }); -}; - -const key = process.env.INPUT_KEY.toUpperCase(); - -if (process.env[`STATE_${key}`] !== undefined) { - // Are we in the 'post' step? - run(process.env.INPUT_POST); -} else { - // Otherwise, this is the main step - appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`); - run(process.env.INPUT_MAIN); -}