-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Asset server implementation #677
Conversation
Codecov Report
@@ Coverage Diff @@
## master #677 +/- ##
==========================================
+ Coverage 49.27% 56.22% +6.95%
==========================================
Files 23 25 +2
Lines 2401 3929 +1528
==========================================
+ Hits 1183 2209 +1026
- Misses 1090 1522 +432
- Partials 128 198 +70
Continue to review full report at Codecov.
|
I wouldn't bother with cli flags for this. This is specifically for |
Let me explain a bit on why we thing that configuration might help here (for our usecase): This assets could be used for caching things across runs as well. In fact the github We are using act to run github actions in a non-local environment. And we would like to use this feature (and extend on that outside of act) to build a whole caching layer. An implicit overridable env-var would be fine for us. |
Ok, I see server is running locally on host. That won't work if the Docker host is a remote server, for example |
We should at least follow some standard of non-conflicting envvars, like |
What do you mean with that? Do you suggest to make the server only available in the docker internal network for the run - for sharing across jobs? One use case which is in my head would be to expose test result data or coverage information after an act execution. |
IMO, server should be available only in containers created by |
Hmm, I see your point. But I'm not sure how to implement that. Don't we need the server outside of the containers to write into the host file system? |
Don't worry, proceed with your PR as you planned 😺 I have some idea but that requires much more changes in |
since server will be on host for now, please add port flag
Please add them to Line 652 in cc4e23d
|
@catthehacker @cplee Can you guide us where the proper place for these lines are? I think it might not be right in the middle of the CLI parsing. |
Before Lines 261 to 271 in ef0da2a
|
This comment has been minimized.
This comment has been minimized.
pkg/artifacts/server.go
Outdated
router.PUT("/upload/:runId", func(w http.ResponseWriter, req *http.Request, params httprouter.Params) { | ||
itemPath := req.URL.Query().Get("itemPath") | ||
runID := params.ByName("runId") | ||
|
||
filePath := fmt.Sprintf("%s/%s/%s", artifactPath, runID, itemPath) | ||
|
||
err := os.MkdirAll(path.Dir(filePath), os.ModePerm) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
file, err := os.Create(filePath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer file.Close() | ||
|
||
_, err = io.Copy(file, req.Body) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
json, err := json.Marshal(ResponseMessage{ | ||
Message: "success", | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
_, err = w.Write(json) | ||
if err != nil { | ||
panic(err) | ||
} | ||
}) |
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.
Does this work for asset files > 8 MB?
I ask this because the actions/toolkit uploads big files in 8MB chunks with range upload.
Currently 2 chunks are uploaded parallel to the server by the toolkit.
I haven't tested this implementation, but the nodejs version also missed chunk upload
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.
I guess it doesn't work. I think think the default go web server does this.
But I also think the support for chunked upload could be defered to a later PR. The API wouldn't change for that.
Splitting this into multiple PRs would add support for smaller chunks earlier/faster.
Could you also update |
@catthehacker Yes, good point. I'm currently writing tests. So this is still WIP. |
@catthehacker I'm very inexperienced with go. I think the tests are fine now, can you do a review. Specially with the MemFS parts, I'm unsure if this is 'go-like'. P.S.: This is still WIP. I need to re-test if the implementation still works. |
Hi, @KnisterPeter
results to
same thing with the ACTIONS_RUNTIME_URL
results to
spitfire.lan - is local domain name of the my workstation Will appreciate any information) |
First of all I have to say that this is not about the cache, but about artifacts created during the build. The github actions caching is only using parts of this and is not compatible. Second to note, this is not a fully tested solution and it should be integrated when I'm ready with testing. I haven't had so much time lately. |
@KnisterPeter Thank you for having time to clear this out for me. |
@crawler Use https://github.com/nektos/act#skipping-steps with |
31665e5
to
0ee3a45
Compare
ce928d7
to
53eb9f8
Compare
@KnisterPeter this pull request has failed checks 🛠 |
1 similar comment
@KnisterPeter this pull request has failed checks 🛠 |
This change should allow to use the host ip in macos and windows. Since docker is running in an intermediate vm, localhost is not sufficient to have the artifacts in the host system.
To shutdown artifact server, we should not use the already canceled context but the parent context instead. Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
77ae60e
to
861695e
Compare
@KnisterPeter this pull request has failed checks 🛠 |
When the pipeline is done the asset server should be shut down gracefully. Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
@catthehacker @cplee We consider this ready for review and merge now.
|
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.
Looks sound 😸
@catthehacker @cplee What need to be done to enable the merge? I wanted to tick the |
I assume @cplee can merge it manually (since I don't have permissions to do so) or you could rebase on master and force push branch, but it would require approval again. |
@KnisterPeter - the issue is the base branch |
I can't see this documented in the README for this project - is it ready to use? |
It is documented as 'artifact server' in the readme. |
Thankyou for your great work team. Having said that, I am unable to run this. The command I am using is
The error I am getting is
Am I missing something? |
Please create new issue or ask on Gitter. |
Description
This PR contains a naive github-actions (partially-)compatible asset server.
We only reverse engineered the success case.
The implementation is based on the awesome work of @anthonykawa: https://github.com/anthonykawa/artifact-server
This implementation should be seen as a draft and requires an architecture/design review.
Missing things
Prerequisites
--env ACTIONS_RUNTIME_URL=http://localhost:8080/
must be set because it's internally used by the@action/toolkit
--env ACTIONS_RUNTIME_TOKEN=foo
must be set (we do not have authentication implemented)This should ideally be implemented (either as port of this PR or #329), so users don't need to set it on their own.These variables are set if act is started with
--artifact-server-path
and configured for the internal server.It is also possible to define them as environment variables using
--env
for an external artifact-server.Relates to #329
--
Closes #169