Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #13

Merged
merged 149 commits into from
Jan 30, 2024
Merged

test #13

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
0747ab3
cache - getCacheVersion - dup paths array
MSP-Greg Mar 20, 2023
8f032d3
Upgrade codeql actions to v2
pje Sep 27, 2023
0d63834
Merge pull request #1541 from actions/pje/upgrade-codeql-actions-to-v2
pje Sep 27, 2023
0faced6
Add function to return proxy agent dispatcher for compatibility with …
takost Oct 5, 2023
129f884
fix format
takost Oct 5, 2023
eae1b66
fix audit
takost Oct 5, 2023
13e0ce9
resolve comments
takost Oct 6, 2023
c8d1588
Merge pull request #1547 from actions/takost/update-http-client
takost Oct 6, 2023
797f48f
Update release notes for [email protected] (#1549)
takost Oct 6, 2023
494f12b
Update dependencies in github package (#1553)
takost Oct 10, 2023
8247412
use sha256 instead of md5 for artifact v4 integrity hash
robherley Oct 16, 2023
8cd02df
audit fix
robherley Oct 16, 2023
fe3e7ce
Merge pull request #1563 from actions/robherley/artifact-v4/sha256
robherley Oct 16, 2023
20f826b
Add platform info utilities to @actions/core (#1551)
nikolai-laevskii Nov 14, 2023
7b01731
increase upload concurrency based on cpus, adjust highWaterMark, spec…
robherley Nov 20, 2023
606ebdc
extra log line for debug
robherley Nov 20, 2023
3a610e8
linter
robherley Nov 20, 2023
9e7201f
audit fix
robherley Nov 20, 2023
a920781
fix results url construction
robherley Nov 20, 2023
0407266
Merge pull request #1584 from actions/robherley/upload-v4-improvements
robherley Nov 20, 2023
faa4254
Add RUN_ATTEMPT to Github context
sshmaxime Nov 28, 2023
0787a93
Merge pull request #1588 from sshmaxime/main
TingluoHuang Nov 28, 2023
695bf98
rewrite artifacts client to have public and internal implementations
robherley Nov 30, 2023
e9d6649
consume new pb wrappers
robherley Nov 30, 2023
22b7aeb
some test updates
robherley Dec 1, 2023
32549e8
update download-artifact tests for public and internal impl
robherley Dec 1, 2023
4789a46
make FindOptions interface more user friendly
robherley Dec 1, 2023
57db7a6
more debug info
robherley Dec 1, 2023
a59f976
minor fixes
robherley Dec 1, 2023
281697e
fix test expectations
robherley Dec 1, 2023
8f1c589
Merge pull request #1591 from actions/robherley/artifact-internal-apis
robherley Dec 1, 2023
c1f9d37
updates to get/list artifacts
robherley Dec 3, 2023
fa76577
fix import
robherley Dec 3, 2023
c94ca49
ability to filter artifacts by latest
robherley Dec 3, 2023
c11a7cd
wip
robherley Dec 3, 2023
86ce0b1
get artifact tests
robherley Dec 3, 2023
ef454f0
add tests for list-artifacts
robherley Dec 3, 2023
790e6f7
more docs
robherley Dec 3, 2023
141b350
update import
robherley Dec 3, 2023
8ac8bf1
Merge pull request #1592 from actions/robherley/get-list-artifact-upd…
robherley Dec 4, 2023
75a3586
consistent promise behavior for upload artifact
robherley Dec 5, 2023
d3c5f35
consistent promise behavior for get artifact
robherley Dec 5, 2023
ce9eae0
consistent promise behavior for download artifact
robherley Dec 5, 2023
b987215
update GHES warning behavior
robherley Dec 5, 2023
a3053b5
fix typo
robherley Dec 5, 2023
c390199
Update artifact-tests.yml
robherley Dec 5, 2023
5f152b7
Update artifact-tests.yml
robherley Dec 5, 2023
04945c6
Merge pull request #1593 from actions/robherley/api-consistency
robherley Dec 5, 2023
449b28a
update contributing docs
robherley Dec 5, 2023
e27efe5
readme & error updates
robherley Dec 5, 2023
befa19f
initalize artifact client as default export
robherley Dec 6, 2023
9b31b03
more readme updates
robherley Dec 6, 2023
0c96219
add faq, update releases
robherley Dec 6, 2023
68958c2
Update packages/artifact/README.md
robherley Dec 6, 2023
79ace25
Update packages/artifact/README.md
robherley Dec 6, 2023
dc51518
Update packages/artifact/README.md
robherley Dec 6, 2023
23fb8c4
Update packages/artifact/README.md
robherley Dec 6, 2023
b43b979
Update packages/artifact/docs/faq.md
robherley Dec 6, 2023
19d4d9d
releases.md: link to breaking v2 changes
robherley Dec 6, 2023
49ef8b9
fix typo
robherley Dec 6, 2023
c08a7d1
Update packages/artifact/README.md
robherley Dec 6, 2023
2e6c9a1
pr feedback
robherley Dec 6, 2023
8cd4434
mention job limit
robherley Dec 6, 2023
1f87038
Update packages/artifact/README.md
robherley Dec 6, 2023
70cad3f
Update packages/artifact/README.md
robherley Dec 6, 2023
c042a30
Update packages/artifact/CONTRIBUTIONS.md
robherley Dec 6, 2023
207747e
Merge pull request #1594 from actions/robherley/artifact-docs-updates
robherley Dec 6, 2023
715b1ac
cleanup artifact handlers hanging node process
robherley Dec 6, 2023
8c317a0
one too many parses
robherley Dec 6, 2023
f732e4c
linter
robherley Dec 6, 2023
43ccaf0
Merge pull request #1596 from actions/robherley/cleanup-handlers
robherley Dec 7, 2023
64d1b10
Generate Typescript Docs for `@actions/artifact` (#1595)
robherley Dec 7, 2023
55a0525
Remove 429 request from list of retry-able status codes (#1597)
jtamsut Dec 7, 2023
88b76de
Add back 429 to list of retryable requests (#1599)
jtamsut Dec 8, 2023
950e171
Improve error messages (duplicate artifacts; too many artifacts) (#1600)
vmjoseph Dec 11, 2023
3c3af56
replace unzipper with unzip-stream
robherley Dec 11, 2023
4c531c0
update packages
robherley Dec 11, 2023
09249a7
push null at end of mocked message
robherley Dec 11, 2023
37a66eb
Merge pull request #1602 from actions/robherley/replace-unzip-lib
robherley Dec 11, 2023
a4bd0f1
Add specific messages for network-specific node error codes
robherley Dec 11, 2023
18ce228
Merge pull request #1603 from actions/robherley/network-errors
robherley Dec 11, 2023
16b786a
better error message for usage limits
robherley Dec 12, 2023
eff198b
Merge pull request #1605 from actions/robherley/usage-message
robherley Dec 12, 2023
6a9034d
update artifact workflow tests
robherley Dec 13, 2023
43c63ee
Merge pull request #1607 from actions/robherley/update-artifact-tests
robherley Dec 13, 2023
11a2dd3
update artifact module quick start
robherley Dec 14, 2023
68f2292
Merge pull request #1608 from actions/robherley/artifact-client-import
robherley Dec 14, 2023
571bf22
update to use blob client over http client
Dec 18, 2023
0c0770c
cleanup
Dec 18, 2023
bf93b54
adding logger for blob client and response
vmjoseph Dec 18, 2023
73babea
add explicit options
Dec 19, 2023
c119fcd
update optional settings for blob client
Dec 19, 2023
78ed49f
update error handling abort
Dec 19, 2023
bc68ce9
chore(docs): add missing job summary documentation (#1574)
jamesrenaud Dec 20, 2023
5430c5d
fix typo (#1611)
muzimuzhi Dec 20, 2023
2d6ba67
retry the promise
robherley Dec 20, 2023
34a411f
add timeout in between data chunks
robherley Dec 20, 2023
d6f3ee9
reject don't throw
robherley Dec 20, 2023
c33724a
update to http client
Dec 20, 2023
03319fc
client fixes for retries + logging
Dec 20, 2023
ecb4df8
remove the exit
Dec 20, 2023
ff2c524
lint and format
bethanyj28 Dec 21, 2023
f482643
updating timeout for retries
vmjoseph Dec 21, 2023
0d39975
updating test with blob timeouts
vmjoseph Dec 21, 2023
98e1a81
testing ci
vmjoseph Dec 21, 2023
7f47ffa
committing v1
vmjoseph Dec 22, 2023
9d70b8a
testing reject after timeout
vmjoseph Jan 8, 2024
67d2d58
adding delayed response to message body http mock
vmjoseph Jan 9, 2024
d63a8c4
updating package-json
vmjoseph Jan 9, 2024
e19b629
increasing timeout
vmjoseph Jan 9, 2024
58ec2bd
increase timeout
vmjoseph Jan 9, 2024
8a6aae0
updating global timeout
vmjoseph Jan 9, 2024
47157e5
fixing true
vmjoseph Jan 9, 2024
d617670
updating timer; removing logs
vmjoseph Jan 9, 2024
2124ef2
cleaning up logs
vmjoseph Jan 9, 2024
7549d1b
removing info logs
vmjoseph Jan 9, 2024
e95bcfe
Update jest.config.js
vmjoseph Jan 9, 2024
f37c445
reverting jest
vmjoseph Jan 9, 2024
c1ded1d
appeasing linter
vmjoseph Jan 9, 2024
439cd9b
appeasing linter
vmjoseph Jan 9, 2024
64b2775
Merge pull request #1613 from actions/srryan/download-v4-client-blob
SrRyan Jan 9, 2024
0389dcd
updating release notes (#1620)
vmjoseph Jan 10, 2024
cab491a
Merge pull request #1378 from MSP-Greg/00-cache-paths-dup
robherley Jan 10, 2024
b907967
Update cache npm package version
robherley Jan 10, 2024
82e8bc6
Merge pull request #1622 from actions/robherley/bump-cache-version
robherley Jan 10, 2024
7c27528
Update RELEASES.md
robherley Jan 10, 2024
1b5a6e2
Merge pull request #1623 from actions/robherley/update-cache-release
robherley Jan 10, 2024
b62d4c9
add public and internal methods to delete artifacts
robherley Jan 17, 2024
7fd71a5
fix typo
robherley Jan 17, 2024
2f5fb3f
list for correct backend ids in internal delete
robherley Jan 17, 2024
2ad687a
add integration test for delete
robherley Jan 17, 2024
abe0bd9
delete example
robherley Jan 17, 2024
1852eb2
more delete examples
robherley Jan 17, 2024
64c0992
adding version compatibility and retention to artifacts FAQ
eggyhead Jan 18, 2024
98f72c3
adding hyperlinks for new section of artifacts faq
eggyhead Jan 18, 2024
30942cc
updating artifact not found error message to include more information…
eggyhead Jan 18, 2024
5016db0
update message for internal method
eggyhead Jan 18, 2024
daf23ba
Merge pull request #1626 from actions/robherley/delete-artifacts
robherley Jan 18, 2024
58c2878
generate docs + update releases
robherley Jan 18, 2024
cca9658
removing newline and camelcasing GitHub
eggyhead Jan 18, 2024
5212cb5
Merge pull request #1628 from actions/eggyhead/update-getartifact-err…
eggyhead Jan 18, 2024
017d757
update releases.md
robherley Jan 18, 2024
4e3b068
Merge pull request #1629 from actions/robherley/update-docs-2.1.0
robherley Jan 18, 2024
8e13afa
updating language and adding compatibility table
eggyhead Jan 18, 2024
d013722
bold text
eggyhead Jan 18, 2024
dbfca02
removing numbered list
eggyhead Jan 18, 2024
bb4505e
yaml formatting
eggyhead Jan 18, 2024
74bca71
Update packages/artifact/docs/faq.md
eggyhead Jan 19, 2024
1fe633e
Merge pull request #1627 from actions/eggyhead/hyperlinks-faq
eggyhead Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 105 additions & 46 deletions .github/workflows/artifact-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Temporarily disabled while v2.0.0 of @actions/artifact is under development

name: artifact-unit-tests
on:
push:
Expand All @@ -12,8 +10,8 @@ on:
- '**.md'

jobs:
build:
name: Build
upload:
name: Upload

strategy:
matrix:
Expand All @@ -24,10 +22,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x

Expand All @@ -42,51 +40,47 @@ jobs:
npm run tsc
working-directory: packages/artifact

- name: Set artifact file contents
shell: bash
run: |
echo "file1=hello from file 1" >> $GITHUB_ENV
echo "file2=hello from file 2" >> $GITHUB_ENV

- name: Create files that will be uploaded
run: |
mkdir artifact-path
echo '${{ env.file1 }}' > artifact-path/first.txt
echo '${{ env.file2 }}' > artifact-path/second.txt
echo -n 'hello from file 1' > artifact-path/first.txt
echo -n 'hello from file 2' > artifact-path/second.txt

- name: Upload Artifacts using actions/github-script@v6
uses: actions/github-script@v6
- name: Upload Artifacts
uses: actions/github-script@v7
with:
script: |
const artifact = require('./packages/artifact/lib/artifact')
const {default: artifact} = require('./packages/artifact/lib/artifact')

const artifactName = 'my-artifact-${{ matrix.runs-on }}'
console.log('artifactName: ' + artifactName)

const fileContents = ['artifact-path/first.txt','artifact-path/second.txt']

const uploadResult = await artifact.create().uploadArtifact(artifactName, fileContents, './')
const uploadResult = await artifact.uploadArtifact(artifactName, fileContents, './')
console.log(uploadResult)

const success = uploadResult.success
const size = uploadResult.size
const id = uploadResult.id

if (!success) {
throw new Error('Failed to upload artifact')
} else {
console.log(`Successfully uploaded artifact ${id}`)
console.log(`Successfully uploaded artifact ${id}`)

try {
await artifact.uploadArtifact(artifactName, fileContents, './')
throw new Error('should have failed second upload')
} catch (err) {
console.log('Successfully blocked second artifact upload')
}

verify:
name: Verify and Delete
runs-on: ubuntu-latest
needs: [build]
needs: [upload]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x

Expand All @@ -101,35 +95,100 @@ jobs:
npm run tsc
working-directory: packages/artifact

- name: List artifacts using actions/github-script@v6
uses: actions/github-script@v6
- name: List and Download Artifacts
uses: actions/github-script@v7
with:
script: |
const artifact = require('./packages/artifact/lib/artifact')
const {default: artifactClient} = require('./packages/artifact/lib/artifact')

const workflowRunId = process.env.GITHUB_RUN_ID
const repository = process.env.GITHUB_REPOSITORY
const repositoryOwner = repository.split('/')[0]
const repositoryName = repository.split('/')[1]
const {readFile} = require('fs/promises')
const path = require('path')

const listResult = await artifact.create().listArtifacts(workflowRunId, repositoryOwner, repositoryName, '${{ secrets.GITHUB_TOKEN }}')
const findBy = {
repositoryOwner: process.env.GITHUB_REPOSITORY.split('/')[0],
repositoryName: process.env.GITHUB_REPOSITORY.split('/')[1],
token: '${{ secrets.GITHUB_TOKEN }}',
workflowRunId: process.env.GITHUB_RUN_ID
}

const listResult = await artifactClient.listArtifacts({latest: true, findBy})
console.log(listResult)

const artifacts = listResult.artifacts

if (artifacts.length !== 3) {
throw new Error('Expected 3 artifacts but only found ' + artifacts.length + ' artifacts')
const expected = [
'my-artifact-ubuntu-latest',
'my-artifact-windows-latest',
'my-artifact-macos-latest'
]

const foundArtifacts = artifacts.filter(artifact =>
expected.includes(artifact.name)
)

if (foundArtifacts.length !== 3) {
console.log('Unexpected length of found artifacts', foundArtifacts)
throw new Error(
`Expected 3 artifacts but found ${foundArtifacts.length} artifacts.`
)
}

const artifactNames = artifacts.map(artifact => artifact.name)
if (!artifactNames.includes('my-artifact-ubuntu-latest')){
throw new Error("Expected artifact list to contain an artifact named my-artifact-ubuntu-latest but it's missing")
console.log('Successfully listed artifacts that were uploaded')

const files = [
{name: 'artifact-path/first.txt', content: 'hello from file 1'},
{name: 'artifact-path/second.txt', content: 'hello from file 2'}
]

for (const artifact of foundArtifacts) {
const {downloadPath} = await artifactClient.downloadArtifact(artifact.id, {
path: artifact.name,
findBy
})

console.log('Downloaded artifact to:', downloadPath)

for (const file of files) {
const filepath = path.join(
process.env.GITHUB_WORKSPACE,
downloadPath,
file.name
)

console.log('Checking file:', filepath)

const content = await readFile(filepath, 'utf8')
if (content.trim() !== file.content.trim()) {
throw new Error(
`Expected file '${file.name}' to contain '${file.content}' but found '${content}'`
)
}
}
}
if (!artifactNames.includes('my-artifact-windows-latest')){
throw new Error("Expected artifact list to contain an artifact named my-artifact-windows-latest but it's missing")
- name: Delete Artifacts
uses: actions/github-script@v7
with:
script: |
const {default: artifactClient} = require('./packages/artifact/lib/artifact')

const artifactsToDelete = [
'my-artifact-ubuntu-latest',
'my-artifact-windows-latest',
'my-artifact-macos-latest'
]

for (const artifactName of artifactsToDelete) {
const {id} = await artifactClient.deleteArtifact(artifactName)
}
if (!artifactNames.includes('my-artifact-macos-latest')){
throw new Error("Expected artifact list to contain an artifact named my-artifact-macos-latest but it's missing")

const {artifacts} = await artifactClient.listArtifacts({latest: true})
const foundArtifacts = artifacts.filter(artifact =>
artifactsToDelete.includes(artifact.name)
)

if (foundArtifacts.length !== 0) {
console.log('Unexpected length of found artifacts:', foundArtifacts)
throw new Error(
`Expected 0 artifacts but found ${foundArtifacts.length} artifacts.`
)
}

console.log('Successfully listed artifacts that were uploaded')
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module.exports = {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
}
Loading
Loading