Compare commits

...
Author SHA1 Message Date
Vallie Joseph a99da03c77 . 2022-12-12 05:26:28 +00:00
Vallie Joseph e0023baa89 trying execFileSync 2022-12-12 05:12:53 +00:00
Vallie Joseph 17bd5c18e9 adding windows verbatim args 2022-12-12 05:05:46 +00:00
Vallie Joseph 4b6dd2fbd0 Test 2022-12-08 20:44:39 +00:00
Vallie Joseph d6c6f72a70 Test 2022-12-08 20:38:15 +00:00
Sampark SharmaandGitHub 819157bf87 Merge pull request #1238 from actions/revert-1232-phantsure/gnutar_windows
Revert "Add GNUtar as default in windows"
2022-11-17 12:42:10 +05:30
Sampark SharmaandGitHub 86102e88e9 Revert "Add GNUtar as default in windows" 2022-11-17 12:26:27 +05:30
Sampark SharmaandGitHub e4c071ba19 Merge pull request #1232 from actions/phantsure/gnutar_windows
Add GNUtar as default in windows
2022-11-16 16:55:59 +05:30
Sampark SharmaandGitHub 9443e26349 Address review comments 2022-11-15 10:18:46 +00:00
Sampark SharmaandGitHub 5a0405df4e Fix tests 2022-11-15 08:48:29 +00:00
Sampark SharmaandGitHub 0e707aeabc Address comments 2022-11-15 08:41:04 +00:00
Sampark SharmaandGitHub 7441dc5e59 Fix tests 2022-11-14 10:25:17 +00:00
Sampark SharmaandGitHub 1ddac5e02f Fix tests 2022-11-14 10:11:46 +00:00
Sampark SharmaandGitHub 55484166d8 Address review comments 2022-11-14 08:12:15 +00:00
Sampark SharmaandGitHub 7181b913f5 Remove export 2022-11-14 06:34:18 +00:00
Sampark SharmaandGitHub 81cd5a5c2e Revert "Add logs for cache version on miss"
This reverts commit 4b348086a9.
2022-11-14 06:33:53 +00:00
Sampark SharmaandGitHub 4b348086a9 Add logs for cache version on miss 2022-11-14 05:24:09 +00:00
Sampark SharmaandGitHub 436cf8d6ea Fix tests 2022-11-10 15:50:06 +00:00
Sampark SharmaandGitHub e0aadb573c Fix GNUtar path 2022-11-08 08:29:31 +00:00
Sampark SharmaandGitHub 62a66a8ce9 Fix tests 2022-11-08 06:43:28 +00:00
Sampark SharmaandGitHub 0c58e4113e Fix gnutar check on windows 2022-11-07 13:43:54 +00:00
Sampark SharmaandGitHub 9366237c90 Add gnuTar as default in windows 2022-11-07 13:39:07 +00:00
Sankalp KotewarandGitHub b36e70495f Merge pull request #1217 from actions/kotewar/release-new-version
Upgraded actions/cache version to 3.0.6
2022-10-19 00:37:15 +05:30
Sankalp KotewarandGitHub 8423354d7d Update RELEASES.md 2022-10-18 23:14:31 +05:30
Sankalp Kotewar abcca5a0b2 Upgraded actions/cache version to 3.0.6 2022-10-18 22:56:17 +05:30
Sankalp KotewarandGitHub b2e1c39c92 Merge pull request #1215 from Kurt-von-Laven/abort-controller
Declare dependency on `@azure/abort-controller`
2022-10-18 22:30:56 +05:30
Sankalp KotewarandGitHub 8e8a93deae Fixed environment variable in the docs. (#1216) 2022-10-18 12:31:00 +05:30
Kurt von Laven 738c849e89 Declare dependency on @azure/abort-controller 2022-10-17 18:05:26 -07:00
Lovepreet SinghandGitHub 9b58167dc9 Merge pull request #888 from martincostello/Fix-Docs
Fix endColumn documentation
2022-10-14 21:26:17 +05:30
Lovepreet SinghandGitHub ffb7e3e14e Merge pull request #1206 from actions/pdotl-patch-1
Patch @actions/cache to use @action/core version 1.10.0
2022-10-13 15:39:35 +05:30
Lovepreet Singh ce378c4cec Fix package-lock.json 2022-10-13 09:45:52 +00:00
Lovepreet Singh 3e257b0745 Update RELEASES.md 2022-10-13 09:36:33 +00:00
Lovepreet Singh e5e4491ac5 Patch @actions/cache to use @action/core version 1.10.0 2022-10-13 08:21:23 +00:00
David BlossandGitHub 1bc93f3cdf fix README broken link to dep caching (#1202) 2022-10-12 11:45:29 +05:30
Luke TomlinsonandGitHub 4fbc5c941a Update @actions/github to v5.1.1 (#1189) 2022-09-30 14:04:50 -04:00
Luke TomlinsonandGitHub ac778acad2 Export default octokit options (#1188) 2022-09-30 12:17:19 -04:00
Francesco RenziandGitHub 192c26f865 Merge pull request #1187 from actions/core/1.10
@actions/core 1.10.0 release
2022-09-29 14:59:11 +01:00
Francesco Renzi 295cbcc4da @actions/core 1.10.0 release 2022-09-29 13:53:58 +00:00
Francesco RenziandGitHub b00a9fd033 Add save-state and set-output file commands (#1178) 2022-09-29 14:45:02 +01:00
Francesco RenziandGitHub 4df45177e4 Merge pull request #1185 from bicstone/bicstone/fix-getMultilineInput-trim
fix(core): `getMultilineInput` not trimming whitespace
2022-09-28 09:23:14 +01:00
Takanori Oishi 33f1d64363 fix: getMultilineInput trims whitespace 2022-09-28 12:54:12 +09:00
Luke TomlinsonandGitHub ebe4ac336f @actions/github release version 5.1.0 (#1182) 2022-09-23 10:01:00 -04:00
Luke TomlinsonandGitHub 94de2cf6d4 Add additionalPlugins parameter to getOctokit method (#1181)
* Add additionalPlugins parameter to getOctokit method

* Simplify getOctokit
2022-09-22 16:43:54 -04:00
Francesco RenziandGitHub 64c334f0e5 Merge pull request #1180 from actions/rentziass/allow-parse-url 2022-09-16 17:05:24 +01:00
martincostello 8b45e1e356 Fix endColumn documentation
Change "start" to "end".
2021-08-20 11:06:49 +01:00
20 changed files with 278 additions and 86 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ console.log(`We can even get context data, like the repo: ${context.repo.repo}`)
## Contributing ## Contributing
We welcome contributions. See [how to contribute](.github/CONTRIBUTING.md). We welcome contributions. See [how to contribute](.github/CONTRIBUTING.md).
hi
## Code of Conduct ## Code of Conduct
See [our code of conduct](CODE_OF_CONDUCT.md). See [our code of conduct](CODE_OF_CONDUCT.md).
+5 -5
View File
@@ -2,17 +2,17 @@
> Functions necessary for caching dependencies and build outputs to improve workflow execution time. > Functions necessary for caching dependencies and build outputs to improve workflow execution time.
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows) for how caching works. See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows) for how caching works.
Note that GitHub will remove any cache entries that have not been accessed in over 7 days. There is no limit on the number of caches you can store, but the total size of all caches in a repository is limited to 10 GB. If you exceed this limit, GitHub will save your cache but will begin evicting caches until the total size is less than 10 GB. Note that GitHub will remove any cache entries that have not been accessed in over 7 days. There is no limit on the number of caches you can store, but the total size of all caches in a repository is limited to 10 GB. If you exceed this limit, GitHub will save your cache but will begin evicting caches until the total size is less than 10 GB.
## Usage ## Usage
This package is used by the v2+ versions of our first party cache action. You can find an example implementation in the cache repo [here](https://github.com/actions/cache). This package is used by the v2+ versions of our first party cache action. You can find an example implementation in the cache repo [here](https://github.com/actions/cache).
#### Save Cache #### Save Cache
Saves a cache containing the files in `paths` using the `key` provided. The files would be compressed using zstandard compression algorithm if zstd is installed, otherwise gzip is used. Function returns the cache id if the cache was saved succesfully and throws an error if cache upload fails. Saves a cache containing the files in `paths` using the `key` provided. The files would be compressed using zstandard compression algorithm if zstd is installed, otherwise gzip is used. Function returns the cache id if the cache was saved succesfully and throws an error if cache upload fails.
```js ```js
const cache = require('@actions/cache'); const cache = require('@actions/cache');
@@ -26,7 +26,7 @@ const cacheId = await cache.saveCache(paths, key)
#### Restore Cache #### Restore Cache
Restores a cache based on `key` and `restoreKeys` to the `paths` provided. Function returns the cache key for cache hit and returns undefined if cache not found. Restores a cache based on `key` and `restoreKeys` to the `paths` provided. Function returns the cache key for cache hit and returns undefined if cache not found.
```js ```js
const cache = require('@actions/cache'); const cache = require('@actions/cache');
@@ -46,4 +46,4 @@ const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.4` of cache package introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss. A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.4` of cache package introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.
Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes. Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
+7 -1
View File
@@ -84,4 +84,10 @@
### 3.0.4 ### 3.0.4
- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891). - Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes. - Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
### 3.0.5
- Update `@actions/cache` to use `@actions/core@^1.10.0`
### 3.0.6
- Added `@azure/abort-controller` to dependencies to fix compatibility issue with ESM [#1208](https://github.com/actions/toolkit/issues/1208)
+19 -18
View File
@@ -1,19 +1,20 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "3.0.4", "version": "3.0.6",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/cache", "name": "@actions/cache",
"version": "3.0.4", "version": "3.0.6",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.8.0", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
@@ -26,9 +27,9 @@
} }
}, },
"node_modules/@actions/core": { "node_modules/@actions/core": {
"version": "1.9.1", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
"dependencies": { "dependencies": {
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"uuid": "^8.3.2" "uuid": "^8.3.2"
@@ -73,14 +74,14 @@
"integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
}, },
"node_modules/@azure/abort-controller": { "node_modules/@azure/abort-controller": {
"version": "1.0.4", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz", "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==", "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
"dependencies": { "dependencies": {
"tslib": "^2.0.0" "tslib": "^2.2.0"
}, },
"engines": { "engines": {
"node": ">=8.0.0" "node": ">=12.0.0"
} }
}, },
"node_modules/@azure/abort-controller/node_modules/tslib": { "node_modules/@azure/abort-controller/node_modules/tslib": {
@@ -617,9 +618,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.9.1", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
"requires": { "requires": {
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"uuid": "^8.3.2" "uuid": "^8.3.2"
@@ -663,11 +664,11 @@
"integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
}, },
"@azure/abort-controller": { "@azure/abort-controller": {
"version": "1.0.4", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz", "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
"integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==", "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
"requires": { "requires": {
"tslib": "^2.0.0" "tslib": "^2.2.0"
}, },
"dependencies": { "dependencies": {
"tslib": { "tslib": {
+3 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/cache", "name": "@actions/cache",
"version": "3.0.4", "version": "3.0.6",
"preview": true, "preview": true,
"description": "Actions cache lib", "description": "Actions cache lib",
"keywords": [ "keywords": [
@@ -37,11 +37,12 @@
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0", "@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.8.0", "@azure/storage-blob": "^12.8.0",
"semver": "^6.1.0", "semver": "^6.1.0",
+1 -1
View File
@@ -163,7 +163,7 @@ export interface AnnotationProperties {
startColumn?: number startColumn?: number
/** /**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
* Defaults to `startColumn` when `startColumn` is provided. * Defaults to `startColumn` when `startColumn` is provided.
*/ */
endColumn?: number endColumn?: number
+4
View File
@@ -1,5 +1,9 @@
# @actions/core Releases # @actions/core Releases
### 1.10.0
- `saveState` and `setOutput` now use environment files if available [#1178](https://github.com/actions/toolkit/pull/1178)
- `getMultilineInput` now correctly trims whitespace by default [#1185](https://github.com/actions/toolkit/pull/1185)
### 1.9.1 ### 1.9.1
- Randomize delimiter when calling `core.exportVariable` - Randomize delimiter when calling `core.exportVariable`
+157 -16
View File
@@ -33,15 +33,17 @@ const testEnvVars = {
INPUT_BOOLEAN_INPUT_FALSE3: 'FALSE', INPUT_BOOLEAN_INPUT_FALSE3: 'FALSE',
INPUT_WRONG_BOOLEAN_INPUT: 'wrong', INPUT_WRONG_BOOLEAN_INPUT: 'wrong',
INPUT_WITH_TRAILING_WHITESPACE: ' some val ', INPUT_WITH_TRAILING_WHITESPACE: ' some val ',
INPUT_MY_INPUT_LIST: 'val1\nval2\nval3', INPUT_MY_INPUT_LIST: 'val1\nval2\nval3',
INPUT_LIST_WITH_TRAILING_WHITESPACE: ' val1 \n val2 \n ',
// Save inputs // Save inputs
STATE_TEST_1: 'state_val', STATE_TEST_1: 'state_val',
// File Commands // File Commands
GITHUB_PATH: '', GITHUB_PATH: '',
GITHUB_ENV: '' GITHUB_ENV: '',
GITHUB_OUTPUT: '',
GITHUB_STATE: ''
} }
const UUID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d' const UUID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
@@ -212,14 +214,6 @@ describe('@actions/core', () => {
) )
}) })
it('getMultilineInput works', () => {
expect(core.getMultilineInput('my input list')).toEqual([
'val1',
'val2',
'val3'
])
})
it('getInput trims whitespace by default', () => { it('getInput trims whitespace by default', () => {
expect(core.getInput('with trailing whitespace')).toBe('some val') expect(core.getInput('with trailing whitespace')).toBe('some val')
}) })
@@ -260,7 +254,38 @@ describe('@actions/core', () => {
) )
}) })
it('setOutput produces the correct command', () => { it('getMultilineInput works', () => {
expect(core.getMultilineInput('my input list')).toEqual([
'val1',
'val2',
'val3'
])
})
it('getMultilineInput trims whitespace by default', () => {
expect(core.getMultilineInput('list with trailing whitespace')).toEqual([
'val1',
'val2'
])
})
it('getMultilineInput trims whitespace when option is explicitly true', () => {
expect(
core.getMultilineInput('list with trailing whitespace', {
trimWhitespace: true
})
).toEqual(['val1', 'val2'])
})
it('getMultilineInput does not trim whitespace when option is false', () => {
expect(
core.getMultilineInput('list with trailing whitespace', {
trimWhitespace: false
})
).toEqual([' val1 ', ' val2 ', ' '])
})
it('legacy setOutput produces the correct command', () => {
core.setOutput('some output', 'some value') core.setOutput('some output', 'some value')
assertWriteCalls([ assertWriteCalls([
os.EOL, os.EOL,
@@ -268,16 +293,74 @@ describe('@actions/core', () => {
]) ])
}) })
it('setOutput handles bools', () => { it('legacy setOutput handles bools', () => {
core.setOutput('some output', false) core.setOutput('some output', false)
assertWriteCalls([os.EOL, `::set-output name=some output::false${os.EOL}`]) assertWriteCalls([os.EOL, `::set-output name=some output::false${os.EOL}`])
}) })
it('setOutput handles numbers', () => { it('legacy setOutput handles numbers', () => {
core.setOutput('some output', 1.01) core.setOutput('some output', 1.01)
assertWriteCalls([os.EOL, `::set-output name=some output::1.01${os.EOL}`]) assertWriteCalls([os.EOL, `::set-output name=some output::1.01${os.EOL}`])
}) })
it('setOutput produces the correct command and sets the output', () => {
const command = 'OUTPUT'
createFileCommandFile(command)
core.setOutput('my out', 'out val')
verifyFileCommand(
command,
`my out<<${DELIMITER}${os.EOL}out val${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('setOutput handles boolean inputs', () => {
const command = 'OUTPUT'
createFileCommandFile(command)
core.setOutput('my out', true)
verifyFileCommand(
command,
`my out<<${DELIMITER}${os.EOL}true${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('setOutput handles number inputs', () => {
const command = 'OUTPUT'
createFileCommandFile(command)
core.setOutput('my out', 5)
verifyFileCommand(
command,
`my out<<${DELIMITER}${os.EOL}5${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('setOutput does not allow delimiter as value', () => {
const command = 'OUTPUT'
createFileCommandFile(command)
expect(() => {
core.setOutput('my out', `good stuff ${DELIMITER} bad stuff`)
}).toThrow(
`Unexpected input: value should not contain the delimiter "${DELIMITER}"`
)
const filePath = path.join(__dirname, `test/${command}`)
fs.unlinkSync(filePath)
})
it('setOutput does not allow delimiter as name', () => {
const command = 'OUTPUT'
createFileCommandFile(command)
expect(() => {
core.setOutput(`good stuff ${DELIMITER} bad stuff`, 'test')
}).toThrow(
`Unexpected input: name should not contain the delimiter "${DELIMITER}"`
)
const filePath = path.join(__dirname, `test/${command}`)
fs.unlinkSync(filePath)
})
it('setFailed sets the correct exit code and failure message', () => { it('setFailed sets the correct exit code and failure message', () => {
core.setFailed('Failure message') core.setFailed('Failure message')
expect(process.exitCode).toBe(core.ExitCode.Failure) expect(process.exitCode).toBe(core.ExitCode.Failure)
@@ -443,21 +526,79 @@ describe('@actions/core', () => {
assertWriteCalls([`::debug::%0D%0Adebug%0A${os.EOL}`]) assertWriteCalls([`::debug::%0D%0Adebug%0A${os.EOL}`])
}) })
it('saveState produces the correct command', () => { it('legacy saveState produces the correct command', () => {
core.saveState('state_1', 'some value') core.saveState('state_1', 'some value')
assertWriteCalls([`::save-state name=state_1::some value${os.EOL}`]) assertWriteCalls([`::save-state name=state_1::some value${os.EOL}`])
}) })
it('saveState handles numbers', () => { it('legacy saveState handles numbers', () => {
core.saveState('state_1', 1) core.saveState('state_1', 1)
assertWriteCalls([`::save-state name=state_1::1${os.EOL}`]) assertWriteCalls([`::save-state name=state_1::1${os.EOL}`])
}) })
it('saveState handles bools', () => { it('legacy saveState handles bools', () => {
core.saveState('state_1', true) core.saveState('state_1', true)
assertWriteCalls([`::save-state name=state_1::true${os.EOL}`]) assertWriteCalls([`::save-state name=state_1::true${os.EOL}`])
}) })
it('saveState produces the correct command and saves the state', () => {
const command = 'STATE'
createFileCommandFile(command)
core.saveState('my state', 'out val')
verifyFileCommand(
command,
`my state<<${DELIMITER}${os.EOL}out val${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('saveState handles boolean inputs', () => {
const command = 'STATE'
createFileCommandFile(command)
core.saveState('my state', true)
verifyFileCommand(
command,
`my state<<${DELIMITER}${os.EOL}true${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('saveState handles number inputs', () => {
const command = 'STATE'
createFileCommandFile(command)
core.saveState('my state', 5)
verifyFileCommand(
command,
`my state<<${DELIMITER}${os.EOL}5${os.EOL}${DELIMITER}${os.EOL}`
)
})
it('saveState does not allow delimiter as value', () => {
const command = 'STATE'
createFileCommandFile(command)
expect(() => {
core.saveState('my state', `good stuff ${DELIMITER} bad stuff`)
}).toThrow(
`Unexpected input: value should not contain the delimiter "${DELIMITER}"`
)
const filePath = path.join(__dirname, `test/${command}`)
fs.unlinkSync(filePath)
})
it('saveState does not allow delimiter as name', () => {
const command = 'STATE'
createFileCommandFile(command)
expect(() => {
core.saveState(`good stuff ${DELIMITER} bad stuff`, 'test')
}).toThrow(
`Unexpected input: name should not contain the delimiter "${DELIMITER}"`
)
const filePath = path.join(__dirname, `test/${command}`)
fs.unlinkSync(filePath)
})
it('getState gets wrapper action state', () => { it('getState gets wrapper action state', () => {
expect(core.getState('TEST_1')).toBe('state_val') expect(core.getState('TEST_1')).toBe('state_val')
}) })
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@actions/core", "name": "@actions/core",
"version": "1.9.1", "version": "1.10.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/core", "name": "@actions/core",
"version": "1.9.1", "version": "1.10.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/core", "name": "@actions/core",
"version": "1.9.1", "version": "1.10.0",
"description": "Actions core lib", "description": "Actions core lib",
"keywords": [ "keywords": [
"github", "github",
+22 -25
View File
@@ -1,10 +1,9 @@
import {issue, issueCommand} from './command' import {issue, issueCommand} from './command'
import {issueCommand as issueFileCommand} from './file-command' import {issueFileCommand, prepareKeyValueMessage} from './file-command'
import {toCommandProperties, toCommandValue} from './utils' import {toCommandProperties, toCommandValue} from './utils'
import * as os from 'os' import * as os from 'os'
import * as path from 'path' import * as path from 'path'
import {v4 as uuidv4} from 'uuid'
import {OidcClient} from './oidc-utils' import {OidcClient} from './oidc-utils'
@@ -65,7 +64,7 @@ export interface AnnotationProperties {
startColumn?: number startColumn?: number
/** /**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
* Defaults to `startColumn` when `startColumn` is provided. * Defaults to `startColumn` when `startColumn` is provided.
*/ */
endColumn?: number endColumn?: number
@@ -87,26 +86,10 @@ export function exportVariable(name: string, val: any): void {
const filePath = process.env['GITHUB_ENV'] || '' const filePath = process.env['GITHUB_ENV'] || ''
if (filePath) { if (filePath) {
const delimiter = `ghadelimiter_${uuidv4()}` return issueFileCommand('ENV', prepareKeyValueMessage(name, val))
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
if (name.includes(delimiter)) {
throw new Error(
`Unexpected input: name should not contain the delimiter "${delimiter}"`
)
}
if (convertedVal.includes(delimiter)) {
throw new Error(
`Unexpected input: value should not contain the delimiter "${delimiter}"`
)
}
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`
issueFileCommand('ENV', commandValue)
} else {
issueCommand('set-env', {name}, convertedVal)
} }
issueCommand('set-env', {name}, convertedVal)
} }
/** /**
@@ -170,7 +153,11 @@ export function getMultilineInput(
.split('\n') .split('\n')
.filter(x => x !== '') .filter(x => x !== '')
return inputs if (options && options.trimWhitespace === false) {
return inputs
}
return inputs.map(input => input.trim())
} }
/** /**
@@ -203,8 +190,13 @@ export function getBooleanInput(name: string, options?: InputOptions): boolean {
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function setOutput(name: string, value: any): void { export function setOutput(name: string, value: any): void {
const filePath = process.env['GITHUB_OUTPUT'] || ''
if (filePath) {
return issueFileCommand('OUTPUT', prepareKeyValueMessage(name, value))
}
process.stdout.write(os.EOL) process.stdout.write(os.EOL)
issueCommand('set-output', {name}, value) issueCommand('set-output', {name}, toCommandValue(value))
} }
/** /**
@@ -358,7 +350,12 @@ export async function group<T>(name: string, fn: () => Promise<T>): Promise<T> {
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function saveState(name: string, value: any): void { export function saveState(name: string, value: any): void {
issueCommand('save-state', {name}, value) const filePath = process.env['GITHUB_STATE'] || ''
if (filePath) {
return issueFileCommand('STATE', prepareKeyValueMessage(name, value))
}
issueCommand('save-state', {name}, toCommandValue(value))
} }
/** /**
+24 -1
View File
@@ -5,9 +5,10 @@
import * as fs from 'fs' import * as fs from 'fs'
import * as os from 'os' import * as os from 'os'
import {v4 as uuidv4} from 'uuid'
import {toCommandValue} from './utils' import {toCommandValue} from './utils'
export function issueCommand(command: string, message: any): void { export function issueFileCommand(command: string, message: any): void {
const filePath = process.env[`GITHUB_${command}`] const filePath = process.env[`GITHUB_${command}`]
if (!filePath) { if (!filePath) {
throw new Error( throw new Error(
@@ -22,3 +23,25 @@ export function issueCommand(command: string, message: any): void {
encoding: 'utf8' encoding: 'utf8'
}) })
} }
export function prepareKeyValueMessage(key: string, value: any): string {
const delimiter = `ghadelimiter_${uuidv4()}`
const convertedValue = toCommandValue(value)
// These should realistically never happen, but just in case someone finds a
// way to exploit uuid generation let's not allow keys or values that contain
// the delimiter.
if (key.includes(delimiter)) {
throw new Error(
`Unexpected input: name should not contain the delimiter "${delimiter}"`
)
}
if (convertedValue.includes(delimiter)) {
throw new Error(
`Unexpected input: value should not contain the delimiter "${delimiter}"`
)
}
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`
}
+8
View File
@@ -1,5 +1,13 @@
# @actions/github Releases # @actions/github Releases
### 5.1.1
- Export default octokit options [#1188](https://github.com/actions/toolkit/pull/1188)
### 5.1.0
- Add additionalPlugins parameter to getOctokit method [#1181](https://github.com/actions/toolkit/pull/1181)
- Dependency updates [#1180](https://github.com/actions/toolkit/pull/1180)
### 5.0.3 ### 5.0.3
- - Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087) - - Update to v2.0.1 of `@actions/http-client` [#1087](https://github.com/actions/toolkit/pull/1087)
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@actions/github", "name": "@actions/github",
"version": "5.0.3", "version": "5.1.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/github", "name": "@actions/github",
"version": "5.0.3", "version": "5.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/github", "name": "@actions/github",
"version": "5.0.3", "version": "5.1.1",
"description": "Actions github lib", "description": "Actions github lib",
"keywords": [ "keywords": [
"github", "github",
+5 -3
View File
@@ -2,7 +2,7 @@ import * as Context from './context'
import {GitHub, getOctokitOptions} from './utils' import {GitHub, getOctokitOptions} from './utils'
// octokit + plugins // octokit + plugins
import {OctokitOptions} from '@octokit/core/dist-types/types' import {OctokitOptions, OctokitPlugin} from '@octokit/core/dist-types/types'
export const context = new Context.Context() export const context = new Context.Context()
@@ -14,7 +14,9 @@ export const context = new Context.Context()
*/ */
export function getOctokit( export function getOctokit(
token: string, token: string,
options?: OctokitOptions options?: OctokitOptions,
...additionalPlugins: OctokitPlugin[]
): InstanceType<typeof GitHub> { ): InstanceType<typeof GitHub> {
return new GitHub(getOctokitOptions(token, options)) const GitHubWithPlugins = GitHub.plugin(...additionalPlugins)
return new GitHubWithPlugins(getOctokitOptions(token, options))
} }
+1 -1
View File
@@ -10,7 +10,7 @@ import {paginateRest} from '@octokit/plugin-paginate-rest'
export const context = new Context.Context() export const context = new Context.Context()
const baseUrl = Utils.getApiBaseUrl() const baseUrl = Utils.getApiBaseUrl()
const defaults = { export const defaults: OctokitOptions = {
baseUrl, baseUrl,
request: { request: {
agent: Utils.getProxyAgent(baseUrl) agent: Utils.getProxyAgent(baseUrl)
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@actions/io", "name": "@actions/io",
"version": "1.1.2", "version": "1.1.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/io", "name": "@actions/io",
"version": "1.1.2", "version": "1.1.3",
"license": "MIT" "license": "MIT"
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/io", "name": "@actions/io",
"version": "1.1.2", "version": "1.1.3",
"description": "Actions io lib", "description": "Actions io lib",
"keywords": [ "keywords": [
"github", "github",
+12 -3
View File
@@ -4,7 +4,8 @@ import * as path from 'path'
import {promisify} from 'util' import {promisify} from 'util'
import * as ioUtil from './io-util' import * as ioUtil from './io-util'
const exec = promisify(childProcess.exec) // const exec = promisify(childProcess.exec)
// const fork = promisify(childProcess.fork)
const execFile = promisify(childProcess.execFile) const execFile = promisify(childProcess.execFile)
/** /**
@@ -129,12 +130,20 @@ export async function rmRF(inputPath: string): Promise<void> {
try { try {
const cmdPath = ioUtil.getCmdPath() const cmdPath = ioUtil.getCmdPath()
if (await ioUtil.isDirectory(inputPath, true)) { if (await ioUtil.isDirectory(inputPath, true)) {
await exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { await execFile(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: {inputPath} env: {inputPath}
}).catch(err => {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT') throw err
}) })
} else { } else {
await exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { await execFile(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: {inputPath} env: {inputPath}
}).catch(err => {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT') throw err
}) })
} }
} catch (err) { } catch (err) {