Skip to content
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
merged 12 commits into from Jul 11, 2023

Conversation

JoshMcCullough
Copy link
Contributor

@JoshMcCullough JoshMcCullough commented May 13, 2023

Originally I thought the path checks were too specific, and the a reusable workflow didn't need to be stored under .github/workflows/. I believe I was confusing actions with workflows while reading the docs. So in the end, this PR ends up being simply to throw/exit in the case that an invalid uses is provided.

@JoshMcCullough JoshMcCullough requested a review from a team as a code owner May 13, 2023 00:34
@mergify
Copy link
Contributor

mergify bot commented May 13, 2023

@JoshMcCullough this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label May 13, 2023
@mergify
Copy link
Contributor

mergify bot commented May 13, 2023

@JoshMcCullough this pull request has failed checks 🛠

@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #1804 (f678692) into master (4989f44) will increase coverage by 1.35%.
The diff coverage is 64.79%.

@@            Coverage Diff             @@
##           master    #1804      +/-   ##
==========================================
+ Coverage   61.22%   62.58%   +1.35%     
==========================================
  Files          46       51       +5     
  Lines        7141     8282    +1141     
==========================================
+ Hits         4372     5183     +811     
- Misses       2462     2701     +239     
- Partials      307      398      +91     
Impacted Files Coverage Δ
pkg/common/outbound_ip.go 0.00% <0.00%> (ø)
pkg/container/docker_cli.go 82.23% <ø> (ø)
pkg/container/docker_logger.go 52.08% <ø> (ø)
pkg/container/docker_volume.go 0.00% <ø> (ø)
pkg/container/file_collector.go 37.30% <0.00%> (ø)
pkg/container/host_environment.go 0.00% <0.00%> (ø)
...ontainer/linux_container_environment_extensions.go 23.07% <0.00%> (-1.25%) ⬇️
pkg/container/util.go 0.00% <0.00%> (ø)
pkg/exprparser/functions.go 66.32% <0.00%> (-1.04%) ⬇️
pkg/container/docker_run.go 13.58% <12.50%> (-0.01%) ⬇️
... and 29 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@JoshMcCullough JoshMcCullough marked this pull request as draft May 13, 2023 13:06
@mergify mergify bot removed the needs-work Extra attention is needed label May 13, 2023
@JoshMcCullough JoshMcCullough marked this pull request as ready for review May 13, 2023 13:57
pkg/model/workflow.go Outdated Show resolved Hide resolved
@JoshMcCullough JoshMcCullough changed the title fix relative path check when determining workflow job type throw when invalid uses key is provided May 13, 2023
@pull-request-size pull-request-size bot added size/L and removed size/M labels May 14, 2023
@mergify
Copy link
Contributor

mergify bot commented May 14, 2023

@JoshMcCullough this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label May 14, 2023
ChristopherHX
ChristopherHX previously approved these changes May 15, 2023
Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm dropping my changes requested review, somehow I'm not allow to dismis my review.

As long the linter complains about your tests, merging is blocked

I guess you need either add

// nolint:dupl
func TestReadWorkflow_JobTypes(t *testing.T) {
...
// nolint:dupl
func TestReadWorkflow_JobTypes_InvalidPath(t *testing.T) {

Or merge the test functions to make the linter (I didn't added it) happy.

You can download golangci-lint and run it locally in your checkout

pkg/model/workflow.go Outdated Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented May 15, 2023

@JoshMcCullough this pull request has failed checks 🛠

@mergify
Copy link
Contributor

mergify bot commented May 15, 2023

@JoshMcCullough this pull request has failed checks 🛠

@mergify
Copy link
Contributor

mergify bot commented May 15, 2023

@JoshMcCullough this pull request has failed checks 🛠

@JoshMcCullough
Copy link
Contributor Author

You can download golangci-lint and run it locally in your checkout

I actually did try to run that, it gives me a massive amount of superfluous output so I didn't trust it. :) I promise I read CONTRIBUTING.md.

Those tests are not actually duplicative so I don't know why the linter thinks they are...seems a bit picky.

@JoshMcCullough
Copy link
Contributor Author

JoshMcCullough commented May 16, 2023

Not sure what lint is upset about here:

Running [/home/runner/golangci-lint-1.47.2-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
Warning: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)

level=warning msg="[linters context] contextcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the golangci/golangci-lint#2649."
level=warning msg="[linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the golangci/golangci-lint#2649."

Error: issues found

I also don't see why the Linux build is so mad. :)

@ChristopherHX
Copy link
Contributor

Warning: error-strings: error strings should not be capitalized or end with punctuation or a newline (revive)

Warnings like this seems to raised as errors

I also don't see why the Linux build is so mad. :)

Flaky tests, maybe we should disable TestRunEvent/network. Sometime the container cannot resolve the dns name of the hosted runner

@mergify mergify bot removed the needs-work Extra attention is needed label May 17, 2023
@mergify mergify bot requested a review from a team May 17, 2023 13:09
@nektos nektos deleted a comment from mergify bot May 17, 2023
@nektos nektos deleted a comment from mergify bot May 17, 2023
@JoshMcCullough
Copy link
Contributor Author

Finally.

ChristopherHX
ChristopherHX previously approved these changes May 18, 2023
Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1/2 Approvals

pkg/runner/run_context.go Show resolved Hide resolved
isYaml, _ := regexp.MatchString(`\.(ya?ml)(?:$|@)`, j.Uses)

if isYaml {
isLocalPath := strings.HasPrefix(j.Uses, "./.github/workflows/")
Copy link
Contributor

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

Copy link
Contributor Author

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.

@ChristopherHX
Copy link
Contributor

Looks fine for me.
I'm awaiting a review from another maintainer, I can't do anything on my own.

Copy link
Member

@KnisterPeter KnisterPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me too. Thanks for contributing.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops the else if jobType != model.JobTypeDefault { block needs to be moved back, because it should allow skipping reusable workflows.

While jobtypeinvalid should return an error as early as possible.

This means we don't have a test for skipping reusable workflows

@ChristopherHX
Copy link
Contributor

Looks fine for me too. Thanks for contributing.

Do you accept the regression I mentioned above ? If so I approve, since I don't use the reusable workflow feature of act.

@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2023

@JoshMcCullough this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Jul 10, 2023
@mergify mergify bot removed the needs-work Extra attention is needed label Jul 11, 2023
@cplee cplee merged commit 808cf5a into nektos:master Jul 11, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants