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

feat: Validate GitHub Actions schema #2416

Merged
merged 9 commits into from
Aug 13, 2024
Merged

feat: Validate GitHub Actions schema #2416

merged 9 commits into from
Aug 13, 2024

Conversation

ChristopherHX
Copy link
Contributor

Resolves #2414

BREAKING previously accepted workflows are now invalid

@wolfogre you would need to add context gitea everywhere github is in the context array in your fork if this would be merged

I'm not shure if Gitea Actions has labeled some behavior allowed without schema as features.

Moreover Singleworlflows are more likely to be rejected after this change.

TBD add tests that serialized workflows from model can be parsed again, e.g. the Container structure used to contain additional fields that are invalid per schema

As draft to see which test is invalid as well

**BREAKING** previously accepted workflows are now invalid
@ChristopherHX ChristopherHX requested a review from a team as a code owner August 4, 2024 11:42
Copy link
Contributor

github-actions bot commented Aug 4, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 9 0 0.06s
✅ JSON jsonlint 2 0 0.11s
✅ JSON prettier 2 0 0.41s
✅ JSON v8r 2 0 1.59s
✅ REPOSITORY gitleaks yes no 2.32s
✅ REPOSITORY git_diff yes no 0.01s
✅ REPOSITORY grype yes no 8.54s
✅ REPOSITORY secretlint yes no 1.06s
✅ REPOSITORY trivy-sbom yes no 0.47s
✅ REPOSITORY trufflehog yes no 4.07s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link
Contributor

mergify bot commented Aug 4, 2024

@ChristopherHX this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Aug 4, 2024
Copy link
Contributor

mergify bot commented Aug 4, 2024

@ChristopherHX this pull request has failed checks 🛠

@ChristopherHX ChristopherHX marked this pull request as draft August 4, 2024 13:44
ChristopherHX added a commit to nektos/act-test-actions that referenced this pull request Aug 4, 2024
@wolfogre
Copy link
Member

wolfogre commented Aug 4, 2024

Thanks for mentioning me. I'll keep an eye on this PR. Don't worry, although there could be some challenges for the Gitea's fork, I believe we can find a way to handle them. So please feel free to do what you think is right. 👍

Copy link

codecov bot commented Aug 4, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 34 lines in your changes missing coverage. Please review.

Project coverage is 76.59%. Comparing base (5a80a04) to head (1bb2cf3).
Report is 98 commits behind head on master.

Files Patch % Lines
pkg/schema/schema.go 85.58% 25 Missing and 7 partials ⚠️
pkg/model/action.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2416       +/-   ##
===========================================
+ Coverage   61.56%   76.59%   +15.03%     
===========================================
  Files          53       62        +9     
  Lines        9002     8157      -845     
===========================================
+ Hits         5542     6248      +706     
+ Misses       3020     1343     -1677     
- Partials      440      566      +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mergify mergify bot removed the needs-work Extra attention is needed label Aug 4, 2024
@ChristopherHX ChristopherHX marked this pull request as ready for review August 4, 2024 15:26
@ChristopherHX
Copy link
Contributor Author

The error messages might be cryptic here, but this should be the minimal viable variant of a schema check without additional complexity for producing better errors

Somehow I managed to fix the errors reported by CI here.

Actually disabling this schema check to get more time in a fork should be straight forward, by removeing UnmarshallYAML in two places

Sources of the schemas

@ChristopherHX
Copy link
Contributor Author

@focusaurus please review this change to the validation.

Something like this will no longer parse

- uses:
  run:
- null
on: whatever

and a lot more like

- uses: myrepo@${{ github.ref }}
- run: ${{ gitlab.test }}

expressions are checked ahead of time like in actions/runner parser.

Copy link
Contributor

mergify bot commented Aug 11, 2024

@ChristopherHX this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Aug 11, 2024
@mergify mergify bot removed the needs-work Extra attention is needed label Aug 11, 2024
@weyert
Copy link

weyert commented Aug 11, 2024

This looks really interesting! I have had cases were I was happy writing Github Actions/workflows with act and then Github Actions CI on GitHub.com complained about things. Would be really nice to have early warnings about such errors.

@mergify mergify bot merged commit 102e6cb into master Aug 13, 2024
12 checks passed
@mergify mergify bot deleted the act-schema branch August 13, 2024 03:40
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.

act should validate schema in a way that is close to what github does
3 participants