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

chore: Make YAML workflow git-based #7477

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ name: YAML Validation
on:
pull_request:
paths:
- '**.y?ml'
- '**.yml'
- '**.yaml'
Comment on lines -6 to +7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit is better than implicit.

push:
paths:
- '**.y?ml'
- '**.yml'
- '**.yaml'

permissions:
contents: read # to fetch code (actions/checkout)
Expand All @@ -21,4 +23,4 @@ jobs:
uses: actions/checkout@v4

- name: Run yamllint
run: find . -path \*/vendor -prune -false -o -name \*.y*ml | xargs yamllint
run: git ls-files --cached -z -- '*.y*ml' | xargs --null -- yamllint
Copy link
Member

Choose a reason for hiding this comment

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

Explanation:

  • -z quotes filenames with special characters and separates each path with NUL byte (that's why when you call this in CLI you get one long string, instead of multiple lines)
  • xargs --null then handles this NUL byte and applies YAML linter to each file

I am not 100% sure if it's needed here, we could use git ls-files without -z and then xargs would work on new lines. But both ways work, so 👍.

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 cannot take the risk of having space - or line end - characters in file names.
Sorry. My speciality is the unhappy path. I run (not build) things.

Copy link
Member

Choose a reason for hiding this comment

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

I believe we don't have files with spaces in name, but yeah, your approach is better here:

image