-
-
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
Add ability to run with a snapshot of working directory #21
Comments
@cplee I think it would be simplest/best† from act's perspective if it always created a copy with The temporary directory should be deleted (may have to use another container to delete it due to non-user ownership) unless Another thing would be that this temporary directory should only be acessable to root+the current user, otherwise you could be exposing secrets (e.g. on a shared test server). † The files on your local system probably won't match what git gets for various reasons, e.g.
|
While I think using a temp directory is a great idea as to not leave artifacts around, the other side of the coin is that running on the users files makes testing workflows easier. Also it would limit acts usefulness as a task runner. Not sure what I actually would prefer though. |
@xendk agreed. My thought would be to leave the current behavior as the default, and then add a flag to use to activate this new behavior of creating a temp directory. thoughts? |
@cplee One could make a case for the default to be the non-destructive option and put the current behavior behind a switch. A bit annoying for using it as a task runner, but there's something to be said for not touching the users checkout in the default case. |
I think running in the original checkout may be useful if you aren't using filters (other than git-lfs) and want to do something something weird and wonderful(?) like only running some stages by hand - your task running? The thing I don't like about doing that by default is that it leaves room for surprises to casual users e.g. permissions on artefacts, "works on my machine". I'm pro-fresh working directory by default as I am convinced it would make adoption smoother/simpler for people/teams. People getting caught out by "works on my machine" would be a pretty big detraction from the GitLab Actions CI/CD to me. Would it cover your use case with something like: rm -fr /tmp/my-workspace
act my-first-stage --use=/tmp/my-workspace # directory doesn't exist so make a fresh copy
act my-second-stage --use=/tmp/my-workspace # directory exists so just run action |
What I'd suggest:
Runs in a new temporary directory which is deleted after use.
Runs in the original directory. Personally I don't think I'd use a switch to specify a specific directory. To me it would suggest not removing the directory after use which I can't see why I would need that. But that's just my personal oppinion. |
Could you describe your use case(s) for me? I imagined you were interested in running a subset of actions but it sounds like I misunderstand - particularly around "it would limit acts usefulness as a task runner". I suppose for testing workflows you'd just want the workspace to not be deleted/cleaned. I suggest deleting them by default because as I imagine you'd be safest using a random temporary directory for each run to avoid conflicts, and that could fill up your disk - especially if you are running on a CI/CD machine. The other reason I suggest deleting the temporary workspaces by default is for projects where there are contributors who aren't familiar with the issues from using docker, or even how GitHub actions work - I imagine this to be quite a large part of the population. I imagine there's a fair chance people would get caught on: temporary directories accumulating, temporary directories containing things owned by root thanks to Docker so they can't delete (or have to sudo or use another container with a mount), or non-clean state causing different outcomes. I suppose my motivation is to minimise unpleasant surprises for casual users, letting them use workflows with the minimum amount of thought as though they were just pushing to GitHub. p.s. I imagine |
I'm actually not using it as a task runner, I was merely taking the hint from the readme:
My use case for not using a temporary directory is working with the workflow itself. I was using act to test run the workflow before committing and pushing. In that case, creating a fresh clone would require me to commit every change.
I'll still contest that. Having act only run on committed changes will certainly trip up people used to Running on a temp copy of your current checkout would be nice, but that involves a fair bit more of bitshuffling. Actually, thinking about it and acts potential as a task runner, I'm more leaning towards keeping the current behavior and having |
In makefiles that's whatever a user defines it as. In GitHub Actions the workspace gets thrown away at completion so it doesn't deal with the particulars of cleaning. How would Personally I'm used to modifying commits locally before I push them to a remote branch with I love the I like the idea of catering for secondary use cases, that is why I don't think copy+run+delete is all that should be catered for, but I think the primary use is what should work smoothly out of the box. With what I'm suggesting you could still use makefiles perfectly easily to do things if you wanted to contain your tooling in Actions, so I don't think it compromises that vision. |
Sure, but I'm yet to see a
I'm quite familiar with git and history modification, but that's not the point. I don't commit to run
But what do you think the primary use is? It seems to be at odds with the stated purpose of the maintainer:
Which both points towards not using a clean slate. Anyway, @cplee himself suggested adding a switch, and after some thinking, I think that's the best solution. Then you could alias github-actions to |
I've seen quite a few makefiles that require commits (plenty in my current workplace), e.g. for things that ultimately end up using It does come down to cplee's choice and vision for the project. I've covered my reasoning both for the copy approach by default, and ways to use that when like-for-like GitHub Action replication isn't the goal. |
For those folks that are interested in the original proposal (to run |
Thanks for all the feedback! I still like the option of keeping Next question...should the temp directory be populated from the current git worktree or from the latest git commit? My preference would be worktree. Thoughts? |
Either works for me. I'm biased towards worktree as it allows for testing that it works on ones changes, but without any stray files one might have floating about. |
Close nektos#21 I have tested this PR and run Go actions successfully on: - Windows host - Docker on Windows - Linux host - Docker on Linux Before running Go actions, we need to make sure that Go has been installed on the host or the Docker image. Reviewed-on: https://gitea.com/gitea/act/pulls/22 Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: Zettat123 <[email protected]> Co-committed-by: Zettat123 <[email protected]>
Currently act binds the local repo as
/github/workspace
in the containers for the actions. The problem is that any mutations that the actions make to the workspace affect the local repo.We should add support for a new flag
-t
to instruct act to create a copy of the local repo in a new temp directory and bind that temp directory into the containers so that act can be run in a way that guarantees no changes are made on the local repo.The text was updated successfully, but these errors were encountered: