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

fix: panic if a step in a job is nil #1145

Merged
merged 5 commits into from
May 12, 2022
Merged

fix: panic if a step in a job is nil #1145

merged 5 commits into from
May 12, 2022

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Apr 29, 2022

We need to be careful
Closes #1144

on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    -
    - run: exit 0
go run . -W .\w.yml -P ubuntu-latest=ubuntu:latest --no-skip-checkout
Error: invalid Step 0: missing run or uses key
exit status 1

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ CREDENTIALS secretlint yes no 1.0s
✅ EDITORCONFIG editorconfig-checker 2 0 0.53s
✅ GIT git_diff yes no 0.0s

See errors details in artifact MegaLinter reports on CI Job page
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #1145 (fc892da) into master (4f8da0a) will increase coverage by 2.49%.
The diff coverage is 78.48%.

@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
+ Coverage   57.50%   60.00%   +2.49%     
==========================================
  Files          32       39       +7     
  Lines        4594     5000     +406     
==========================================
+ Hits         2642     3000     +358     
- Misses       1729     1751      +22     
- Partials      223      249      +26     
Impacted Files Coverage Δ
pkg/model/action.go 0.00% <ø> (ø)
pkg/model/github_context.go 79.51% <ø> (ø)
pkg/model/planner.go 50.73% <ø> (+0.32%) ⬆️
pkg/model/workflow.go 50.36% <0.00%> (-0.56%) ⬇️
pkg/container/docker_run.go 5.01% <1.96%> (-0.53%) ⬇️
pkg/common/git.go 49.31% <28.57%> (-0.52%) ⬇️
pkg/container/file_collector.go 44.85% <44.85%> (ø)
pkg/runner/runner.go 73.72% <73.68%> (-2.75%) ⬇️
pkg/exprparser/interpreter.go 75.29% <75.00%> (+1.89%) ⬆️
pkg/runner/logger.go 69.56% <75.47%> (+4.13%) ⬆️
... and 20 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ChristopherHX ChristopherHX marked this pull request as ready for review May 4, 2022 20:07
@ChristopherHX ChristopherHX requested a review from a team as a code owner May 4, 2022 20:07
catthehacker
catthehacker previously approved these changes May 5, 2022
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.

I think the main problem is found in this function:

act/pkg/model/workflow.go

Lines 416 to 428 in a76c349

func (s *Step) Type() StepType {
if s.Run != "" {
if s.Uses != "" {
return StepTypeInvalid
}
return StepTypeRun
} else if strings.HasPrefix(s.Uses, "docker://") {
return StepTypeUsesDockerURL
} else if strings.HasPrefix(s.Uses, "./") {
return StepTypeUsesActionLocal
}
return StepTypeUsesActionRemote
}

It assumes that any type which isn't matched otherwise is a remote action.

@KnisterPeter
Copy link
Member

I've created #1157 to fix this

cplee
cplee previously approved these changes May 11, 2022
@ChristopherHX ChristopherHX dismissed stale reviews from cplee and catthehacker via aa7be68 May 12, 2022 18:10
@mergify mergify bot requested a review from a team May 12, 2022 18:24
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.

Thanks 👍

@mergify mergify bot merged commit 91fd412 into master May 12, 2022
@mergify mergify bot deleted the fix-panic-nil-step branch May 12, 2022 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants