-
-
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
throw when invalid uses
key is provided
#1804
Merged
cplee
merged 12 commits into
nektos:master
from
JoshMcCullough:jsm/fix-workflow-jobtype
Jul 11, 2023
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e874540
throw if `uses` is invalid
JoshMcCullough 79776a8
update JobType to return error
JoshMcCullough ab711ff
Merge branch 'master' into jsm/fix-workflow-jobtype
JoshMcCullough 5a95bfe
lint
JoshMcCullough b8b3c8e
put //nolint:dupl on wrong test
JoshMcCullough 0060436
update error message to remove end punctuation
JoshMcCullough 919982c
lint
JoshMcCullough 7d005c1
update remote job type check
JoshMcCullough 921167b
move if statement
JoshMcCullough bc33613
rm nolint:dupl ... we'll see how that goes
JoshMcCullough fb5febc
Merge branch 'master' into jsm/fix-workflow-jobtype
cplee f678692
Merge branch 'master' into jsm/fix-workflow-jobtype
cplee 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,16 +451,19 @@ func (rc *RunContext) steps() []*model.Step { | |
} | ||
|
||
// Executor returns a pipeline executor for all the steps in the job | ||
func (rc *RunContext) Executor() common.Executor { | ||
func (rc *RunContext) Executor() (common.Executor, error) { | ||
var executor common.Executor | ||
var jobType, err = rc.Run.Job().Type() | ||
|
||
switch rc.Run.Job().Type() { | ||
switch jobType { | ||
case model.JobTypeDefault: | ||
executor = newJobExecutor(rc, &stepFactoryImpl{}, rc) | ||
case model.JobTypeReusableWorkflowLocal: | ||
executor = newLocalReusableWorkflowExecutor(rc) | ||
case model.JobTypeReusableWorkflowRemote: | ||
executor = newRemoteReusableWorkflowExecutor(rc) | ||
case model.JobTypeInvalid: | ||
return nil, err | ||
} | ||
|
||
return func(ctx context.Context) error { | ||
|
@@ -472,7 +475,7 @@ func (rc *RunContext) Executor() common.Executor { | |
return executor(ctx) | ||
} | ||
return nil | ||
} | ||
}, nil | ||
} | ||
|
||
func (rc *RunContext) containerImage(ctx context.Context) string { | ||
|
@@ -525,16 +528,21 @@ func (rc *RunContext) options(ctx context.Context) string { | |
func (rc *RunContext) isEnabled(ctx context.Context) (bool, error) { | ||
job := rc.Run.Job() | ||
l := common.Logger(ctx) | ||
runJob, err := EvalBool(ctx, rc.ExprEval, job.If.Value, exprparser.DefaultStatusCheckSuccess) | ||
if err != nil { | ||
return false, fmt.Errorf(" \u274C Error in if-expression: \"if: %s\" (%s)", job.If.Value, err) | ||
runJob, runJobErr := EvalBool(ctx, rc.ExprEval, job.If.Value, exprparser.DefaultStatusCheckSuccess) | ||
jobType, jobTypeErr := job.Type() | ||
|
||
if runJobErr != nil { | ||
return false, fmt.Errorf(" \u274C Error in if-expression: \"if: %s\" (%s)", job.If.Value, runJobErr) | ||
} | ||
|
||
if !runJob { | ||
l.WithField("jobResult", "skipped").Debugf("Skipping job '%s' due to '%s'", job.Name, job.If.Value) | ||
return false, nil | ||
} | ||
|
||
if job.Type() != model.JobTypeDefault { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops the While jobtypeinvalid should return an error as early as possible. This means we don't have a test for skipping reusable workflows |
||
if jobType == model.JobTypeInvalid { | ||
return false, jobTypeErr | ||
} else if jobType != model.JobTypeDefault { | ||
JoshMcCullough marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true, nil | ||
} | ||
|
||
|
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
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.
The gitea people probably want
./.gitea/workflows/
to work, but they can just patch it in their fork.I would just allow any path for reusable workflows regardless of the folder, but this error helps most people using this tool
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 was also thinking it shouldn't matter where the workflow YML is. But when I was using "any path" e.g. under a totally different/custom root dir in the repo, this was causing issues. It's possible that it was actually find and the issue was something else.
I'll push a change for this.