-
-
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
feat: support offline mode #2128
Conversation
Can you provide a detailed explanation of how offline mode works with act runner? BTW, if you cannot access github.com, you can handle it with |
In nektos act is forcepull enabled by default, I would expect that offline mode would also stop pulling existing images e.g. turning the default force-pull off. As far as I understand, this change relies on the cache of act and skip all updates to cached actions. Due to that git.fetch can not return any errors anymore while cannot connect to github. I assume not cached actions will be cloned once per tag and then never updated. In act_runner forcepull is still off by default, however I don't know why it is still disabled there. It's the same as with force-rebuild beeing still disabled in act_runner. Those features beeing turned off caused bugs for users expecting uptodate images or docker actions |
My plans to create a new ActionCache for nektos/act was rejected silently by all members of nektos/act, by not commenting at all That would also have an easy offline mode, even with remote action overrides to a local folder of your choice. |
Yes, I created a new pull request at act_runner#454 |
I'm sorry for your experience. I only added very few features, and you did more, but I don't have the ability to help you :( |
No progress here? You would need two approvals for getting this merged. FYI My approval for this depends on the following
Alternatively I think it might be reasonable that everywhere the forcepull is checked a extra check to OfflineMode is done to behave like forcepull is disabled if OfflineMode is active. e.g. if forcepull {
}
if !forcepull {
} becomes if !OfflineMode && forcepull {
}
if OfflineMode || !forcepull {
} I'm not requesting changes in the hard way, so that two other maintainer can still vote to get this merged as it is I couldn't find the related issue about running act offline, but I believe it exists |
I agree with this suggestion. I have modified the code and committed it here |
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.
Seems like you understood the opposite of what I actually meant.
You are also seem to missing a line here:
Line 59 in 106275b
rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", true, "pull docker image(s) even if already present") |
So what you seem to have changed makes the following
act --offline-mode
(act --offline-mode --pull=true
) ignore offline mode. (forcepull has default value true in act)
A user of act would have to write
act --offline-mode --pull=false
to get the offline mode.
What I meant is
act --offline-mode
(act --offline-mode --pull=true
) turns on offline mode and turns off force pull.
pkg/runner/reusable_workflow.go
Outdated
@@ -66,7 +66,7 @@ func cloneIfRequired(rc *RunContext, remoteReusableWorkflow remoteReusableWorkfl | |||
Ref: remoteReusableWorkflow.Ref, | |||
Dir: targetDirectory, | |||
Token: rc.Config.Token, | |||
OfflineMode: rc.Config.ActionOfflineMode, |
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 actually meant to keep this, like it was before
pkg/runner/step_action_remote.go
Outdated
@@ -67,7 +67,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor { | |||
Ref: sar.remoteAction.Ref, | |||
Dir: actionDir, | |||
Token: github.Token, | |||
OfflineMode: sar.RunContext.Config.ActionOfflineMode, |
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 actually meant to keep this, like it was before
The lines I meant would be
So that the offline mode can turn off forcepull. |
106275b
to
fe28097
Compare
@ChristopherHX Sorry for misunderstanding your meaning earlier. Now I have modified the code and committed it here. |
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.
Works perfectly fine for me on windows, thank you.
Can rerun act with offlinemode using it's cache without getting any error due to turning off internet.
.\t\.github\workflows\t.yaml
on: push
jobs:
_:
runs-on: t
steps:
- uses: actions/download-artifact@v4 # This actions obviously fails, but never due to no internet
via cli
.\act.exe -C .\t\ -P t=-self-hosted --action-offline-mode
Once the mode is enabled the following is the new behavior
- not yet cloned actions will be cloned in this mode, assumes internet is working
- already cloned actions won't be updated (breaks updates of rolling tags / branches, but that's a user decision)
- already pulled images won't be updated
- works offline, with disabled internet
- no rewriting of workflow files needed
One pending review, from maintainers, required...
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2128 +/- ##
==========================================
- Coverage 61.22% 60.78% -0.44%
==========================================
Files 46 53 +7
Lines 7141 8966 +1825
==========================================
+ Hits 4372 5450 +1078
- Misses 2462 3079 +617
- Partials 307 437 +130 ☔ View full report in Codecov by Sentry. |
Thank you for your detailed description of this feature, which makes the originally vague function clearer and easier to understand |
* Add: Actions Offline Mode * Add: Actions Offline Mode --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
In some regions, connecting to github.com may not be as smooth.
So every time we using
uses:
method, it is not a good way tofetch
andpull
the current action content, and I think the action tag will also be rarely updated.We can add a configurable option in
OfflineMode
to control it, setting the default value tofalse
, so this will not affect other users.PS: This feature is mainly intended for use by Gitea act_runner. If possible, I will also create a pull request over there.