From 0e031ae16f564fea708a73bb7d95c28b7c42ac49 Mon Sep 17 00:00:00 2001 From: Nick Fields <46869826+nick-fields@users.noreply.github.com> Date: Wed, 3 Aug 2022 20:37:09 -0400 Subject: [PATCH] minor: use spawn to stream larger output rather than exec which buffers it --- .github/workflows/ci_cd.yml | 50 +++++++++++++++++++++++++++++++++++++ Makefile | 9 +++++++ dist/index.js | 4 +-- kibibyte.txt | 13 ++++++++++ src/index.ts | 6 ++--- 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 Makefile create mode 100644 kibibyte.txt diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d86c854..df4fe7e 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -24,6 +24,56 @@ jobs: directory: ./coverage/ verbose: true + ci_integration_envvar: + name: Run Integration Env Var Tests + if: startsWith(github.ref, 'refs/heads') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + - name: Install dependencies + run: npm ci + - name: env-vars-passed-through + uses: ./ + env: + NODE_OPTIONS: '--max_old_space_size=3072' + with: + timeout_minutes: 1 + max_attempts: 2 + command: node -e 'console.log(process.env.NODE_OPTIONS)' + + ci_integration_sigpipe: + name: Run Integration Issue#76 Tests + if: startsWith(github.ref, 'refs/heads') + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + - name: Install dependencies + run: npm ci + - name: 100MiB + id: large-output + continue-on-error: true + uses: ./ + with: + max_attempts: 1 + timeout_minutes: 5 + command: 'make bytes-102400' + - uses: nick-invision/assert-action@v1 + with: + expected: failure + actual: ${{ steps.large-output.outcome }} + ci_integration: name: Run Integration Tests if: startsWith(github.ref, 'refs/heads') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d4b646 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +SHELL = bash + +bytes-%: + for i in {1..$*}; do cat kibibyte.txt; done; exit 1 +.PHONY: bytes-% + +lines-%: + for i in {1..$*}; do echo a; done; exit 1 +.PHONY: lines-% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index c75ff05..8346935 100644 --- a/dist/index.js +++ b/dist/index.js @@ -778,8 +778,8 @@ function runCmd(attempt) { done = false; (0, core_1.debug)("Running command ".concat(COMMAND, " on ").concat(OS, " using shell ").concat(executable)); child = attempt > 1 && NEW_COMMAND_ON_RETRY - ? (0, child_process_1.exec)(NEW_COMMAND_ON_RETRY, { shell: executable }) - : (0, child_process_1.exec)(COMMAND, { shell: executable }); + ? (0, child_process_1.spawn)(NEW_COMMAND_ON_RETRY, { shell: executable }) + : (0, child_process_1.spawn)(COMMAND, { shell: executable }); (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', function (data) { process.stdout.write(data); }); diff --git a/kibibyte.txt b/kibibyte.txt new file mode 100644 index 0000000..54960cb --- /dev/null +++ b/kibibyte.txt @@ -0,0 +1,13 @@ +1: 0000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +2: 0081 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +3: 0162 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +4: 243 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +5: 324 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +6: 405 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +7: 486 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +8: 567 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +9: 648 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +a: 729 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +b: 810 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +c: 891 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +d: 972 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index a691d19..c1b67ac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { getInput, error, warning, info, debug, setOutput } from '@actions/core'; -import { exec, execSync } from 'child_process'; +import { execSync, spawn } from 'child_process'; import ms from 'milliseconds'; import kill from 'tree-kill'; @@ -137,8 +137,8 @@ async function runCmd(attempt: number) { debug(`Running command ${COMMAND} on ${OS} using shell ${executable}`); const child = attempt > 1 && NEW_COMMAND_ON_RETRY - ? exec(NEW_COMMAND_ON_RETRY, { shell: executable }) - : exec(COMMAND, { shell: executable }); + ? spawn(NEW_COMMAND_ON_RETRY, { shell: executable }) + : spawn(COMMAND, { shell: executable }); child.stdout?.on('data', (data) => { process.stdout.write(data);