-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: download artifacts from current workflow run, improve API usage #9
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
25fa53e
feat: support downloading artifacts from current workflow run
AlCalzone 6a0a7b3
feat: log when artifact found locally
AlCalzone e354a63
feat: handle statistics requests
AlCalzone c7be2f4
feat: download current workflow artifacts before starting the server
AlCalzone 11f2f24
feat: re-upload artifacts from other workflows, cache list response
AlCalzone d4ac2ed
fix: logging for local artifacts
AlCalzone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
import { info, saveState } from '@actions/core'; | ||
import { info, saveState, setFailed } from '@actions/core'; | ||
import { spawn } from 'child_process'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import { cacheDir, States } from './utils/constants'; | ||
import { downloadSameWorkflowArtifacts } from './utils/downloadArtifact'; | ||
|
||
fs.ensureDirSync(cacheDir); | ||
async function main() { | ||
await fs.ensureDir(cacheDir); | ||
|
||
const out = fs.openSync(path.join(cacheDir, 'out.log'), 'a'); | ||
const err = fs.openSync(path.join(cacheDir, 'out.log'), 'a'); | ||
await downloadSameWorkflowArtifacts(); | ||
|
||
const subprocess = spawn('node', [path.resolve(__dirname, '../turboServer/index.js')], { | ||
detached: true, | ||
stdio: ['ignore', out, err], | ||
env: process.env, | ||
}); | ||
const out = fs.openSync(path.join(cacheDir, 'out.log'), 'a'); | ||
const err = fs.openSync(path.join(cacheDir, 'out.log'), 'a'); | ||
|
||
const subprocess = spawn( | ||
'node', | ||
[path.resolve(__dirname, '../turboServer/index.js')], | ||
{ | ||
detached: true, | ||
stdio: ['ignore', out, err], | ||
env: process.env, | ||
} | ||
); | ||
|
||
subprocess.unref(); | ||
subprocess.unref(); | ||
|
||
info(`${States.TURBO_LOCAL_SERVER_PID}: ${subprocess.pid}`); | ||
saveState(States.TURBO_LOCAL_SERVER_PID, subprocess.pid); | ||
info(`${States.TURBO_LOCAL_SERVER_PID}: ${subprocess.pid}`); | ||
saveState(States.TURBO_LOCAL_SERVER_PID, subprocess.pid); | ||
} | ||
|
||
main().catch((error) => { | ||
setFailed(error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you ensure that these artifacts are belongs to the current workflow?
Looks like you are downloading all the files, which may contain hundreds of gigs in my case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's this method: https://github.com/actions/toolkit/blob/e6257f111756d2f3567917c8e27ab57de8c3e09c/packages/artifact/src/internal/artifact-client.ts#L221
using this method to list artifacts: https://github.com/actions/toolkit/blob/e6257f111756d2f3567917c8e27ab57de8c3e09c/packages/artifact/src/internal/download-http-client.ts#L45
which in turn is using https://github.com/actions/toolkit/blob/e6257f111756d2f3567917c8e27ab57de8c3e09c/packages/artifact/src/internal/utils.ts#L222 as the download URL
which is referencing the current workflow run using the env variable here:
https://github.com/actions/toolkit/blob/e6257f111756d2f3567917c8e27ab57de8c3e09c/packages/artifact/src/internal/config-variables.ts#L50
Good point. An alternative would be using
@actions/artifact
s internals as I attempted here:zwave-js/node-zwave-js@
10121ae
(#5050)This way one could filter for files that look like a hash, but that might not be stable across releases of that package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't like this approach, I first attempted to download the files from the current workflow and fall back to the ones from other workflows if that didn't work. However, it was pretty slow (20 seconds for a handful of small artifacts).