Skip to content

Commit

Permalink
minor: use spawn to stream larger output rather than exec which buffe…
Browse files Browse the repository at this point in the history
…rs it
  • Loading branch information
nick-fields committed Aug 4, 2022
1 parent a25f198 commit 0e031ae
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci_cd.yml
Expand Up @@ -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')
Expand Down
9 changes: 9 additions & 0 deletions 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-%
4 changes: 2 additions & 2 deletions dist/index.js
Expand Up @@ -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);
});
Expand Down
13 changes: 13 additions & 0 deletions 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
6 changes: 3 additions & 3 deletions 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';

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0e031ae

Please sign in to comment.