Compare commits

..
Author SHA1 Message Date
Thomas Boop 5dc68c18e2 Update to node16
Node 12 has an end of life on April 30, 2022.

This PR updates the default runtime to [node16](https://github.blog/changelog/2021-12-10-github-actions-github-hosted-runners-now-run-node-js-16-by-default/), rather then node12. 

This is supported on all Actions Runners v2.285.0 or later.
2022-02-07 14:06:57 -05:00
Konrad Pabjan 87348cee5f Add 503 warning when uploading to the same artifact 2022-01-20 15:26:28 +01:00
Konrad Pabjan 82c141cc51 Bump @actions/artifact to version 0.6.1 (#286) 2021-12-15 09:47:54 -05:00
Konrad Pabjan da838ae959 Bump @actions/artifact to version 0.6.0 (#280) 2021-12-07 11:45:04 -05:00
Jozef Izso f4ac36d205 Improve readme (#278) 2021-12-07 09:07:03 -05:00
Konrad Pabjan 5f375cca4b Document how to correctly use environment variables for path input (#274)
* Update README.md

* Update README.md
2021-12-06 16:35:35 -05:00
Konrad Pabjan a009a66585 Create release-new-action-version.yml (#277) 2021-12-02 10:29:09 -05:00
dependabot[bot]dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Konrad Pabjan
b9bb65708e Bump tmpl from 1.0.4 to 1.0.5 (#250)
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2021-12-01 17:23:57 -05:00
Peter Mescalchin 0b3de3e43b Fix README.md links and some formatting updates (#273)
* Some `README.md` whitespace and tweaks

* Fix link and title to GitHub documentation page on `README.md`

* Update link to `actions/toolkit` documentation

* De-quote some YAML blocks/examples in `README.md`
2021-12-01 08:48:09 -05:00
Rob Herley 54f3f7f081 Merge pull request #271 from actions/robherley/dupe-issue-template
rm dupe security vulnerability from issue template
2021-11-23 14:49:07 -05:00
Rob Herley f061e61d75 rm dupe security vulnerability from issue template 2021-11-23 14:47:33 -05:00
Rob Herley ee82d6a40e Merge pull request #269 from actions/robherley/update-issue-templates
Add issue templates
2021-11-22 17:09:19 -05:00
Rob Herley ecd66f1683 add issue templates 2021-11-22 10:51:21 -05:00
Alberto Gimeno 37da8e8d08 Merge pull request #241 from actions/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-11-10 11:56:12 +01:00
dependabot[bot] cd62eed952 Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-15 14:49:55 +00:00
Alberto Gimeno 6fc84b101e Merge pull request #257 from actions/upgrade-dependencies
Upgrade dependencies
2021-10-15 16:48:51 +02:00
Alberto Gimeno 551bc9bdf8 Upgrade jest, jest-circus and ts-jest 2021-10-15 10:24:17 +02:00
Brian Cristante 11e311c8b5 Remove path filters (#229) 2021-06-25 13:39:56 -04:00
Brian CristanteandJosh Gross 317b58f0d1 Fix YAML types in licensed.yml (#228)
* fix YAML types in licensed.yml

* Update .github/workflows/licensed.yml

Co-authored-by: Josh Gross <joshmgross@github.com>

* formatting

Co-authored-by: Josh Gross <joshmgross@github.com>
2021-06-24 11:52:33 -04:00
Brian CristanteandKonrad Pabjan 8d06e6c094 Create check-dist.yml (#227)
* Create check-dist.yml

* steps.if still needs ${{ }} when the expr has operators

* single quotes?

* npm install

* mess with index.js

* add if failure()

* Copy the correct version back in from the artifact

* Update .github/workflows/check-dist.yml

Co-authored-by: Konrad Pabjan <konradpabjan@github.com>

* formatting & language

* npm ci

Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
2021-06-24 11:38:43 -04:00
15 changed files with 5194 additions and 5113 deletions
+63
View File
@@ -0,0 +1,63 @@
name: "🐛 Bug report"
description: Let us know about a bug!
labels: ['bug']
title: '[bug]'
body:
- type: textarea
id: problem
attributes:
label: What happened?
description: |
Please provide a clear and concise description of what the bug is. If applicable, add screenshots to help explain your problem.
validations:
required: true
- type: textarea
id: expected
attributes:
label: What did you expect to happen?
validations:
required: true
- type: textarea
id: repro
attributes:
label: How can we reproduce it?
description: |
Please be minimal and precise as possible. If your repo/run is public, please include a URL so it is easier for us to investigate.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Anything else we need to know?
- type: input
id: version
attributes:
label: What version of the action are you using?
placeholder: vX.Y.Z
description: |
Please check the documentation first since different major versions can have different behaviors.
validations:
required: true
- type: dropdown
id: environment
attributes:
label: What are your runner environments?
multiple: true
options:
- self-hosted
- linux
- window
- macos
validations:
required: true
- type: input
id: ghes
attributes:
label: Are you on GitHub Enterprise Server? If so, what version?
placeholder: vX.Y
-33
View File
@@ -1,33 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**Version**
- [ ] V1
- [ ] V2
**Environment**
- [ ] self-hosted
- [ ] Linux
- [ ] Windows
- [ ] Mac
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Run/Repo Url**
If applicable, and if your repo/run is public, please include a URL so it is easier for us to investigate.
**How to reproduce**
If applicable, add information on how to reproduce the problem.
**Additional context**
Add any other context about the problem here.
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 🙋 Ask a question
url: https://github.community/c/code-to-cloud/52
about: Please ask and answer questions on GitHub Support Community.
@@ -0,0 +1,28 @@
name: "📚 Documentation issues"
description: Make a suggestion to improve the documentation!
labels: ['documentation']
title: '[docs]'
body:
- type: markdown
attributes:
value: |
❗ This is only for documentation updates for files in this repo, ie: `README.md`.
If you want to suggest changes for the [GitHub Docs](https://docs.github.com/), please [open an issue there](https://github.com/github/docs/issues/new/choose).
- type: textarea
id: affected
attributes:
label: What files would you like to change?
description: |
Please provide permalinks to the specified files and line numbers.
validations:
required: true
- type: textarea
id: suggested
attributes:
label: What are your suggested changes?
description: |
Give as much detail as you can to help us understand the changes you want to see.
validations:
required: true
@@ -0,0 +1,20 @@
name: "🎁 Feature request"
description: Suggest a new feature/enhancement!
labels: ['enhancement']
title: '[feat req]'
body:
- type: textarea
id: feature
attributes:
label: What would you like to be added?
description: |
Please check existing issues to avoid making duplicates. Any duplicate issue will be closed immediately.
validations:
required: true
- type: textarea
id: reasoning
attributes:
label: Why is this needed?
validations:
required: true
+48
View File
@@ -0,0 +1,48 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process
# from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Move the committed index.js file
run: mv dist/index.js /tmp
- name: Rebuild the index.js file
run: npm run release
- name: Compare the expected and actual index.js files
run: git diff --ignore-all-space dist/index.js /tmp/index.js
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: index.js
path: dist/index.js
+7 -3
View File
@@ -1,8 +1,12 @@
name: Licensed name: Licensed
on: on:
push: {branches: main} push:
pull_request: {branches: main} branches:
- main
pull_request:
branches:
- main
jobs: jobs:
test: test:
@@ -17,4 +21,4 @@ jobs:
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed sudo mv licensed /usr/local/bin/licensed
- run: licensed status - run: licensed status
@@ -0,0 +1,28 @@
name: Release new action version
on:
release:
types: [released]
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
permissions:
contents: write
jobs:
update_tag:
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
environment:
name: releaseNewActionVersion
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
+2 -2
View File
@@ -30,8 +30,8 @@ jobs:
with: with:
node-version: 12.x node-version: 12.x
- name: npm install - name: Install dependencies
run: npm install run: npm ci
- name: Compile - name: Compile
run: npm run build run: npm run build
+1 -1
View File
@@ -1,6 +1,6 @@
--- ---
name: "@actions/artifact" name: "@actions/artifact"
version: 0.5.2 version: 0.6.1
type: npm type: npm
summary: summary:
homepage: homepage:
+60 -41
View File
@@ -6,7 +6,7 @@ See also [download-artifact](https://github.com/actions/download-artifact).
# What's new # What's new
- Easier upload - Easier upload
- Specify a wildcard pattern - Specify a wildcard pattern
- Specify an individual file - Specify an individual file
- Specify a directory (previously you were limited to only this option) - Specify a directory (previously you were limited to only this option)
@@ -25,6 +25,7 @@ Refer [here](https://github.com/actions/upload-artifact/tree/releases/v1) for th
See [action.yml](action.yml) See [action.yml](action.yml)
### Upload an Individual File ### Upload an Individual File
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -49,6 +50,7 @@ steps:
``` ```
### Upload using a Wildcard Pattern ### Upload using a Wildcard Pattern
```yaml ```yaml
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
@@ -57,6 +59,7 @@ steps:
``` ```
### Upload using Multiple Paths and Exclusions ### Upload using Multiple Paths and Exclusions
```yaml ```yaml
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
@@ -69,19 +72,20 @@ steps:
For supported wildcards along with behavior and documentation, see [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob) which is used internally to search for files. For supported wildcards along with behavior and documentation, see [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob) which is used internally to search for files.
If a wildcard pattern is used, the path hierarchy will be preserved after the first wildcard pattern. If a wildcard pattern is used, the path hierarchy will be preserved after the first wildcard pattern:
``` ```
path/to/*/directory/foo?.txt => path/to/*/directory/foo?.txt =>
∟ path/to/some/directory/foo1.txt ∟ path/to/some/directory/foo1.txt
∟ path/to/some/directory/foo2.txt ∟ path/to/some/directory/foo2.txt
∟ path/to/other/directory/foo1.txt ∟ path/to/other/directory/foo1.txt
would be flattened and uploaded as => would be flattened and uploaded as =>
∟ some/directory/foo1.txt ∟ some/directory/foo1.txt
∟ some/directory/foo2.txt ∟ some/directory/foo2.txt
∟ other/directory/foo1.txt ∟ other/directory/foo1.txt
``` ```
If multiple paths are provided as input, the least common ancestor of all the search paths will be used as the root directory of the artifact. Exclude paths do not affect the directory structure. If multiple paths are provided as input, the least common ancestor of all the search paths will be used as the root directory of the artifact. Exclude paths do not affect the directory structure.
Relative and absolute file paths are both allowed. Relative paths are rooted against the current working directory. Paths that begin with a wildcard character should be quoted to avoid being interpreted as YAML aliases. Relative and absolute file paths are both allowed. Relative paths are rooted against the current working directory. Paths that begin with a wildcard character should be quoted to avoid being interpreted as YAML aliases.
@@ -90,14 +94,14 @@ The [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/ar
### Customization if no files are found ### Customization if no files are found
If a path (or paths), result in no files being found for the artifact, the action will succeed but print out a warning. In certain scenarios it may be desirable to fail the action or suppress the warning. The `if-no-files-found` option allows you to customize the behavior of the action if no files are found. If a path (or paths), result in no files being found for the artifact, the action will succeed but print out a warning. In certain scenarios it may be desirable to fail the action or suppress the warning. The `if-no-files-found` option allows you to customize the behavior of the action if no files are found:
```yaml ```yaml
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: my-artifact name: my-artifact
path: path/to/artifact/ path: path/to/artifact/
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
``` ```
### Conditional Artifact Upload ### Conditional Artifact Upload
@@ -115,6 +119,7 @@ To upload artifacts only when the previous step of a job failed, use [`if: failu
### Uploading without an artifact name ### Uploading without an artifact name
You can upload an artifact without specifying a name You can upload an artifact without specifying a name
```yaml ```yaml
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
@@ -125,7 +130,7 @@ If not provided, `artifact` will be used as the default name which will manifest
### Uploading to the same artifact ### Uploading to the same artifact
With the following example, the available artifact (named `artifact` by default if no name is provided) would contain both `world.txt` (`hello`) and `extra-file.txt` (`howdy`). With the following example, the available artifact (named `artifact` by default if no name is provided) would contain both `world.txt` (`hello`) and `extra-file.txt` (`howdy`):
```yaml ```yaml
- run: echo hi > world.txt - run: echo hi > world.txt
@@ -144,28 +149,28 @@ With the following example, the available artifact (named `artifact` by default
path: world.txt path: world.txt
``` ```
> **_Warning:_** Be careful when uploading to the same artifact via multiple jobs as artifacts may become corrupted Each artifact behaves as a file share. Uploading to the same artifact multiple times in the same workflow can overwrite and append already uploaded files:
Each artifact behaves as a file share. Uploading to the same artifact multiple times in the same workflow can overwrite and append already uploaded files
```yaml ```yaml
strategy: strategy:
matrix: matrix:
node-version: [8.x, 10.x, 12.x, 13.x] node-version: [8.x, 10.x, 12.x, 13.x]
steps: steps:
- name: 'Create a file' - name: Create a file
run: echo ${{ matrix.node-version }} > my_file.txt run: echo ${{ matrix.node-version }} > my_file.txt
- name: 'Accidently upload to the same artifact via multiple jobs' - name: Accidentally upload to the same artifact via multiple jobs
uses: 'actions/upload-artifact@v2' uses: actions/upload-artifact@v2
with: with:
name: my-artifact name: my-artifact
path: ${{ github.workspace }} path: ${{ github.workspace }}
``` ```
In the above example, four jobs will upload four different files to the same artifact but there will only be one file available when `my-artifact` is downloaded. Each job overwrites what was previously uploaded. To ensure that jobs don't overwrite existing artifacts, use a different name per job. > **_Warning:_** Be careful when uploading to the same artifact via multiple jobs as artifacts may become corrupted. When uploading a file with an identical name and path in multiple jobs, uploads may fail with 503 errors due to conflicting uploads happening at the same time. Ensure uploads to identical locations to not interfere with each other.
In the above example, four jobs will upload four different files to the same artifact but there will only be one file available when `my-artifact` is downloaded. Each job overwrites what was previously uploaded. To ensure that jobs don't overwrite existing artifacts, use a different name per job:
```yaml ```yaml
uses: 'actions/upload-artifact@v2' uses: actions/upload-artifact@v2
with: with:
name: my-artifact ${{ matrix.node-version }} name: my-artifact ${{ matrix.node-version }}
path: ${{ github.workspace }} path: ${{ github.workspace }}
@@ -173,48 +178,61 @@ In the above example, four jobs will upload four different files to the same art
### Environment Variables and Tilde Expansion ### Environment Variables and Tilde Expansion
You can use `~` in the path input as a substitute for `$HOME`. Basic tilde expansion is supported. You can use `~` in the path input as a substitute for `$HOME`. Basic tilde expansion is supported:
```yaml ```yaml
- run: | - run: |
mkdir -p ~/new/artifact mkdir -p ~/new/artifact
echo hello > ~/new/artifact/world.txt echo hello > ~/new/artifact/world.txt
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: 'Artifacts-V2' name: Artifacts-V2
path: '~/new/**/*' path: ~/new/**/*
``` ```
Environment variables along with context expressions can also be used for input. For documentation see [context and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions). Environment variables along with context expressions can also be used for input. For documentation see [context and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions):
```yaml ```yaml
env: env:
name: my-artifact name: my-artifact
steps: steps:
- run: | - run: |
mkdir -p ${{ github.workspace }}/artifact mkdir -p ${{ github.workspace }}/artifact
echo hello > ${{ github.workspace }}/artifact/world.txt echo hello > ${{ github.workspace }}/artifact/world.txt
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: ${{ env.name }}-name name: ${{ env.name }}-name
path: ${{ github.workspace }}/artifact/**/* path: ${{ github.workspace }}/artifact/**/*
``` ```
For environment variables created in other steps, make sure to use the `env` expression syntax
```yaml
steps:
- run: |
mkdir testing
echo "This is a file to upload" > testing/file.txt
echo "artifactPath=testing/file.txt" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: artifact
path: ${{ env.artifactPath }} # this will resolve to testing/file.txt at runtime
```
### Retention Period ### Retention Period
Artifacts are retained for 90 days by default. You can specify a shorter retention period using the `retention-days` input: Artifacts are retained for 90 days by default. You can specify a shorter retention period using the `retention-days` input:
```yaml ```yaml
- name: 'Create a file' - name: Create a file
run: echo "I won't live long" > my_file.txt run: echo "I won't live long" > my_file.txt
- name: 'Upload Artifact' - name: Upload Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: my-artifact name: my-artifact
path: my_file.txt path: my_file.txt
retention-days: 5 retention-days: 5
``` ```
The retention period must be between 1 and 90 inclusive. For more information see [artifact and log retention policies](https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration#artifact-and-log-retention-policy). The retention period must be between 1 and 90 inclusive. For more information see [artifact and log retention policies](https://docs.github.com/en/free-pro-team@latest/actions/reference/usage-limits-billing-and-administration#artifact-and-log-retention-policy).
@@ -233,7 +251,7 @@ The size of the artifact is denoted in bytes. The displayed artifact size denote
### Zipped Artifact Downloads ### Zipped Artifact Downloads
During a workflow run, files are uploaded and downloaded individually using the `upload-artifact` and `download-artifact` actions. However, when a workflow run finishes and an artifact is downloaded from either the UI or through the [download api](https://developer.github.com/v3/actions/artifacts/#download-an-artifact), a zip is dynamically created with all the file contents that were uploaded. There is currently no way to download artifacts after a workflow run finishes in a format other than a zip or to download artifact contents individually. One of the consequences of this limitation is that if a zip is uploaded during a workflow run and then downloaded from the UI, there will be a double zip created. During a workflow run, files are uploaded and downloaded individually using the `upload-artifact` and `download-artifact` actions. However, when a workflow run finishes and an artifact is downloaded from either the UI or through the [download api](https://developer.github.com/v3/actions/artifacts/#download-an-artifact), a zip is dynamically created with all the file contents that were uploaded. There is currently no way to download artifacts after a workflow run finishes in a format other than a zip or to download artifact contents individually. One of the consequences of this limitation is that if a zip is uploaded during a workflow run and then downloaded from the UI, there will be a double zip created.
### Permission Loss ### Permission Loss
@@ -245,18 +263,19 @@ During a workflow run, files are uploaded and downloaded individually using the
### Maintaining file permissions and case sensitive files ### Maintaining file permissions and case sensitive files
If file permissions and case sensitivity are required, you can `tar` all of your files together before artifact upload. Post download, the `tar` file will maintain file permissions and case sensitivity. If file permissions and case sensitivity are required, you can `tar` all of your files together before artifact upload. Post download, the `tar` file will maintain file permissions and case sensitivity:
```yaml ```yaml
- name: 'Tar files' - name: Tar files
run: tar -cvf my_files.tar /path/to/my/directory run: tar -cvf my_files.tar /path/to/my/directory
- name: 'Upload Artifact' - name: Upload Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: my-artifact name: my-artifact
path: my_files.tar path: my_files.tar
``` ```
### Too many uploads resulting in 429 responses ### Too many uploads resulting in 429 responses
A very minute subset of users who upload a very very large amount of artifacts in a short period of time may see their uploads throttled or fail because of `Request was blocked due to exceeding usage of resource 'DBCPU' in namespace` or `Unable to copy file to server StatusCode=TooManyRequests`. A very minute subset of users who upload a very very large amount of artifacts in a short period of time may see their uploads throttled or fail because of `Request was blocked due to exceeding usage of resource 'DBCPU' in namespace` or `Unable to copy file to server StatusCode=TooManyRequests`.
@@ -265,10 +284,10 @@ To reduce the chance of this happening, you can reduce the number of HTTP calls
## Additional Documentation ## Additional Documentation
See [persisting workflow data using artifacts](https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts) for additional examples and tips. See [Storing workflow data as artifacts](https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts) for additional examples and tips.
See extra documentation for the [@actions/artifact](https://github.com/actions/toolkit/blob/master/packages/artifact/docs/additional-information.md) package that is used internally regarding certain behaviors and limitations. See extra documentation for the [@actions/artifact](https://github.com/actions/toolkit/blob/main/packages/artifact/docs/additional-information.md) package that is used internally regarding certain behaviors and limitations.
# License # License
The scripts and documentation in this project are released under the [MIT License](LICENSE) The scripts and documentation in this project are released under the [MIT License](LICENSE).
+1 -1
View File
@@ -24,5 +24,5 @@ inputs:
Minimum 1 day. Minimum 1 day.
Maximum 90 days unless changed from the repository settings page. Maximum 90 days unless changed from the repository settings page.
runs: runs:
using: 'node12' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'
+897 -815
View File
@@ -81,6 +81,373 @@ function wrappy (fn, cb) {
} }
/***/ }),
/***/ 13:
/***/ (function(module, __unusedexports, __webpack_require__) {
const assert = __webpack_require__(357)
const path = __webpack_require__(622)
const fs = __webpack_require__(747)
let glob = undefined
try {
glob = __webpack_require__(402)
} catch (_err) {
// treat glob as optional.
}
const defaultGlobOpts = {
nosort: true,
silent: true
}
// for EMFILE handling
let timeout = 0
const isWindows = (process.platform === "win32")
const defaults = options => {
const methods = [
'unlink',
'chmod',
'stat',
'lstat',
'rmdir',
'readdir'
]
methods.forEach(m => {
options[m] = options[m] || fs[m]
m = m + 'Sync'
options[m] = options[m] || fs[m]
})
options.maxBusyTries = options.maxBusyTries || 3
options.emfileWait = options.emfileWait || 1000
if (options.glob === false) {
options.disableGlob = true
}
if (options.disableGlob !== true && glob === undefined) {
throw Error('glob dependency not found, set `options.disableGlob = true` if intentional')
}
options.disableGlob = options.disableGlob || false
options.glob = options.glob || defaultGlobOpts
}
const rimraf = (p, options, cb) => {
if (typeof options === 'function') {
cb = options
options = {}
}
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
assert(options, 'rimraf: invalid options argument provided')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
defaults(options)
let busyTries = 0
let errState = null
let n = 0
const next = (er) => {
errState = errState || er
if (--n === 0)
cb(errState)
}
const afterGlob = (er, results) => {
if (er)
return cb(er)
n = results.length
if (n === 0)
return cb()
results.forEach(p => {
const CB = (er) => {
if (er) {
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
busyTries < options.maxBusyTries) {
busyTries ++
// try again, with the same exact callback as this one.
return setTimeout(() => rimraf_(p, options, CB), busyTries * 100)
}
// this one won't happen if graceful-fs is used.
if (er.code === "EMFILE" && timeout < options.emfileWait) {
return setTimeout(() => rimraf_(p, options, CB), timeout ++)
}
// already gone
if (er.code === "ENOENT") er = null
}
timeout = 0
next(er)
}
rimraf_(p, options, CB)
})
}
if (options.disableGlob || !glob.hasMagic(p))
return afterGlob(null, [p])
options.lstat(p, (er, stat) => {
if (!er)
return afterGlob(null, [p])
glob(p, options.glob, afterGlob)
})
}
// Two possible strategies.
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
//
// Both result in an extra syscall when you guess wrong. However, there
// are likely far more normal files in the world than directories. This
// is based on the assumption that a the average number of files per
// directory is >= 1.
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow. But until then, YAGNI.
const rimraf_ = (p, options, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
// sunos lets the root user unlink directories, which is... weird.
// so we have to lstat here and make sure it's not a dir.
options.lstat(p, (er, st) => {
if (er && er.code === "ENOENT")
return cb(null)
// Windows can EPERM on stat. Life is suffering.
if (er && er.code === "EPERM" && isWindows)
fixWinEPERM(p, options, er, cb)
if (st && st.isDirectory())
return rmdir(p, options, er, cb)
options.unlink(p, er => {
if (er) {
if (er.code === "ENOENT")
return cb(null)
if (er.code === "EPERM")
return (isWindows)
? fixWinEPERM(p, options, er, cb)
: rmdir(p, options, er, cb)
if (er.code === "EISDIR")
return rmdir(p, options, er, cb)
}
return cb(er)
})
})
}
const fixWinEPERM = (p, options, er, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
options.chmod(p, 0o666, er2 => {
if (er2)
cb(er2.code === "ENOENT" ? null : er)
else
options.stat(p, (er3, stats) => {
if (er3)
cb(er3.code === "ENOENT" ? null : er)
else if (stats.isDirectory())
rmdir(p, options, er, cb)
else
options.unlink(p, cb)
})
})
}
const fixWinEPERMSync = (p, options, er) => {
assert(p)
assert(options)
try {
options.chmodSync(p, 0o666)
} catch (er2) {
if (er2.code === "ENOENT")
return
else
throw er
}
let stats
try {
stats = options.statSync(p)
} catch (er3) {
if (er3.code === "ENOENT")
return
else
throw er
}
if (stats.isDirectory())
rmdirSync(p, options, er)
else
options.unlinkSync(p)
}
const rmdir = (p, options, originalEr, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
// if we guessed wrong, and it's not a directory, then
// raise the original error.
options.rmdir(p, er => {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
rmkids(p, options, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)
else
cb(er)
})
}
const rmkids = (p, options, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
options.readdir(p, (er, files) => {
if (er)
return cb(er)
let n = files.length
if (n === 0)
return options.rmdir(p, cb)
let errState
files.forEach(f => {
rimraf(path.join(p, f), options, er => {
if (errState)
return
if (er)
return cb(errState = er)
if (--n === 0)
options.rmdir(p, cb)
})
})
})
}
// this looks simpler, and is strictly *faster*, but will
// tie up the JavaScript thread and fail on excessively
// deep directory trees.
const rimrafSync = (p, options) => {
options = options || {}
defaults(options)
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert(options, 'rimraf: missing options')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
let results
if (options.disableGlob || !glob.hasMagic(p)) {
results = [p]
} else {
try {
options.lstatSync(p)
results = [p]
} catch (er) {
results = glob.sync(p, options.glob)
}
}
if (!results.length)
return
for (let i = 0; i < results.length; i++) {
const p = results[i]
let st
try {
st = options.lstatSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
// Windows can EPERM on stat. Life is suffering.
if (er.code === "EPERM" && isWindows)
fixWinEPERMSync(p, options, er)
}
try {
// sunos lets the root user unlink directories, which is... weird.
if (st && st.isDirectory())
rmdirSync(p, options, null)
else
options.unlinkSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
if (er.code === "EPERM")
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
if (er.code !== "EISDIR")
throw er
rmdirSync(p, options, er)
}
}
}
const rmdirSync = (p, options, originalEr) => {
assert(p)
assert(options)
try {
options.rmdirSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
if (er.code === "ENOTDIR")
throw originalEr
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
rmkidsSync(p, options)
}
}
const rmkidsSync = (p, options) => {
assert(p)
assert(options)
options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options))
// We only end up here once we got ENOTEMPTY at least once, and
// at this point, we are guaranteed to have removed all the kids.
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
const retries = isWindows ? 100 : 1
let i = 0
do {
let threw = true
try {
const ret = options.rmdirSync(p, options)
threw = false
return ret
} finally {
if (++i < retries && threw)
continue
}
} while (true)
}
module.exports = rimraf
rimraf.sync = rimrafSync
/***/ }), /***/ }),
/***/ 16: /***/ 16:
@@ -1738,10 +2105,8 @@ const fs = __webpack_require__(747);
const os = __webpack_require__(87); const os = __webpack_require__(87);
const path = __webpack_require__(622); const path = __webpack_require__(622);
const crypto = __webpack_require__(417); const crypto = __webpack_require__(417);
const _c = fs.constants && os.constants ? const _c = { fs: fs.constants, os: os.constants };
{ fs: fs.constants, os: os.constants } : const rimraf = __webpack_require__(13);
process.binding('constants');
const rimraf = __webpack_require__(569);
/* /*
* The working inner variables. * The working inner variables.
@@ -1756,128 +2121,26 @@ const
CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR),
// constants are off on the windows platform and will not match the actual errno codes
IS_WIN32 = os.platform() === 'win32',
EBADF = _c.EBADF || _c.os.errno.EBADF, EBADF = _c.EBADF || _c.os.errno.EBADF,
ENOENT = _c.ENOENT || _c.os.errno.ENOENT, ENOENT = _c.ENOENT || _c.os.errno.ENOENT,
DIR_MODE = 448 /* 0o700 */, DIR_MODE = 0o700 /* 448 */,
FILE_MODE = 384 /* 0o600 */, FILE_MODE = 0o600 /* 384 */,
EXIT = 'exit', EXIT = 'exit',
SIGINT = 'SIGINT',
// this will hold the objects need to be removed on exit // this will hold the objects need to be removed on exit
_removeObjects = []; _removeObjects = [],
var // API change in fs.rmdirSync leads to error when passing in a second parameter, e.g. the callback
FN_RMDIR_SYNC = fs.rmdirSync.bind(fs),
FN_RIMRAF_SYNC = rimraf.sync;
let
_gracefulCleanup = false; _gracefulCleanup = false;
/**
* Random name generator based on crypto.
* Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript
*
* @param {number} howMany
* @returns {string} the generated random name
* @private
*/
function _randomChars(howMany) {
var
value = [],
rnd = null;
// make sure that we do not fail because we ran out of entropy
try {
rnd = crypto.randomBytes(howMany);
} catch (e) {
rnd = crypto.pseudoRandomBytes(howMany);
}
for (var i = 0; i < howMany; i++) {
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
}
return value.join('');
}
/**
* Checks whether the `obj` parameter is defined or not.
*
* @param {Object} obj
* @returns {boolean} true if the object is undefined
* @private
*/
function _isUndefined(obj) {
return typeof obj === 'undefined';
}
/**
* Parses the function arguments.
*
* This function helps to have optional arguments.
*
* @param {(Options|Function)} options
* @param {Function} callback
* @returns {Array} parsed arguments
* @private
*/
function _parseArguments(options, callback) {
/* istanbul ignore else */
if (typeof options === 'function') {
return [{}, options];
}
/* istanbul ignore else */
if (_isUndefined(options)) {
return [{}, callback];
}
return [options, callback];
}
/**
* Generates a new temporary name.
*
* @param {Object} opts
* @returns {string} the new random name according to opts
* @private
*/
function _generateTmpName(opts) {
const tmpDir = _getTmpDir();
// fail early on missing tmp dir
if (isBlank(opts.dir) && isBlank(tmpDir)) {
throw new Error('No tmp dir specified');
}
/* istanbul ignore else */
if (!isBlank(opts.name)) {
return path.join(opts.dir || tmpDir, opts.name);
}
// mkstemps like template
// opts.template has already been guarded in tmpName() below
/* istanbul ignore else */
if (opts.template) {
var template = opts.template;
// make sure that we prepend the tmp path if none was given
/* istanbul ignore else */
if (path.basename(template) === template)
template = path.join(opts.dir || tmpDir, template);
return template.replace(TEMPLATE_PATTERN, _randomChars(6));
}
// prefix and postfix
const name = [
(isBlank(opts.prefix) ? 'tmp-' : opts.prefix),
process.pid,
_randomChars(12),
(opts.postfix ? opts.postfix : '')
].join('');
return path.join(opts.dir || tmpDir, name);
}
/** /**
* Gets a temporary file name. * Gets a temporary file name.
* *
@@ -1885,20 +2148,18 @@ function _generateTmpName(opts) {
* @param {?tmpNameCallback} callback the callback function * @param {?tmpNameCallback} callback the callback function
*/ */
function tmpName(options, callback) { function tmpName(options, callback) {
var const
args = _parseArguments(options, callback), args = _parseArguments(options, callback),
opts = args[0], opts = args[0],
cb = args[1], cb = args[1];
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
/* istanbul ignore else */ try {
if (isNaN(tries) || tries < 0) _assertAndSanitizeOptions(opts);
return cb(new Error('Invalid tries')); } catch (err) {
return cb(err);
/* istanbul ignore else */ }
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
return cb(new Error('Invalid template provided'));
let tries = opts.tries;
(function _getUniqueName() { (function _getUniqueName() {
try { try {
const name = _generateTmpName(opts); const name = _generateTmpName(opts);
@@ -1929,19 +2190,13 @@ function tmpName(options, callback) {
* @throws {Error} if the options are invalid or could not generate a filename * @throws {Error} if the options are invalid or could not generate a filename
*/ */
function tmpNameSync(options) { function tmpNameSync(options) {
var const
args = _parseArguments(options), args = _parseArguments(options),
opts = args[0], opts = args[0];
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
/* istanbul ignore else */ _assertAndSanitizeOptions(opts);
if (isNaN(tries) || tries < 0)
throw new Error('Invalid tries');
/* istanbul ignore else */
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
throw new Error('Invalid template provided');
let tries = opts.tries;
do { do {
const name = _generateTmpName(opts); const name = _generateTmpName(opts);
try { try {
@@ -1957,11 +2212,11 @@ function tmpNameSync(options) {
/** /**
* Creates and opens a temporary file. * Creates and opens a temporary file.
* *
* @param {(Options|fileCallback)} options the config options or the callback function * @param {(Options|null|undefined|fileCallback)} options the config options or the callback function or null or undefined
* @param {?fileCallback} callback * @param {?fileCallback} callback
*/ */
function file(options, callback) { function file(options, callback) {
var const
args = _parseArguments(options, callback), args = _parseArguments(options, callback),
opts = args[0], opts = args[0],
cb = args[1]; cb = args[1];
@@ -1973,34 +2228,20 @@ function file(options, callback) {
// create and open the file // create and open the file
fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) { fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) {
/* istanbul ignore else */ /* istanbu ignore else */
if (err) return cb(err); if (err) return cb(err);
if (opts.discardDescriptor) { if (opts.discardDescriptor) {
return fs.close(fd, function _discardCallback(err) { return fs.close(fd, function _discardCallback(possibleErr) {
/* istanbul ignore else */ // the chance of getting an error on close here is rather low and might occur in the most edgiest cases only
if (err) { return cb(possibleErr, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts, false));
// Low probability, and the file exists, so this could be
// ignored. If it isn't we certainly need to unlink the
// file, and if that fails too its error is more
// important.
try {
fs.unlinkSync(name);
} catch (e) {
if (!isENOENT(e)) {
err = e;
}
}
return cb(err);
}
cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts));
}); });
} else {
// detachDescriptor passes the descriptor whereas discardDescriptor closes it, either way, we no longer care
// about the descriptor
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, false));
} }
/* istanbul ignore else */
if (opts.detachDescriptor) {
return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts));
}
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts));
}); });
}); });
} }
@@ -2013,7 +2254,7 @@ function file(options, callback) {
* @throws {Error} if cannot create a file * @throws {Error} if cannot create a file
*/ */
function fileSync(options) { function fileSync(options) {
var const
args = _parseArguments(options), args = _parseArguments(options),
opts = args[0]; opts = args[0];
@@ -2029,7 +2270,7 @@ function fileSync(options) {
return { return {
name: name, name: name,
fd: fd, fd: fd,
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts) removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, true)
}; };
} }
@@ -2040,7 +2281,7 @@ function fileSync(options) {
* @param {?dirCallback} callback * @param {?dirCallback} callback
*/ */
function dir(options, callback) { function dir(options, callback) {
var const
args = _parseArguments(options, callback), args = _parseArguments(options, callback),
opts = args[0], opts = args[0],
cb = args[1]; cb = args[1];
@@ -2055,7 +2296,7 @@ function dir(options, callback) {
/* istanbul ignore else */ /* istanbul ignore else */
if (err) return cb(err); if (err) return cb(err);
cb(null, name, _prepareTmpDirRemoveCallback(name, opts)); cb(null, name, _prepareTmpDirRemoveCallback(name, opts, false));
}); });
}); });
} }
@@ -2068,7 +2309,7 @@ function dir(options, callback) {
* @throws {Error} if it cannot create a directory * @throws {Error} if it cannot create a directory
*/ */
function dirSync(options) { function dirSync(options) {
var const
args = _parseArguments(options), args = _parseArguments(options),
opts = args[0]; opts = args[0];
@@ -2077,7 +2318,7 @@ function dirSync(options) {
return { return {
name: name, name: name,
removeCallback: _prepareTmpDirRemoveCallback(name, opts) removeCallback: _prepareTmpDirRemoveCallback(name, opts, true)
}; };
} }
@@ -2090,15 +2331,15 @@ function dirSync(options) {
*/ */
function _removeFileAsync(fdPath, next) { function _removeFileAsync(fdPath, next) {
const _handler = function (err) { const _handler = function (err) {
if (err && !isENOENT(err)) { if (err && !_isENOENT(err)) {
// reraise any unanticipated error // reraise any unanticipated error
return next(err); return next(err);
} }
next(); next();
} };
if (0 <= fdPath[0]) if (0 <= fdPath[0])
fs.close(fdPath[0], function (err) { fs.close(fdPath[0], function () {
fs.unlink(fdPath[1], _handler); fs.unlink(fdPath[1], _handler);
}); });
else fs.unlink(fdPath[1], _handler); else fs.unlink(fdPath[1], _handler);
@@ -2111,117 +2352,104 @@ function _removeFileAsync(fdPath, next) {
* @private * @private
*/ */
function _removeFileSync(fdPath) { function _removeFileSync(fdPath) {
let rethrownException = null;
try { try {
if (0 <= fdPath[0]) fs.closeSync(fdPath[0]); if (0 <= fdPath[0]) fs.closeSync(fdPath[0]);
} catch (e) { } catch (e) {
// reraise any unanticipated error // reraise any unanticipated error
if (!isEBADF(e) && !isENOENT(e)) throw e; if (!_isEBADF(e) && !_isENOENT(e)) throw e;
} finally { } finally {
try { try {
fs.unlinkSync(fdPath[1]); fs.unlinkSync(fdPath[1]);
} }
catch (e) { catch (e) {
// reraise any unanticipated error // reraise any unanticipated error
if (!isENOENT(e)) throw e; if (!_isENOENT(e)) rethrownException = e;
} }
} }
if (rethrownException !== null) {
throw rethrownException;
}
} }
/** /**
* Prepares the callback for removal of the temporary file. * Prepares the callback for removal of the temporary file.
* *
* Returns either a sync callback or a async callback depending on whether
* fileSync or file was called, which is expressed by the sync parameter.
*
* @param {string} name the path of the file * @param {string} name the path of the file
* @param {number} fd file descriptor * @param {number} fd file descriptor
* @param {Object} opts * @param {Object} opts
* @returns {fileCallback} * @param {boolean} sync
* @returns {fileCallback | fileCallbackSync}
* @private * @private
*/ */
function _prepareTmpFileRemoveCallback(name, fd, opts) { function _prepareTmpFileRemoveCallback(name, fd, opts, sync) {
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]); const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name], sync);
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync); const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], sync, removeCallbackSync);
if (!opts.keep) _removeObjects.unshift(removeCallbackSync); if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
return removeCallback; return sync ? removeCallbackSync : removeCallback;
}
/**
* Simple wrapper for rimraf.
*
* @param {string} dirPath
* @param {Function} next
* @private
*/
function _rimrafRemoveDirWrapper(dirPath, next) {
rimraf(dirPath, next);
}
/**
* Simple wrapper for rimraf.sync.
*
* @param {string} dirPath
* @private
*/
function _rimrafRemoveDirSyncWrapper(dirPath, next) {
try {
return next(null, rimraf.sync(dirPath));
} catch (err) {
return next(err);
}
} }
/** /**
* Prepares the callback for removal of the temporary directory. * Prepares the callback for removal of the temporary directory.
* *
* Returns either a sync callback or a async callback depending on whether
* tmpFileSync or tmpFile was called, which is expressed by the sync parameter.
*
* @param {string} name * @param {string} name
* @param {Object} opts * @param {Object} opts
* @param {boolean} sync
* @returns {Function} the callback * @returns {Function} the callback
* @private * @private
*/ */
function _prepareTmpDirRemoveCallback(name, opts) { function _prepareTmpDirRemoveCallback(name, opts, sync) {
const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs); const removeFunction = opts.unsafeCleanup ? rimraf : fs.rmdir.bind(fs);
const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs); const removeFunctionSync = opts.unsafeCleanup ? FN_RIMRAF_SYNC : FN_RMDIR_SYNC;
const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name); const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name, sync);
const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync); const removeCallback = _prepareRemoveCallback(removeFunction, name, sync, removeCallbackSync);
if (!opts.keep) _removeObjects.unshift(removeCallbackSync); if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
return removeCallback; return sync ? removeCallbackSync : removeCallback;
} }
/** /**
* Creates a guarded function wrapping the removeFunction call. * Creates a guarded function wrapping the removeFunction call.
* *
* The cleanup callback is save to be called multiple times.
* Subsequent invocations will be ignored.
*
* @param {Function} removeFunction * @param {Function} removeFunction
* @param {Object} arg * @param {string} fileOrDirName
* @returns {Function} * @param {boolean} sync
* @param {cleanupCallbackSync?} cleanupCallbackSync
* @returns {cleanupCallback | cleanupCallbackSync}
* @private * @private
*/ */
function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) { function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCallbackSync) {
var called = false; let called = false;
// if sync is true, the next parameter will be ignored
return function _cleanupCallback(next) { return function _cleanupCallback(next) {
next = next || function () {};
/* istanbul ignore else */
if (!called) { if (!called) {
// remove cleanupCallback from cache
const toRemove = cleanupCallbackSync || _cleanupCallback; const toRemove = cleanupCallbackSync || _cleanupCallback;
const index = _removeObjects.indexOf(toRemove); const index = _removeObjects.indexOf(toRemove);
/* istanbul ignore else */ /* istanbul ignore else */
if (index >= 0) _removeObjects.splice(index, 1); if (index >= 0) _removeObjects.splice(index, 1);
called = true; called = true;
// sync? if (sync || removeFunction === FN_RMDIR_SYNC || removeFunction === FN_RIMRAF_SYNC) {
if (removeFunction.length === 1) { return removeFunction(fileOrDirName);
try { } else {
removeFunction(arg); return removeFunction(fileOrDirName, next || function() {});
return next(null); }
} }
catch (err) {
// if no next is provided and since we are
// in silent cleanup mode on process exit,
// we will ignore the error
return next(err);
}
} else return removeFunction(arg, next);
} else return next(new Error('cleanup callback has already been called'));
}; };
} }
@@ -2246,41 +2474,30 @@ function _garbageCollector() {
} }
/** /**
* Helper for testing against EBADF to compensate changes made to Node 7.x under Windows. * Random name generator based on crypto.
* Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript
*
* @param {number} howMany
* @returns {string} the generated random name
* @private
*/ */
function isEBADF(error) { function _randomChars(howMany) {
return isExpectedError(error, -EBADF, 'EBADF'); let
} value = [],
rnd = null;
/** // make sure that we do not fail because we ran out of entropy
* Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows. try {
*/ rnd = crypto.randomBytes(howMany);
function isENOENT(error) { } catch (e) {
return isExpectedError(error, -ENOENT, 'ENOENT'); rnd = crypto.pseudoRandomBytes(howMany);
} }
/** for (var i = 0; i < howMany; i++) {
* Helper to determine whether the expected error code matches the actual code and errno, value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
* which will differ between the supported node versions. }
*
* - Node >= 7.0: return value.join('');
* error.code {string}
* error.errno {string|number} any numerical value will be negated
*
* - Node >= 6.0 < 7.0:
* error.code {string}
* error.errno {number} negated
*
* - Node >= 4.0 < 6.0: introduces SystemError
* error.code {string}
* error.errno {number} negated
*
* - Node >= 0.10 < 4.0:
* error.code {number} negated
* error.errno n/a
*/
function isExpectedError(error, code, errno) {
return error.code === code || error.code === errno;
} }
/** /**
@@ -2290,12 +2507,241 @@ function isExpectedError(error, code, errno) {
* @param {string} s * @param {string} s
* @returns {Boolean} true whether the string s is blank, false otherwise * @returns {Boolean} true whether the string s is blank, false otherwise
*/ */
function isBlank(s) { function _isBlank(s) {
return s === null || s === undefined || !s.trim(); return s === null || _isUndefined(s) || !s.trim();
}
/**
* Checks whether the `obj` parameter is defined or not.
*
* @param {Object} obj
* @returns {boolean} true if the object is undefined
* @private
*/
function _isUndefined(obj) {
return typeof obj === 'undefined';
}
/**
* Parses the function arguments.
*
* This function helps to have optional arguments.
*
* @param {(Options|null|undefined|Function)} options
* @param {?Function} callback
* @returns {Array} parsed arguments
* @private
*/
function _parseArguments(options, callback) {
/* istanbul ignore else */
if (typeof options === 'function') {
return [{}, options];
}
/* istanbul ignore else */
if (_isUndefined(options)) {
return [{}, callback];
}
// copy options so we do not leak the changes we make internally
const actualOptions = {};
for (const key of Object.getOwnPropertyNames(options)) {
actualOptions[key] = options[key];
}
return [actualOptions, callback];
}
/**
* Generates a new temporary name.
*
* @param {Object} opts
* @returns {string} the new random name according to opts
* @private
*/
function _generateTmpName(opts) {
const tmpDir = opts.tmpdir;
/* istanbul ignore else */
if (!_isUndefined(opts.name))
return path.join(tmpDir, opts.dir, opts.name);
/* istanbul ignore else */
if (!_isUndefined(opts.template))
return path.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6));
// prefix and postfix
const name = [
opts.prefix ? opts.prefix : 'tmp',
'-',
process.pid,
'-',
_randomChars(12),
opts.postfix ? '-' + opts.postfix : ''
].join('');
return path.join(tmpDir, opts.dir, name);
}
/**
* Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing
* options.
*
* @param {Options} options
* @private
*/
function _assertAndSanitizeOptions(options) {
options.tmpdir = _getTmpDir(options);
const tmpDir = options.tmpdir;
/* istanbul ignore else */
if (!_isUndefined(options.name))
_assertIsRelative(options.name, 'name', tmpDir);
/* istanbul ignore else */
if (!_isUndefined(options.dir))
_assertIsRelative(options.dir, 'dir', tmpDir);
/* istanbul ignore else */
if (!_isUndefined(options.template)) {
_assertIsRelative(options.template, 'template', tmpDir);
if (!options.template.match(TEMPLATE_PATTERN))
throw new Error(`Invalid template, found "${options.template}".`);
}
/* istanbul ignore else */
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
throw new Error(`Invalid tries, found "${options.tries}".`);
// if a name was specified we will try once
options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1;
options.keep = !!options.keep;
options.detachDescriptor = !!options.detachDescriptor;
options.discardDescriptor = !!options.discardDescriptor;
options.unsafeCleanup = !!options.unsafeCleanup;
// sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to
options.dir = _isUndefined(options.dir) ? '' : path.relative(tmpDir, _resolvePath(options.dir, tmpDir));
options.template = _isUndefined(options.template) ? undefined : path.relative(tmpDir, _resolvePath(options.template, tmpDir));
// sanitize further if template is relative to options.dir
options.template = _isBlank(options.template) ? undefined : path.relative(options.dir, options.template);
// for completeness' sake only, also keep (multiple) blanks if the user, purportedly sane, requests us to
options.name = _isUndefined(options.name) ? undefined : _sanitizeName(options.name);
options.prefix = _isUndefined(options.prefix) ? '' : options.prefix;
options.postfix = _isUndefined(options.postfix) ? '' : options.postfix;
}
/**
* Resolve the specified path name in respect to tmpDir.
*
* The specified name might include relative path components, e.g. ../
* so we need to resolve in order to be sure that is is located inside tmpDir
*
* @param name
* @param tmpDir
* @returns {string}
* @private
*/
function _resolvePath(name, tmpDir) {
const sanitizedName = _sanitizeName(name);
if (sanitizedName.startsWith(tmpDir)) {
return path.resolve(sanitizedName);
} else {
return path.resolve(path.join(tmpDir, sanitizedName));
}
}
/**
* Sanitize the specified path name by removing all quote characters.
*
* @param name
* @returns {string}
* @private
*/
function _sanitizeName(name) {
if (_isBlank(name)) {
return name;
}
return name.replace(/["']/g, '');
}
/**
* Asserts whether specified name is relative to the specified tmpDir.
*
* @param {string} name
* @param {string} option
* @param {string} tmpDir
* @throws {Error}
* @private
*/
function _assertIsRelative(name, option, tmpDir) {
if (option === 'name') {
// assert that name is not absolute and does not contain a path
if (path.isAbsolute(name))
throw new Error(`${option} option must not contain an absolute path, found "${name}".`);
// must not fail on valid .<name> or ..<name> or similar such constructs
let basename = path.basename(name);
if (basename === '..' || basename === '.' || basename !== name)
throw new Error(`${option} option must not contain a path, found "${name}".`);
}
else { // if (option === 'dir' || option === 'template') {
// assert that dir or template are relative to tmpDir
if (path.isAbsolute(name) && !name.startsWith(tmpDir)) {
throw new Error(`${option} option must be relative to "${tmpDir}", found "${name}".`);
}
let resolvedPath = _resolvePath(name, tmpDir);
if (!resolvedPath.startsWith(tmpDir))
throw new Error(`${option} option must be relative to "${tmpDir}", found "${resolvedPath}".`);
}
}
/**
* Helper for testing against EBADF to compensate changes made to Node 7.x under Windows.
*
* @private
*/
function _isEBADF(error) {
return _isExpectedError(error, -EBADF, 'EBADF');
}
/**
* Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows.
*
* @private
*/
function _isENOENT(error) {
return _isExpectedError(error, -ENOENT, 'ENOENT');
}
/**
* Helper to determine whether the expected error code matches the actual code and errno,
* which will differ between the supported node versions.
*
* - Node >= 7.0:
* error.code {string}
* error.errno {number} any numerical value will be negated
*
* CAVEAT
*
* On windows, the errno for EBADF is -4083 but os.constants.errno.EBADF is different and we must assume that ENOENT
* is no different here.
*
* @param {SystemError} error
* @param {number} errno
* @param {string} code
* @private
*/
function _isExpectedError(error, errno, code) {
return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno;
} }
/** /**
* Sets the graceful cleanup. * Sets the graceful cleanup.
*
* If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit, otherwise the
* temporary objects will remain in place, waiting to be cleaned up on system restart or otherwise scheduled temporary
* object removals.
*/ */
function setGracefulCleanup() { function setGracefulCleanup() {
_gracefulCleanup = true; _gracefulCleanup = true;
@@ -2305,120 +2751,38 @@ function setGracefulCleanup() {
* Returns the currently configured tmp dir from os.tmpdir(). * Returns the currently configured tmp dir from os.tmpdir().
* *
* @private * @private
* @param {?Options} options
* @returns {string} the currently configured tmp dir * @returns {string} the currently configured tmp dir
*/ */
function _getTmpDir() { function _getTmpDir(options) {
return os.tmpdir(); return path.resolve(_sanitizeName(options && options.tmpdir || os.tmpdir()));
} }
/** // Install process exit listener
* If there are multiple different versions of tmp in place, make sure that process.addListener(EXIT, _garbageCollector);
* we recognize the old listeners.
*
* @param {Function} listener
* @private
* @returns {Boolean} true whether listener is a legacy listener
*/
function _is_legacy_listener(listener) {
return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown')
&& listener.toString().indexOf('_garbageCollector();') > -1;
}
/**
* Safely install SIGINT listener.
*
* NOTE: this will only work on OSX and Linux.
*
* @private
*/
function _safely_install_sigint_listener() {
const listeners = process.listeners(SIGINT);
const existingListeners = [];
for (let i = 0, length = listeners.length; i < length; i++) {
const lstnr = listeners[i];
/* istanbul ignore else */
if (lstnr.name === '_tmp$sigint_listener') {
existingListeners.push(lstnr);
process.removeListener(SIGINT, lstnr);
}
}
process.on(SIGINT, function _tmp$sigint_listener(doExit) {
for (let i = 0, length = existingListeners.length; i < length; i++) {
// let the existing listener do the garbage collection (e.g. jest sandbox)
try {
existingListeners[i](false);
} catch (err) {
// ignore
}
}
try {
// force the garbage collector even it is called again in the exit listener
_garbageCollector();
} finally {
if (!!doExit) {
process.exit(0);
}
}
});
}
/**
* Safely install process exit listener.
*
* @private
*/
function _safely_install_exit_listener() {
const listeners = process.listeners(EXIT);
// collect any existing listeners
const existingListeners = [];
for (let i = 0, length = listeners.length; i < length; i++) {
const lstnr = listeners[i];
/* istanbul ignore else */
// TODO: remove support for legacy listeners once release 1.0.0 is out
if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) {
// we must forget about the uncaughtException listener, hopefully it is ours
if (lstnr.name !== '_uncaughtExceptionThrown') {
existingListeners.push(lstnr);
}
process.removeListener(EXIT, lstnr);
}
}
// TODO: what was the data parameter good for?
process.addListener(EXIT, function _tmp$safe_listener(data) {
for (let i = 0, length = existingListeners.length; i < length; i++) {
// let the existing listener do the garbage collection (e.g. jest sandbox)
try {
existingListeners[i](data);
} catch (err) {
// ignore
}
}
_garbageCollector();
});
}
_safely_install_exit_listener();
_safely_install_sigint_listener();
/** /**
* Configuration options. * Configuration options.
* *
* @typedef {Object} Options * @typedef {Object} Options
* @property {?boolean} keep the temporary object (file or dir) will not be garbage collected
* @property {?number} tries the number of tries before give up the name generation * @property {?number} tries the number of tries before give up the name generation
* @property (?int) mode the access mode, defaults are 0o700 for directories and 0o600 for files
* @property {?string} template the "mkstemp" like filename template * @property {?string} template the "mkstemp" like filename template
* @property {?string} name fix name * @property {?string} name fixed name relative to tmpdir or the specified dir option
* @property {?string} dir the tmp directory to use * @property {?string} dir tmp directory relative to the root tmp directory in use
* @property {?string} prefix prefix for the generated name * @property {?string} prefix prefix for the generated name
* @property {?string} postfix postfix for the generated name * @property {?string} postfix postfix for the generated name
* @property {?string} tmpdir the root tmp directory which overrides the os tmpdir
* @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty * @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty
* @property {?boolean} detachDescriptor detaches the file descriptor, caller is responsible for closing the file, tmp will no longer try closing the file during garbage collection
* @property {?boolean} discardDescriptor discards the file descriptor (closes file, fd is -1), tmp will no longer try closing the file during garbage collection
*/ */
/** /**
* @typedef {Object} FileSyncObject * @typedef {Object} FileSyncObject
* @property {string} name the name of the file * @property {string} name the name of the file
* @property {string} fd the file descriptor * @property {string} fd the file descriptor or -1 if the fd has been discarded
* @property {fileCallback} removeCallback the callback function to remove the file * @property {fileCallback} removeCallback the callback function to remove the file
*/ */
@@ -2438,10 +2802,18 @@ _safely_install_sigint_listener();
* @callback fileCallback * @callback fileCallback
* @param {?Error} err the error object if anything goes wrong * @param {?Error} err the error object if anything goes wrong
* @param {string} name the temporary file name * @param {string} name the temporary file name
* @param {number} fd the file descriptor * @param {number} fd the file descriptor or -1 if the fd had been discarded
* @param {cleanupCallback} fn the cleanup callback function * @param {cleanupCallback} fn the cleanup callback function
*/ */
/**
* @callback fileCallbackSync
* @param {?Error} err the error object if anything goes wrong
* @param {string} name the temporary file name
* @param {number} fd the file descriptor or -1 if the fd had been discarded
* @param {cleanupCallbackSync} fn the cleanup callback function
*/
/** /**
* @callback dirCallback * @callback dirCallback
* @param {?Error} err the error object if anything goes wrong * @param {?Error} err the error object if anything goes wrong
@@ -2449,11 +2821,24 @@ _safely_install_sigint_listener();
* @param {cleanupCallback} fn the cleanup callback function * @param {cleanupCallback} fn the cleanup callback function
*/ */
/**
* @callback dirCallbackSync
* @param {?Error} err the error object if anything goes wrong
* @param {string} name the temporary file name
* @param {cleanupCallbackSync} fn the cleanup callback function
*/
/** /**
* Removes the temporary created file or directory. * Removes the temporary created file or directory.
* *
* @callback cleanupCallback * @callback cleanupCallback
* @param {simpleCallback} [next] function to call after entry was removed * @param {simpleCallback} [next] function to call whenever the tmp object needs to be removed
*/
/**
* Removes the temporary created file or directory.
*
* @callback cleanupCallbackSync
*/ */
/** /**
@@ -2465,7 +2850,7 @@ _safely_install_sigint_listener();
// exporting all the needed methods // exporting all the needed methods
// evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will // evaluate _getTmpDir() lazily, mainly for simplifying testing but it also will
// allow users to reconfigure the temporary directory // allow users to reconfigure the temporary directory
Object.defineProperty(module.exports, 'tmpdir', { Object.defineProperty(module.exports, 'tmpdir', {
enumerable: true, enumerable: true,
@@ -2509,11 +2894,11 @@ class StatusReporter {
this.processedCount = 0; this.processedCount = 0;
this.largeFiles = new Map(); this.largeFiles = new Map();
this.totalFileStatus = undefined; this.totalFileStatus = undefined;
this.largeFileStatus = undefined;
this.displayFrequencyInMilliseconds = displayFrequencyInMilliseconds; this.displayFrequencyInMilliseconds = displayFrequencyInMilliseconds;
} }
setTotalNumberOfFilesToProcess(fileTotal) { setTotalNumberOfFilesToProcess(fileTotal) {
this.totalNumberOfFilesToProcess = fileTotal; this.totalNumberOfFilesToProcess = fileTotal;
this.processedCount = 0;
} }
start() { start() {
// displays information about the total upload/download status // displays information about the total upload/download status
@@ -2522,30 +2907,17 @@ class StatusReporter {
const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess); const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess);
core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`); core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`);
}, this.displayFrequencyInMilliseconds); }, this.displayFrequencyInMilliseconds);
// displays extra information about any large files that take a significant amount of time to upload or download every 1 second
this.largeFileStatus = setInterval(() => {
for (const value of Array.from(this.largeFiles.values())) {
core_1.info(value);
}
// delete all entries in the map after displaying the information so it will not be displayed again unless explicitly added
this.largeFiles.clear();
}, 1000);
} }
// if there is a large file that is being uploaded in chunks, this is used to display extra information about the status of the upload // if there is a large file that is being uploaded in chunks, this is used to display extra information about the status of the upload
updateLargeFileStatus(fileName, numerator, denominator) { updateLargeFileStatus(fileName, chunkStartIndex, chunkEndIndex, totalUploadFileSize) {
// display 1 decimal place without any rounding // display 1 decimal place without any rounding
const percentage = this.formatPercentage(numerator, denominator); const percentage = this.formatPercentage(chunkEndIndex, totalUploadFileSize);
const displayInformation = `Uploading ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`; core_1.info(`Uploaded ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%) bytes ${chunkStartIndex}:${chunkEndIndex}`);
// any previously added display information should be overwritten for the specific large file because a map is being used
this.largeFiles.set(fileName, displayInformation);
} }
stop() { stop() {
if (this.totalFileStatus) { if (this.totalFileStatus) {
clearInterval(this.totalFileStatus); clearInterval(this.totalFileStatus);
} }
if (this.largeFileStatus) {
clearInterval(this.largeFileStatus);
}
} }
incrementProcessedCount() { incrementProcessedCount() {
this.processedCount++; this.processedCount++;
@@ -3770,6 +4142,7 @@ const core = __importStar(__webpack_require__(470));
const upload_specification_1 = __webpack_require__(590); const upload_specification_1 = __webpack_require__(590);
const upload_http_client_1 = __webpack_require__(608); const upload_http_client_1 = __webpack_require__(608);
const utils_1 = __webpack_require__(870); const utils_1 = __webpack_require__(870);
const path_and_artifact_name_validation_1 = __webpack_require__(553);
const download_http_client_1 = __webpack_require__(855); const download_http_client_1 = __webpack_require__(855);
const download_specification_1 = __webpack_require__(532); const download_specification_1 = __webpack_require__(532);
const config_variables_1 = __webpack_require__(401); const config_variables_1 = __webpack_require__(401);
@@ -3786,7 +4159,9 @@ class DefaultArtifactClient {
*/ */
uploadArtifact(name, files, rootDirectory, options) { uploadArtifact(name, files, rootDirectory, options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
utils_1.checkArtifactName(name); core.info(`Starting artifact upload
For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`);
path_and_artifact_name_validation_1.checkArtifactName(name);
// Get specification for the files being uploaded // Get specification for the files being uploaded
const uploadSpecification = upload_specification_1.getUploadSpecification(name, rootDirectory, files); const uploadSpecification = upload_specification_1.getUploadSpecification(name, rootDirectory, files);
const uploadResponse = { const uploadResponse = {
@@ -3807,12 +4182,24 @@ class DefaultArtifactClient {
throw new Error('No URL provided by the Artifact Service to upload an artifact to'); throw new Error('No URL provided by the Artifact Service to upload an artifact to');
} }
core.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); core.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`);
core.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`);
// Upload each of the files that were found concurrently // Upload each of the files that were found concurrently
const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options); const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options);
// Update the size of the artifact to indicate we are done uploading // Update the size of the artifact to indicate we are done uploading
// The uncompressed size is used for display when downloading a zip of the artifact from the UI // The uncompressed size is used for display when downloading a zip of the artifact from the UI
core.info(`File upload process has finished. Finalizing the artifact upload`);
yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name); yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name);
core.info(`Finished uploading artifact ${name}. Reported size is ${uploadResult.uploadSize} bytes. There were ${uploadResult.failedItems.length} items that failed to upload`); if (uploadResult.failedItems.length > 0) {
core.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`);
}
else {
core.info(`Artifact has been finalized. All files have been successfully uploaded!`);
}
core.info(`
The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes
The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage
Note: The size of downloaded zips can differ significantly from the reported size. For more information see: https://github.com/actions/upload-artifact#zipped-artifact-downloads \r\n`);
uploadResponse.artifactItems = uploadSpecification.map(item => item.absoluteFilePath); uploadResponse.artifactItems = uploadSpecification.map(item => item.absoluteFilePath);
uploadResponse.size = uploadResult.uploadSize; uploadResponse.size = uploadResult.uploadSize;
uploadResponse.failedItems = uploadResult.failedItems; uploadResponse.failedItems = uploadResult.failedItems;
@@ -3875,6 +4262,7 @@ class DefaultArtifactClient {
while (downloadedArtifacts < artifacts.count) { while (downloadedArtifacts < artifacts.count) {
const currentArtifactToDownload = artifacts.value[downloadedArtifacts]; const currentArtifactToDownload = artifacts.value[downloadedArtifacts];
downloadedArtifacts += 1; downloadedArtifacts += 1;
core.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`);
// Get container entries for the specific artifact // Get container entries for the specific artifact
const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl); const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl);
const downloadSpecification = download_specification_1.getDownloadSpecification(currentArtifactToDownload.name, items.value, path, true); const downloadSpecification = download_specification_1.getDownloadSpecification(currentArtifactToDownload.name, items.value, path, true);
@@ -4955,10 +5343,9 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
/***/ }), /***/ }),
/***/ 413: /***/ 413:
/***/ (function(module, __unusedexports, __webpack_require__) { /***/ (function(module) {
module.exports = __webpack_require__(141);
module.exports = require("stream");
/***/ }), /***/ }),
@@ -5915,7 +6302,7 @@ class HttpClient {
if (useProxy) { if (useProxy) {
// If using proxy, need tunnel // If using proxy, need tunnel
if (!tunnel) { if (!tunnel) {
tunnel = __webpack_require__(413); tunnel = __webpack_require__(988);
} }
const agentOptions = { const agentOptions = {
maxSockets: maxSockets, maxSockets: maxSockets,
@@ -6033,374 +6420,76 @@ exports.HttpClient = HttpClient;
/***/ }), /***/ }),
/***/ 569: /***/ 553:
/***/ (function(module, __unusedexports, __webpack_require__) { /***/ (function(__unusedmodule, exports, __webpack_require__) {
module.exports = rimraf "use strict";
rimraf.sync = rimrafSync
var assert = __webpack_require__(357) Object.defineProperty(exports, "__esModule", { value: true });
var path = __webpack_require__(622) const core_1 = __webpack_require__(470);
var fs = __webpack_require__(747) /**
var glob = __webpack_require__(402) * Invalid characters that cannot be in the artifact name or an uploaded file. Will be rejected
var _0666 = parseInt('666', 8) * from the server if attempted to be sent over. These characters are not allowed due to limitations with certain
* file systems such as NTFS. To maintain platform-agnostic behavior, all characters that are not supported by an
var defaultGlobOpts = { * individual filesystem/platform will not be supported on all fileSystems/platforms
nosort: true, *
silent: true * FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
} */
const invalidArtifactFilePathCharacters = new Map([
// for EMFILE handling ['"', ' Double quote "'],
var timeout = 0 [':', ' Colon :'],
['<', ' Less than <'],
var isWindows = (process.platform === "win32") ['>', ' Greater than >'],
['|', ' Vertical bar |'],
function defaults (options) { ['*', ' Asterisk *'],
var methods = [ ['?', ' Question mark ?'],
'unlink', ['\r', ' Carriage return \\r'],
'chmod', ['\n', ' Line feed \\n']
'stat', ]);
'lstat', const invalidArtifactNameCharacters = new Map([
'rmdir', ...invalidArtifactFilePathCharacters,
'readdir' ['\\', ' Backslash \\'],
] ['/', ' Forward slash /']
methods.forEach(function(m) { ]);
options[m] = options[m] || fs[m] /**
m = m + 'Sync' * Scans the name of the artifact to make sure there are no illegal characters
options[m] = options[m] || fs[m] */
}) function checkArtifactName(name) {
if (!name) {
options.maxBusyTries = options.maxBusyTries || 3 throw new Error(`Artifact name: ${name}, is incorrectly provided`);
options.emfileWait = options.emfileWait || 1000 }
if (options.glob === false) { for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactNameCharacters) {
options.disableGlob = true if (name.includes(invalidCharacterKey)) {
} throw new Error(`Artifact name is not valid: ${name}. Contains the following character: ${errorMessageForCharacter}
options.disableGlob = options.disableGlob || false
options.glob = options.glob || defaultGlobOpts Invalid characters include: ${Array.from(invalidArtifactNameCharacters.values()).toString()}
}
These characters are not allowed in the artifact name due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.`);
function rimraf (p, options, cb) {
if (typeof options === 'function') {
cb = options
options = {}
}
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
assert(options, 'rimraf: invalid options argument provided')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
defaults(options)
var busyTries = 0
var errState = null
var n = 0
if (options.disableGlob || !glob.hasMagic(p))
return afterGlob(null, [p])
options.lstat(p, function (er, stat) {
if (!er)
return afterGlob(null, [p])
glob(p, options.glob, afterGlob)
})
function next (er) {
errState = errState || er
if (--n === 0)
cb(errState)
}
function afterGlob (er, results) {
if (er)
return cb(er)
n = results.length
if (n === 0)
return cb()
results.forEach(function (p) {
rimraf_(p, options, function CB (er) {
if (er) {
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
busyTries < options.maxBusyTries) {
busyTries ++
var time = busyTries * 100
// try again, with the same exact callback as this one.
return setTimeout(function () {
rimraf_(p, options, CB)
}, time)
}
// this one won't happen if graceful-fs is used.
if (er.code === "EMFILE" && timeout < options.emfileWait) {
return setTimeout(function () {
rimraf_(p, options, CB)
}, timeout ++)
}
// already gone
if (er.code === "ENOENT") er = null
} }
timeout = 0
next(er)
})
})
}
}
// Two possible strategies.
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
//
// Both result in an extra syscall when you guess wrong. However, there
// are likely far more normal files in the world than directories. This
// is based on the assumption that a the average number of files per
// directory is >= 1.
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow. But until then, YAGNI.
function rimraf_ (p, options, cb) {
assert(p)
assert(options)
assert(typeof cb === 'function')
// sunos lets the root user unlink directories, which is... weird.
// so we have to lstat here and make sure it's not a dir.
options.lstat(p, function (er, st) {
if (er && er.code === "ENOENT")
return cb(null)
// Windows can EPERM on stat. Life is suffering.
if (er && er.code === "EPERM" && isWindows)
fixWinEPERM(p, options, er, cb)
if (st && st.isDirectory())
return rmdir(p, options, er, cb)
options.unlink(p, function (er) {
if (er) {
if (er.code === "ENOENT")
return cb(null)
if (er.code === "EPERM")
return (isWindows)
? fixWinEPERM(p, options, er, cb)
: rmdir(p, options, er, cb)
if (er.code === "EISDIR")
return rmdir(p, options, er, cb)
}
return cb(er)
})
})
}
function fixWinEPERM (p, options, er, cb) {
assert(p)
assert(options)
assert(typeof cb === 'function')
if (er)
assert(er instanceof Error)
options.chmod(p, _0666, function (er2) {
if (er2)
cb(er2.code === "ENOENT" ? null : er)
else
options.stat(p, function(er3, stats) {
if (er3)
cb(er3.code === "ENOENT" ? null : er)
else if (stats.isDirectory())
rmdir(p, options, er, cb)
else
options.unlink(p, cb)
})
})
}
function fixWinEPERMSync (p, options, er) {
assert(p)
assert(options)
if (er)
assert(er instanceof Error)
try {
options.chmodSync(p, _0666)
} catch (er2) {
if (er2.code === "ENOENT")
return
else
throw er
}
try {
var stats = options.statSync(p)
} catch (er3) {
if (er3.code === "ENOENT")
return
else
throw er
}
if (stats.isDirectory())
rmdirSync(p, options, er)
else
options.unlinkSync(p)
}
function rmdir (p, options, originalEr, cb) {
assert(p)
assert(options)
if (originalEr)
assert(originalEr instanceof Error)
assert(typeof cb === 'function')
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
// if we guessed wrong, and it's not a directory, then
// raise the original error.
options.rmdir(p, function (er) {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
rmkids(p, options, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)
else
cb(er)
})
}
function rmkids(p, options, cb) {
assert(p)
assert(options)
assert(typeof cb === 'function')
options.readdir(p, function (er, files) {
if (er)
return cb(er)
var n = files.length
if (n === 0)
return options.rmdir(p, cb)
var errState
files.forEach(function (f) {
rimraf(path.join(p, f), options, function (er) {
if (errState)
return
if (er)
return cb(errState = er)
if (--n === 0)
options.rmdir(p, cb)
})
})
})
}
// this looks simpler, and is strictly *faster*, but will
// tie up the JavaScript thread and fail on excessively
// deep directory trees.
function rimrafSync (p, options) {
options = options || {}
defaults(options)
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert(options, 'rimraf: missing options')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
var results
if (options.disableGlob || !glob.hasMagic(p)) {
results = [p]
} else {
try {
options.lstatSync(p)
results = [p]
} catch (er) {
results = glob.sync(p, options.glob)
} }
} core_1.info(`Artifact name is valid!`);
if (!results.length)
return
for (var i = 0; i < results.length; i++) {
var p = results[i]
try {
var st = options.lstatSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
// Windows can EPERM on stat. Life is suffering.
if (er.code === "EPERM" && isWindows)
fixWinEPERMSync(p, options, er)
}
try {
// sunos lets the root user unlink directories, which is... weird.
if (st && st.isDirectory())
rmdirSync(p, options, null)
else
options.unlinkSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
if (er.code === "EPERM")
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
if (er.code !== "EISDIR")
throw er
rmdirSync(p, options, er)
}
}
} }
exports.checkArtifactName = checkArtifactName;
function rmdirSync (p, options, originalEr) { /**
assert(p) * Scans the name of the filePath used to make sure there are no illegal characters
assert(options) */
if (originalEr) function checkArtifactFilePath(path) {
assert(originalEr instanceof Error) if (!path) {
throw new Error(`Artifact path: ${path}, is incorrectly provided`);
try { }
options.rmdirSync(p) for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactFilePathCharacters) {
} catch (er) { if (path.includes(invalidCharacterKey)) {
if (er.code === "ENOENT") throw new Error(`Artifact path is not valid: ${path}. Contains the following character: ${errorMessageForCharacter}
return
if (er.code === "ENOTDIR") Invalid characters include: ${Array.from(invalidArtifactFilePathCharacters.values()).toString()}
throw originalEr
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") The following characters are not allowed in files that are uploaded due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.
rmkidsSync(p, options) `);
} }
}
function rmkidsSync (p, options) {
assert(p)
assert(options)
options.readdirSync(p).forEach(function (f) {
rimrafSync(path.join(p, f), options)
})
// We only end up here once we got ENOTEMPTY at least once, and
// at this point, we are guaranteed to have removed all the kids.
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
var retries = isWindows ? 100 : 1
var i = 0
do {
var threw = true
try {
var ret = options.rmdirSync(p, options)
threw = false
return ret
} finally {
if (++i < retries && threw)
continue
} }
} while (true)
} }
exports.checkArtifactFilePath = checkArtifactFilePath;
//# sourceMappingURL=path-and-artifact-name-validation.js.map
/***/ }), /***/ }),
@@ -6616,7 +6705,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const core_1 = __webpack_require__(470); const core_1 = __webpack_require__(470);
const path_1 = __webpack_require__(622); const path_1 = __webpack_require__(622);
const utils_1 = __webpack_require__(870); const path_and_artifact_name_validation_1 = __webpack_require__(553);
/** /**
* Creates a specification that describes how each file that is part of the artifact will be uploaded * Creates a specification that describes how each file that is part of the artifact will be uploaded
* @param artifactName the name of the artifact being uploaded. Used during upload to denote where the artifact is stored on the server * @param artifactName the name of the artifact being uploaded. Used during upload to denote where the artifact is stored on the server
@@ -6624,7 +6713,7 @@ const utils_1 = __webpack_require__(870);
* @param artifactFiles a list of absolute file paths that denote what should be uploaded as part of the artifact * @param artifactFiles a list of absolute file paths that denote what should be uploaded as part of the artifact
*/ */
function getUploadSpecification(artifactName, rootDirectory, artifactFiles) { function getUploadSpecification(artifactName, rootDirectory, artifactFiles) {
utils_1.checkArtifactName(artifactName); // artifact name was checked earlier on, no need to check again
const specifications = []; const specifications = [];
if (!fs.existsSync(rootDirectory)) { if (!fs.existsSync(rootDirectory)) {
throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`); throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`);
@@ -6667,7 +6756,7 @@ function getUploadSpecification(artifactName, rootDirectory, artifactFiles) {
} }
// Check for forbidden characters in file paths that will be rejected during upload // Check for forbidden characters in file paths that will be rejected during upload
const uploadPath = file.replace(rootDirectory, ''); const uploadPath = file.replace(rootDirectory, '');
utils_1.checkArtifactFilePath(uploadPath); path_and_artifact_name_validation_1.checkArtifactFilePath(uploadPath);
/* /*
uploadFilePath denotes where the file will be uploaded in the file container on the server. During a run, if multiple artifacts are uploaded, they will all uploadFilePath denotes where the file will be uploaded in the file container on the server. During a run, if multiple artifacts are uploaded, they will all
be saved in the same container. The artifact name is used as the root directory in the container to separate and distinguish uploaded artifacts be saved in the same container. The artifact name is used as the root directory in the container to separate and distinguish uploaded artifacts
@@ -6845,7 +6934,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tmp = __importStar(__webpack_require__(875)); const tmp = __importStar(__webpack_require__(875));
const stream = __importStar(__webpack_require__(794)); const stream = __importStar(__webpack_require__(413));
const utils_1 = __webpack_require__(870); const utils_1 = __webpack_require__(870);
const config_variables_1 = __webpack_require__(401); const config_variables_1 = __webpack_require__(401);
const util_1 = __webpack_require__(669); const util_1 = __webpack_require__(669);
@@ -6987,27 +7076,33 @@ class UploadHttpClient {
*/ */
uploadFileAsync(httpClientIndex, parameters) { uploadFileAsync(httpClientIndex, parameters) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const totalFileSize = (yield stat(parameters.file)).size; const fileStat = yield stat(parameters.file);
const totalFileSize = fileStat.size;
const isFIFO = fileStat.isFIFO();
let offset = 0; let offset = 0;
let isUploadSuccessful = true; let isUploadSuccessful = true;
let failedChunkSizes = 0; let failedChunkSizes = 0;
let uploadFileSize = 0; let uploadFileSize = 0;
let isGzip = true; let isGzip = true;
// the file that is being uploaded is less than 64k in size, to increase throughput and to minimize disk I/O // the file that is being uploaded is less than 64k in size to increase throughput and to minimize disk I/O
// for creating a new GZip file, an in-memory buffer is used for compression // for creating a new GZip file, an in-memory buffer is used for compression
if (totalFileSize < 65536) { // with named pipes the file size is reported as zero in that case don't read the file in memory
if (!isFIFO && totalFileSize < 65536) {
core.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`);
const buffer = yield upload_gzip_1.createGZipFileInBuffer(parameters.file); const buffer = yield upload_gzip_1.createGZipFileInBuffer(parameters.file);
//An open stream is needed in the event of a failure and we need to retry. If a NodeJS.ReadableStream is directly passed in, // An open stream is needed in the event of a failure and we need to retry. If a NodeJS.ReadableStream is directly passed in,
// it will not properly get reset to the start of the stream if a chunk upload needs to be retried // it will not properly get reset to the start of the stream if a chunk upload needs to be retried
let openUploadStream; let openUploadStream;
if (totalFileSize < buffer.byteLength) { if (totalFileSize < buffer.byteLength) {
// compression did not help with reducing the size, use a readable stream from the original file for upload // compression did not help with reducing the size, use a readable stream from the original file for upload
core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
openUploadStream = () => fs.createReadStream(parameters.file); openUploadStream = () => fs.createReadStream(parameters.file);
isGzip = false; isGzip = false;
uploadFileSize = totalFileSize; uploadFileSize = totalFileSize;
} }
else { else {
// create a readable stream using a PassThrough stream that is both readable and writable // create a readable stream using a PassThrough stream that is both readable and writable
core.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`);
openUploadStream = () => { openUploadStream = () => {
const passThrough = new stream.PassThrough(); const passThrough = new stream.PassThrough();
passThrough.end(buffer); passThrough.end(buffer);
@@ -7032,25 +7127,27 @@ class UploadHttpClient {
// the file that is being uploaded is greater than 64k in size, a temporary file gets created on disk using the // the file that is being uploaded is greater than 64k in size, a temporary file gets created on disk using the
// npm tmp-promise package and this file gets used to create a GZipped file // npm tmp-promise package and this file gets used to create a GZipped file
const tempFile = yield tmp.file(); const tempFile = yield tmp.file();
core.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`);
// create a GZip file of the original file being uploaded, the original file should not be modified in any way // create a GZip file of the original file being uploaded, the original file should not be modified in any way
uploadFileSize = yield upload_gzip_1.createGZipFileOnDisk(parameters.file, tempFile.path); uploadFileSize = yield upload_gzip_1.createGZipFileOnDisk(parameters.file, tempFile.path);
let uploadFilePath = tempFile.path; let uploadFilePath = tempFile.path;
// compression did not help with size reduction, use the original file for upload and delete the temp GZip file // compression did not help with size reduction, use the original file for upload and delete the temp GZip file
if (totalFileSize < uploadFileSize) { // for named pipes totalFileSize is zero, this assumes compression did help
if (!isFIFO && totalFileSize < uploadFileSize) {
core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
uploadFileSize = totalFileSize; uploadFileSize = totalFileSize;
uploadFilePath = parameters.file; uploadFilePath = parameters.file;
isGzip = false; isGzip = false;
} }
else {
core.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`);
}
let abortFileUpload = false; let abortFileUpload = false;
// upload only a single chunk at a time // upload only a single chunk at a time
while (offset < uploadFileSize) { while (offset < uploadFileSize) {
const chunkSize = Math.min(uploadFileSize - offset, parameters.maxChunkSize); const chunkSize = Math.min(uploadFileSize - offset, parameters.maxChunkSize);
// if an individual file is greater than 100MB (1024*1024*100) in size, display extra information about the upload status const startChunkIndex = offset;
if (uploadFileSize > 104857600) { const endChunkIndex = offset + chunkSize - 1;
this.statusReporter.updateLargeFileStatus(parameters.file, offset, uploadFileSize);
}
const start = offset;
const end = offset + chunkSize - 1;
offset += parameters.maxChunkSize; offset += parameters.maxChunkSize;
if (abortFileUpload) { if (abortFileUpload) {
// if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed // if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed
@@ -7058,10 +7155,10 @@ class UploadHttpClient {
continue; continue;
} }
const result = yield this.uploadChunk(httpClientIndex, parameters.resourceUrl, () => fs.createReadStream(uploadFilePath, { const result = yield this.uploadChunk(httpClientIndex, parameters.resourceUrl, () => fs.createReadStream(uploadFilePath, {
start, start: startChunkIndex,
end, end: endChunkIndex,
autoClose: false autoClose: false
}), start, end, uploadFileSize, isGzip, totalFileSize); }), startChunkIndex, endChunkIndex, uploadFileSize, isGzip, totalFileSize);
if (!result) { if (!result) {
// Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was // Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was
// successfully uploaded so the server may report a different size for what was uploaded // successfully uploaded so the server may report a different size for what was uploaded
@@ -7070,9 +7167,16 @@ class UploadHttpClient {
core.warning(`Aborting upload for ${parameters.file} due to failure`); core.warning(`Aborting upload for ${parameters.file} due to failure`);
abortFileUpload = true; abortFileUpload = true;
} }
else {
// if an individual file is greater than 8MB (1024*1024*8) in size, display extra information about the upload status
if (uploadFileSize > 8388608) {
this.statusReporter.updateLargeFileStatus(parameters.file, startChunkIndex, endChunkIndex, uploadFileSize);
}
}
} }
// Delete the temporary file that was created as part of the upload. If the temp file does not get manually deleted by // Delete the temporary file that was created as part of the upload. If the temp file does not get manually deleted by
// calling cleanup, it gets removed when the node process exits. For more info see: https://www.npmjs.com/package/tmp-promise#about // calling cleanup, it gets removed when the node process exits. For more info see: https://www.npmjs.com/package/tmp-promise#about
core.debug(`deleting temporary gzip file ${tempFile.path}`);
yield tempFile.cleanup(); yield tempFile.cleanup();
return { return {
isSuccess: isUploadSuccessful, isSuccess: isUploadSuccessful,
@@ -7334,6 +7438,19 @@ const fs = __importStar(__webpack_require__(747));
const zlib = __importStar(__webpack_require__(761)); const zlib = __importStar(__webpack_require__(761));
const util_1 = __webpack_require__(669); const util_1 = __webpack_require__(669);
const stat = util_1.promisify(fs.stat); const stat = util_1.promisify(fs.stat);
/**
* GZipping certain files that are already compressed will likely not yield further size reductions. Creating large temporary gzip
* files then will just waste a lot of time before ultimately being discarded (especially for very large files).
* If any of these types of files are encountered then on-disk gzip creation will be skipped and the original file will be uploaded as-is
*/
const gzipExemptFileExtensions = [
'.gzip',
'.zip',
'.tar.lz',
'.tar.gz',
'.tar.bz2',
'.7z'
];
/** /**
* Creates a Gzip compressed file of an original file at the provided temporary filepath location * Creates a Gzip compressed file of an original file at the provided temporary filepath location
* @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified * @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified
@@ -7342,6 +7459,12 @@ const stat = util_1.promisify(fs.stat);
*/ */
function createGZipFileOnDisk(originalFilePath, tempFilePath) { function createGZipFileOnDisk(originalFilePath, tempFilePath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
for (const gzipExemptExtension of gzipExemptFileExtensions) {
if (originalFilePath.endsWith(gzipExemptExtension)) {
// return a really large number so that the original file gets uploaded
return Number.MAX_SAFE_INTEGER;
}
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const inputStream = fs.createReadStream(originalFilePath); const inputStream = fs.createReadStream(originalFilePath);
const gzip = zlib.createGzip(); const gzip = zlib.createGzip();
@@ -7572,13 +7695,6 @@ module.exports = require("zlib");
/***/ }), /***/ }),
/***/ 794:
/***/ (function(module) {
module.exports = require("stream");
/***/ }),
/***/ 835: /***/ 835:
/***/ (function(module) { /***/ (function(module) {
@@ -7759,9 +7875,6 @@ class DownloadHttpClient {
let response; let response;
try { try {
response = yield makeDownloadRequest(); response = yield makeDownloadRequest();
if (core.isDebug()) {
utils_1.displayHttpDiagnostics(response);
}
} }
catch (error) { catch (error) {
// if an error is caught, it is usually indicative of a timeout so retry the download // if an error is caught, it is usually indicative of a timeout so retry the download
@@ -8149,7 +8262,7 @@ function getExponentialRetryTimeInMilliseconds(retryCount) {
const minTime = config_variables_1.getInitialRetryIntervalInMilliseconds() * config_variables_1.getRetryMultiplier() * retryCount; const minTime = config_variables_1.getInitialRetryIntervalInMilliseconds() * config_variables_1.getRetryMultiplier() * retryCount;
const maxTime = minTime * config_variables_1.getRetryMultiplier(); const maxTime = minTime * config_variables_1.getRetryMultiplier();
// returns a random number between the minTime (inclusive) and the maxTime (exclusive) // returns a random number between the minTime (inclusive) and the maxTime (exclusive)
return Math.random() * (maxTime - minTime) + minTime; return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
} }
exports.getExponentialRetryTimeInMilliseconds = getExponentialRetryTimeInMilliseconds; exports.getExponentialRetryTimeInMilliseconds = getExponentialRetryTimeInMilliseconds;
/** /**
@@ -8328,48 +8441,6 @@ Header Information: ${JSON.stringify(response.message.headers, undefined, 2)}
###### End Diagnostic HTTP information ######`); ###### End Diagnostic HTTP information ######`);
} }
exports.displayHttpDiagnostics = displayHttpDiagnostics; exports.displayHttpDiagnostics = displayHttpDiagnostics;
/**
* Invalid characters that cannot be in the artifact name or an uploaded file. Will be rejected
* from the server if attempted to be sent over. These characters are not allowed due to limitations with certain
* file systems such as NTFS. To maintain platform-agnostic behavior, all characters that are not supported by an
* individual filesystem/platform will not be supported on all fileSystems/platforms
*
* FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
*/
const invalidArtifactFilePathCharacters = ['"', ':', '<', '>', '|', '*', '?'];
const invalidArtifactNameCharacters = [
...invalidArtifactFilePathCharacters,
'\\',
'/'
];
/**
* Scans the name of the artifact to make sure there are no illegal characters
*/
function checkArtifactName(name) {
if (!name) {
throw new Error(`Artifact name: ${name}, is incorrectly provided`);
}
for (const invalidChar of invalidArtifactNameCharacters) {
if (name.includes(invalidChar)) {
throw new Error(`Artifact name is not valid: ${name}. Contains character: "${invalidChar}". Invalid artifact name characters include: ${invalidArtifactNameCharacters.toString()}.`);
}
}
}
exports.checkArtifactName = checkArtifactName;
/**
* Scans the name of the filePath used to make sure there are no illegal characters
*/
function checkArtifactFilePath(path) {
if (!path) {
throw new Error(`Artifact path: ${path}, is incorrectly provided`);
}
for (const invalidChar of invalidArtifactFilePathCharacters) {
if (path.includes(invalidChar)) {
throw new Error(`Artifact path is not valid: ${path}. Contains character: "${invalidChar}". Invalid characters include: ${invalidArtifactFilePathCharacters.toString()}.`);
}
}
}
exports.checkArtifactFilePath = checkArtifactFilePath;
function createDirectoriesForArtifact(directories) { function createDirectoriesForArtifact(directories) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
for (const directory of directories) { for (const directory of directories) {
@@ -8430,7 +8501,10 @@ exports.sleep = sleep;
/***/ 875: /***/ 875:
/***/ (function(module, __unusedexports, __webpack_require__) { /***/ (function(module, __unusedexports, __webpack_require__) {
const {promisify} = __webpack_require__(669); "use strict";
const { promisify } = __webpack_require__(669);
const tmp = __webpack_require__(150); const tmp = __webpack_require__(150);
// file // file
@@ -8985,6 +9059,14 @@ function safeTrimTrailingSeparator(p) {
exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator; exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator;
//# sourceMappingURL=internal-path-helper.js.map //# sourceMappingURL=internal-path-helper.js.map
/***/ }),
/***/ 988:
/***/ (function(module, __unusedexports, __webpack_require__) {
module.exports = __webpack_require__(141);
/***/ }) /***/ })
/******/ }); /******/ });
+4030 -4213
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -29,7 +29,7 @@
}, },
"homepage": "https://github.com/actions/upload-artifact#readme", "homepage": "https://github.com/actions/upload-artifact#readme",
"dependencies": { "dependencies": {
"@actions/artifact": "^0.5.2", "@actions/artifact": "^0.6.1",
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/glob": "^0.1.0", "@actions/glob": "^0.1.0",
"@actions/io": "^1.0.2" "@actions/io": "^1.0.2"
@@ -44,10 +44,10 @@
"eslint-plugin-github": "^4.1.1", "eslint-plugin-github": "^4.1.1",
"eslint-plugin-jest": "^23.8.2", "eslint-plugin-jest": "^23.8.2",
"glob": "^7.1.6", "glob": "^7.1.6",
"jest": "^26.6.3", "jest": "^27.2.5",
"jest-circus": "^26.1.0", "jest-circus": "^27.2.5",
"prettier": "^2.0.4", "prettier": "^2.0.4",
"ts-jest": "^25.3.1", "ts-jest": "^27.0.6",
"typescript": "^3.8.3" "typescript": "^3.8.3"
} }
} }