mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-29 19:44:21 +01:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92343fa204 | ||
|
|
9d84900f32 | ||
|
|
9e9a1c276b | ||
|
|
274fe8537f | ||
|
|
e95ccdd206 | ||
|
|
04ba7507e2 | ||
|
|
720194ca9d | ||
|
|
4738a2ed5e | ||
|
|
bbaf94fb8f | ||
|
|
dc6f440014 | ||
|
|
8ff58c1228 | ||
|
|
339b7b2a1b | ||
|
|
5e2b22fba4 | ||
|
|
dd259403c5 | ||
|
|
5a7ce099f4 | ||
|
|
58cf7f7458 | ||
|
|
1631e5f6a3 | ||
|
|
82a7ffce68 | ||
|
|
9cc1438d52 | ||
|
|
d23989bcfc | ||
|
|
868f16c8cb | ||
|
|
9fc82761c6 | ||
|
|
b16e63e2c6 | ||
|
|
0f0911fca8 |
No files matched your search
@@ -1,6 +1,8 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "npm"
|
- package-ecosystem: "npm"
|
||||||
|
cooldown:
|
||||||
|
default-days: 7
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
name: 'Continuous Integration'
|
name: "Continuous Integration"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-dist:
|
check-dist:
|
||||||
name: Check dist/ directory
|
name: Check dist/ directory
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@967035ce963867fb956a309c9b67512314bc7c1f
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@2826fb8353263a138210fc017301ce5767a9c0d4
|
||||||
with:
|
with:
|
||||||
node-version: "20.x"
|
node-version: "20.19.1"
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@967035ce963867fb956a309c9b67512314bc7c1f
|
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@2826fb8353263a138210fc017301ce5767a9c0d4
|
||||||
with:
|
with:
|
||||||
node-version: "20.x"
|
node-version: "20.19.1"
|
||||||
+6
-1
@@ -4,4 +4,9 @@
|
|||||||
# We currently do not have any specific code owners
|
# We currently do not have any specific code owners
|
||||||
# In the future, we will have a Github team of global code owners of the entire package
|
# In the future, we will have a Github team of global code owners of the entire package
|
||||||
# Later on, we will start splitting up the responsibilities, and packages will be assigned more specific code owners
|
# Later on, we will start splitting up the responsibilities, and packages will be assigned more specific code owners
|
||||||
# * @opentofu-code-owners
|
* @opentofu/maintainers
|
||||||
|
|
||||||
|
# The last matching pattern takes the most precedence for CODEOWNERS. CODEOWNERS does not have fine-grained control so we will
|
||||||
|
# just match whole changes for these specific files, but @diofeher is responsible for taking care of the Dependabot updates
|
||||||
|
# in this repository.
|
||||||
|
package*.json @diofeher
|
||||||
@@ -67,6 +67,15 @@ steps:
|
|||||||
tofu_wrapper: false
|
tofu_wrapper: false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Caching can be enabled to reduce download time on subsequent workflow runs by storing the OpenTofu binary using the GitHub Actions [tool-cache](https://github.com/actions/toolkit/tree/main/packages/tool-cache). Note that this feature is primarily useful for self-hosted runners that support toolchain caching, since GitHub-hosted runners are ephemeral and do not persist the tool cache between runs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: opentofu/setup-opentofu@v1
|
||||||
|
with:
|
||||||
|
cache: true
|
||||||
|
```
|
||||||
|
|
||||||
Subsequent steps can access outputs when the wrapper script is installed:
|
Subsequent steps can access outputs when the wrapper script is installed:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -264,6 +273,7 @@ The action supports the following inputs:
|
|||||||
- `tofu_wrapper` - (optional) Whether to install a wrapper to wrap subsequent calls of
|
- `tofu_wrapper` - (optional) Whether to install a wrapper to wrap subsequent calls of
|
||||||
the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs
|
the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs
|
||||||
named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
|
named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.
|
||||||
|
- `cache` - (optional) Whether to use GitHub Actions tool-cache to store and reuse downloaded OpenTofu binaries. Defaults to `false`.
|
||||||
- `github_token` - (optional) Override the GitHub token read from the environment variable. Defaults to the value of the `GITHUB_TOKEN` environment variable unless running on Forgejo or Gitea.
|
- `github_token` - (optional) Override the GitHub token read from the environment variable. Defaults to the value of the `GITHUB_TOKEN` environment variable unless running on Forgejo or Gitea.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ inputs:
|
|||||||
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
|
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
cache:
|
||||||
|
description: 'Whether to use GitHub Actions tool-cache to store and reuse downloaded OpenTofu binaries. Defaults to `false`.'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
github_token:
|
github_token:
|
||||||
description: 'API token for GitHub to increase the rate limit. Defaults to the GITHUB_TOKEN environment variable unless running on Forgejo/Gitea.'
|
description: 'API token for GitHub to increase the rate limit. Defaults to the GITHUB_TOKEN environment variable unless running on Forgejo/Gitea.'
|
||||||
default: ''
|
default: ''
|
||||||
|
|||||||
Vendored
+29046
-2817
File diff suppressed because it is too large.
Load diff
Vendored
+25373
-1675
File diff suppressed because it is too large.
Load diff
+11
-6
@@ -28,21 +28,26 @@ class Release {
|
|||||||
* @return {Array<Release>} Releases.
|
* @return {Array<Release>} Releases.
|
||||||
*/
|
*/
|
||||||
async function fetchReleases (githubToken) {
|
async function fetchReleases (githubToken) {
|
||||||
|
const hc = require('@actions/http-client');
|
||||||
|
const userAgent = 'opentofu/setup-opentofu';
|
||||||
|
|
||||||
|
const http = new hc.HttpClient(userAgent);
|
||||||
|
|
||||||
const url = 'https://get.opentofu.org/tofu/api.json';
|
const url = 'https://get.opentofu.org/tofu/api.json';
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Accept: 'application/json'
|
Accept: 'application/json'
|
||||||
};
|
};
|
||||||
|
|
||||||
const resp = await fetch(url, {
|
const resp = await http.get(url, headers);
|
||||||
headers
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (resp.message.statusCode !== hc.HttpCodes.OK) {
|
||||||
throw new Error('failed fetching releases (' + resp.status + ')');
|
throw new Error('failed fetching releases (' + resp.message.statusCode + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
const releasesMeta = await resp.json();
|
const body = await resp.readBody();
|
||||||
|
const releasesMeta = JSON.parse(body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
*/
|
*/
|
||||||
|
|||||||
+17
-2
@@ -133,6 +133,7 @@ async function run () {
|
|||||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||||
|
const useCache = core.getInput('cache') === 'true';
|
||||||
let githubToken = core.getInput('github_token');
|
let githubToken = core.getInput('github_token');
|
||||||
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
if (githubToken === '' && !(process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS)) {
|
||||||
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
// Only default to the environment variable when running in GitHub Actions. Don't do this for other CI systems
|
||||||
@@ -174,8 +175,22 @@ async function run () {
|
|||||||
throw new Error(`OpenTofu version ${version} not available for ${platform} and ${arch}`);
|
throw new Error(`OpenTofu version ${version} not available for ${platform} and ${arch}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download requested version
|
// Download requested version if not cached
|
||||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
let pathToCLI;
|
||||||
|
if (useCache) {
|
||||||
|
const cachedPath = tc.find('tofu', release.version, arch);
|
||||||
|
if (cachedPath) {
|
||||||
|
core.debug(`Using cached OpenTofu version ${release.version} from ${cachedPath}`);
|
||||||
|
pathToCLI = cachedPath;
|
||||||
|
} else {
|
||||||
|
core.debug(`OpenTofu version ${release.version} not found in cache, downloading...`);
|
||||||
|
const extractedPath = await downloadAndExtractCLI(build.url);
|
||||||
|
core.debug(`Caching OpenTofu version ${release.version} to tool cache`);
|
||||||
|
pathToCLI = await tc.cacheDir(extractedPath, 'tofu', release.version, arch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pathToCLI = await downloadAndExtractCLI(build.url);
|
||||||
|
}
|
||||||
|
|
||||||
// Install our wrapper
|
// Install our wrapper
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ jest.mock('@actions/io', () => ({
|
|||||||
}));
|
}));
|
||||||
jest.mock('@actions/tool-cache', () => ({
|
jest.mock('@actions/tool-cache', () => ({
|
||||||
downloadTool: jest.fn(),
|
downloadTool: jest.fn(),
|
||||||
extractZip: jest.fn()
|
extractZip: jest.fn(),
|
||||||
|
find: jest.fn(),
|
||||||
|
cacheDir: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock releases.js so setup-tofu.js can be tested in isolation
|
// Mock releases.js so setup-tofu.js can be tested in isolation
|
||||||
@@ -39,6 +41,8 @@ describe('setup-tofu', () => {
|
|||||||
const tc = require('@actions/tool-cache');
|
const tc = require('@actions/tool-cache');
|
||||||
tc.downloadTool.mockResolvedValue('/mock/download/path');
|
tc.downloadTool.mockResolvedValue('/mock/download/path');
|
||||||
tc.extractZip.mockResolvedValue('/mock/extract/path');
|
tc.extractZip.mockResolvedValue('/mock/extract/path');
|
||||||
|
tc.find.mockReturnValue(null); // Default to cache miss
|
||||||
|
tc.cacheDir.mockResolvedValue('/mock/cached/path');
|
||||||
|
|
||||||
const io = require('@actions/io');
|
const io = require('@actions/io');
|
||||||
io.mv.mockResolvedValue();
|
io.mv.mockResolvedValue();
|
||||||
@@ -46,6 +50,7 @@ describe('setup-tofu', () => {
|
|||||||
io.mkdirP.mockResolvedValue();
|
io.mkdirP.mockResolvedValue();
|
||||||
|
|
||||||
const mockRelease = {
|
const mockRelease = {
|
||||||
|
version: '1.10.5',
|
||||||
getBuild: jest.fn().mockReturnValue({ url: 'mock-url' })
|
getBuild: jest.fn().mockReturnValue({ url: 'mock-url' })
|
||||||
};
|
};
|
||||||
releases.getRelease.mockResolvedValue(mockRelease);
|
releases.getRelease.mockResolvedValue(mockRelease);
|
||||||
@@ -64,6 +69,7 @@ describe('setup-tofu', () => {
|
|||||||
cli_config_credentials_hostname: '',
|
cli_config_credentials_hostname: '',
|
||||||
cli_config_credentials_token: '',
|
cli_config_credentials_token: '',
|
||||||
tofu_wrapper: 'true',
|
tofu_wrapper: 'true',
|
||||||
|
cache: 'false',
|
||||||
github_token: ''
|
github_token: ''
|
||||||
};
|
};
|
||||||
return defaults[name] || '';
|
return defaults[name] || '';
|
||||||
@@ -173,4 +179,81 @@ describe('setup-tofu', () => {
|
|||||||
expect(fs.readFile).not.toHaveBeenCalled();
|
expect(fs.readFile).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('caching functionality', () => {
|
||||||
|
it('should use cached version when cache is enabled and found', async () => {
|
||||||
|
const tc = require('@actions/tool-cache');
|
||||||
|
tc.find.mockReturnValue('/mock/cached/path');
|
||||||
|
|
||||||
|
core.getInput.mockImplementation((name) => {
|
||||||
|
const defaults = {
|
||||||
|
tofu_version: fallbackVersion,
|
||||||
|
tofu_version_file: '',
|
||||||
|
cli_config_credentials_hostname: '',
|
||||||
|
cli_config_credentials_token: '',
|
||||||
|
tofu_wrapper: 'true',
|
||||||
|
cache: 'true',
|
||||||
|
github_token: ''
|
||||||
|
};
|
||||||
|
return defaults[name] || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
await setup();
|
||||||
|
|
||||||
|
expect(tc.find).toHaveBeenCalledWith('tofu', '1.10.5', expect.any(String));
|
||||||
|
expect(tc.downloadTool).not.toHaveBeenCalled();
|
||||||
|
expect(tc.extractZip).not.toHaveBeenCalled();
|
||||||
|
expect(tc.cacheDir).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should download and cache when cache is enabled but not found', async () => {
|
||||||
|
const tc = require('@actions/tool-cache');
|
||||||
|
tc.find.mockReturnValue(null); // Cache miss
|
||||||
|
|
||||||
|
core.getInput.mockImplementation((name) => {
|
||||||
|
const defaults = {
|
||||||
|
tofu_version: fallbackVersion,
|
||||||
|
tofu_version_file: '',
|
||||||
|
cli_config_credentials_hostname: '',
|
||||||
|
cli_config_credentials_token: '',
|
||||||
|
tofu_wrapper: 'true',
|
||||||
|
cache: 'true',
|
||||||
|
github_token: ''
|
||||||
|
};
|
||||||
|
return defaults[name] || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
await setup();
|
||||||
|
|
||||||
|
expect(tc.find).toHaveBeenCalledWith('tofu', '1.10.5', expect.any(String));
|
||||||
|
expect(tc.downloadTool).toHaveBeenCalled();
|
||||||
|
expect(tc.extractZip).toHaveBeenCalled();
|
||||||
|
expect(tc.cacheDir).toHaveBeenCalledWith('/mock/extract/path', 'tofu', '1.10.5', expect.any(String));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not use cache when cache is disabled', async () => {
|
||||||
|
const tc = require('@actions/tool-cache');
|
||||||
|
tc.find.mockReturnValue('/mock/cached/path');
|
||||||
|
|
||||||
|
core.getInput.mockImplementation((name) => {
|
||||||
|
const defaults = {
|
||||||
|
tofu_version: fallbackVersion,
|
||||||
|
tofu_version_file: '',
|
||||||
|
cli_config_credentials_hostname: '',
|
||||||
|
cli_config_credentials_token: '',
|
||||||
|
tofu_wrapper: 'true',
|
||||||
|
cache: 'false',
|
||||||
|
github_token: ''
|
||||||
|
};
|
||||||
|
return defaults[name] || '';
|
||||||
|
});
|
||||||
|
|
||||||
|
await setup();
|
||||||
|
|
||||||
|
expect(tc.find).not.toHaveBeenCalled();
|
||||||
|
expect(tc.downloadTool).toHaveBeenCalled();
|
||||||
|
expect(tc.extractZip).toHaveBeenCalled();
|
||||||
|
expect(tc.cacheDir).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Generated
+2142
-1287
File diff suppressed because it is too large.
Load diff
+8
-8
@@ -19,16 +19,16 @@
|
|||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.10.1",
|
"@actions/core": "2.0.2",
|
||||||
"@actions/exec": "1.1.1",
|
"@actions/exec": "2.0.0",
|
||||||
"@actions/io": "1.1.3",
|
"@actions/io": "2.0.0",
|
||||||
"@actions/tool-cache": "2.0.1",
|
"@actions/tool-cache": "2.0.2",
|
||||||
"semver": "7.5.4"
|
"semver": "7.7.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "0.38.1",
|
"@vercel/ncc": "0.38.4",
|
||||||
"husky": "9.0.11",
|
"husky": "9.1.7",
|
||||||
"jest": "29.7.0",
|
"jest": "30.2.0",
|
||||||
"semistandard": "17.0.0"
|
"semistandard": "17.0.0"
|
||||||
},
|
},
|
||||||
"semistandard": {
|
"semistandard": {
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* // Instantiate a new listener
|
* // Instantiate a new listener
|
||||||
* const listener = new OutputListener();
|
* // stream is used to write the data before waiting for the listener to complete
|
||||||
|
* const listener = new OutputListener(stream);
|
||||||
* // Register listener against STDOUT stream
|
* // Register listener against STDOUT stream
|
||||||
* await exec.exec('ls', ['-ltr'], {
|
* await exec.exec('ls', ['-ltr'], {
|
||||||
* listeners: {
|
* listeners: {
|
||||||
@@ -20,12 +21,14 @@
|
|||||||
* console.log(listener.contents);
|
* console.log(listener.contents);
|
||||||
*/
|
*/
|
||||||
class OutputListener {
|
class OutputListener {
|
||||||
constructor () {
|
constructor (stream) {
|
||||||
this._buff = [];
|
this._buff = [];
|
||||||
|
this._stream = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
get listener () {
|
get listener () {
|
||||||
const listen = function listen (data) {
|
const listen = function listen (data) {
|
||||||
|
this._stream.write(data);
|
||||||
this._buff.push(data);
|
this._buff.push(data);
|
||||||
};
|
};
|
||||||
return listen.bind(this);
|
return listen.bind(this);
|
||||||
|
|||||||
@@ -4,14 +4,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const OutputListener = require('../lib/output-listener');
|
const OutputListener = require('../lib/output-listener');
|
||||||
|
const { PassThrough } = require('stream');
|
||||||
describe('output-listener', () => {
|
describe('output-listener', () => {
|
||||||
it('receives and exposes data', () => {
|
it('receives and exposes data', () => {
|
||||||
const listener = new OutputListener();
|
const stream = new PassThrough();
|
||||||
|
const listener = new OutputListener(stream);
|
||||||
const listen = listener.listener;
|
const listen = listener.listener;
|
||||||
listen(Buffer.from('foo'));
|
listen(Buffer.from('foo'));
|
||||||
|
expect(stream.read()).toEqual(Buffer.from('foo'));
|
||||||
listen(Buffer.from('bar'));
|
listen(Buffer.from('bar'));
|
||||||
|
expect(stream.read()).toEqual(Buffer.from('bar'));
|
||||||
listen(Buffer.from('baz'));
|
listen(Buffer.from('baz'));
|
||||||
|
expect(stream.read()).toEqual(Buffer.from('baz'));
|
||||||
expect(listener.contents).toEqual('foobarbaz');
|
expect(listener.contents).toEqual('foobarbaz');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
+20
-16
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
const io = require('@actions/io');
|
const io = require('@actions/io');
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const { exec } = require('@actions/exec');
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
const OutputListener = require('./lib/output-listener');
|
const OutputListener = require('./lib/output-listener');
|
||||||
const pathToCLI = require('./lib/tofu-bin');
|
const pathToCLI = require('./lib/tofu-bin');
|
||||||
@@ -22,25 +22,29 @@ async function checkTofu () {
|
|||||||
await checkTofu();
|
await checkTofu();
|
||||||
|
|
||||||
// Create listeners to receive output (in memory) as well
|
// Create listeners to receive output (in memory) as well
|
||||||
const stdout = new OutputListener();
|
const stdout = new OutputListener(process.stdout);
|
||||||
const stderr = new OutputListener();
|
const stderr = new OutputListener(process.stderr);
|
||||||
const listeners = {
|
|
||||||
stdout: stdout.listener,
|
|
||||||
stderr: stderr.listener
|
|
||||||
};
|
|
||||||
|
|
||||||
// Execute tofu and capture output
|
// Execute tofu and capture output
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const options = {
|
const child = spawn(pathToCLI, args, { stdio: ['inherit', 'pipe', 'pipe'] });
|
||||||
listeners,
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true // don't print "[command...]" into stdout: https://github.com/actions/toolkit/issues/649
|
|
||||||
};
|
|
||||||
const exitCode = await exec(pathToCLI, args, options);
|
|
||||||
|
|
||||||
// Pass-through stdout/err as `exec` won't due to `silent: true` option
|
// Forward signals to child so tofu can release state locks on cancellation
|
||||||
process.stdout.write(stdout.contents);
|
const forwardSigterm = () => { child.kill('SIGTERM'); };
|
||||||
process.stderr.write(stderr.contents);
|
const forwardSigint = () => { child.kill('SIGINT'); };
|
||||||
|
process.on('SIGTERM', forwardSigterm);
|
||||||
|
process.on('SIGINT', forwardSigint);
|
||||||
|
|
||||||
|
child.stdout.on('data', stdout.listener);
|
||||||
|
child.stderr.on('data', stderr.listener);
|
||||||
|
|
||||||
|
const exitCode = await new Promise((resolve) => {
|
||||||
|
// code is null when the process is killed by a signal; treat as failure
|
||||||
|
child.on('close', (code) => resolve(code ?? 1));
|
||||||
|
});
|
||||||
|
|
||||||
|
process.removeListener('SIGTERM', forwardSigterm);
|
||||||
|
process.removeListener('SIGINT', forwardSigint);
|
||||||
|
|
||||||
// Set outputs, result, exitcode, and stderr
|
// Set outputs, result, exitcode, and stderr
|
||||||
core.setOutput('stdout', stdout.contents);
|
core.setOutput('stdout', stdout.contents);
|
||||||
|
|||||||
Reference in new issue
Block a user