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

[CI/Build] Add linting for github actions workflows #7876

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

russellb
Copy link
Collaborator

@russellb russellb commented Aug 26, 2024

This PR introduces linting for github actions workflows to help prevent any
accidental introduction of errors in the future. It introduces this linting in
two ways:

  1. A way to run the linting locally as part of format.sh.

  2. Automatically run the linter in CI anytime github actions workflows are
    modified.

71be98b github: Add an actionlint github workflow
a9785b5 github: Quote variables
2dcdd71 github: Handle filenames with special characters
fc050dd github: Update versions of various github actions
0956a41 format.sh: Avoid exit when no files changed
276b408 format.sh: lint github ci configuration

commit 71be98b
Author: Russell Bryant rbryant@redhat.com
Date: Mon Aug 26 13:39:01 2024 -0400

github: Add an actionlint github workflow

Add a new github actions workflow that will perform linting on github
actions workflow changes. It will only run if github workflows are
modified.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit a9785b5
Author: Russell Bryant rbryant@redhat.com
Date: Mon Aug 26 13:30:03 2024 -0400

github: Quote variables

Avoid accidental globbing or argument splitting by quoting the
`$GITHUB_ENV` variable. In practice, this would probably never be a
problem since github sets the value, but it follows best shell
practices and makes the shell linter happy.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit 2dcdd71
Author: Russell Bryant rbryant@redhat.com
Date: Mon Aug 26 13:34:03 2024 -0400

github: Handle filenames with special characters

Resolve the following linter warning:

```
.github/workflows/publish.yml:87:9: shellcheck reported issue in this script: SC2011:warning:2:14: Use 'find .. -print0 | xargs -0 ..' or 'find .. -exec .. +' to allow non-alphanumeric filenames [shellcheck]
```

I don't expect this was a problem in practice, but it follows best
practice as indicated by the linter.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit fc050dd
Author: Russell Bryant rbryant@redhat.com
Date: Mon Aug 26 14:27:30 2024 -0400

github: Update versions of various github actions

These were raised by the action linter.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit 0956a41
Author: Russell Bryant rbryant@redhat.com
Date: Tue Aug 27 10:08:31 2024 -0400

format.sh: Avoid exit when no files changed

This script is set to exit any time a command fails. In the case of
this line, the script unexpectedly errors out on this check to see if
any files have changed that are relevant for the `clang-format` tool.
The `grep` specifically will return non-zero in this case.

The workaround here is to catch the error and run `echo -e` instead,
which we know will succeed and the end result is what we want (the
list of changed files will be empty).

This allows the script to continue to completion, even when
`clang-format` has nothing to do.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit 276b408
Author: Russell Bryant rbryant@redhat.com
Date: Tue Aug 27 11:08:50 2024 -0400

format.sh: lint github ci configuration

Update `format.sh` to run the `actionlint` tool to check for errors in
GitHub CI configuration. Both this script and the workflow to run this
tool in CI run it using docker to ensure that the same version is in
use in both places.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which consists a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of default ones by unblocking the steps in your fast-check build on Buildkite UI.

Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge).

To run full CI, you can do one of these:

  • Comment /ready on the PR
  • Add ready label to the PR
  • Enable auto-merge.

🚀

@russellb
Copy link
Collaborator Author

/ready

@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 26, 2024
@njhill njhill requested a review from khluu August 27, 2024 01:47
@njhill
Copy link
Member

njhill commented Aug 27, 2024

Thanks @russellb! I wonder if we could incorporate this into the existing format.sh assuming it doesn't take long to run? I.e. rather than having to run make separately for this...

@russellb
Copy link
Collaborator Author

Thanks @russellb! I wonder if we could incorporate this into the existing format.sh assuming it doesn't take long to run? I.e. rather than having to run make separately for this...

Sure, thanks for the tip. Integrating wherever it's most natural for existing dev workflows is best! I'll modify for using format.sh, though I think it should be optional since most people wouldn't be editing the github CI config, so I wouldn't want to require the tool to be installed.

@russellb russellb force-pushed the actionlint branch 2 times, most recently from 5c5d1a3 to 276b408 Compare August 27, 2024 17:26
@russellb russellb changed the title Add linting for github actions workflows [CI/Build] Add linting for github actions workflows Aug 30, 2024
format.sh Outdated
fi
# Ensure we use the same version of actionlint as CI
IMAGE="vllm/actionlint:latest"
${DOCKER} build --tag "${IMAGE}" - < .github/workflows/actionlint.dockerfile
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use something like flake8 instead of Docker for local formatting? Some people might not have Docker installed ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will at least skip this step gracefully if it's not installed.

The alternative is that go needs to be installed. It's not a Python tool. https://github.com/rhysd/actionlint

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They have pre-built binaries, so I could have it auto-download that. I'll look at that now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@khluu I've got it using a prebuilt binary from a github release if it's not found, so there are no longer any dependencies for this to work

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

Add a new github actions workflow that will perform linting on github
actions workflow changes. It will only run if github workflows are
modified.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Avoid accidental globbing or argument splitting by quoting the
`$GITHUB_ENV` variable. In practice, this would probably never be a
problem since github sets the value, but it follows best shell
practices and makes the shell linter happy.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Resolve the following linter warning:

```
.github/workflows/publish.yml:87:9: shellcheck reported issue in this script: SC2011:warning:2:14: Use 'find .. -print0 | xargs -0 ..' or 'find .. -exec .. +' to allow non-alphanumeric filenames [shellcheck]
```

I don't expect this was a problem in practice, but it follows best
practice as indicated by the linter.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
These were raised by the action linter.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
This script is set to exit any time a command fails. In the case of
this line, the script unexpectedly errors out on this check to see if
any files have changed that are relevant for the `clang-format` tool.
The `grep` specifically will return non-zero in this case.

The workaround here is to catch the error and run `echo -e` instead,
which we know will succeed and the end result is what we want (the
list of changed files will be empty).

This allows the script to continue to completion, even when
`clang-format` has nothing to do.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Update `format.sh` to run the `actionlint` tool to check for errors in
GitHub CI configuration. Both this script and the workflow to run this
tool in CI run it using docker to ensure that the same version is in
use in both places.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Previously `format.sh` and the github workflow used docker or podman
to run actionlint. This now will use an installed version if found,
and will otherwise download and run a prebuilt binary from a github
release.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
@khluu khluu enabled auto-merge (squash) October 7, 2024 20:40
@khluu khluu merged commit e0dbdb0 into vllm-project:main Oct 7, 2024
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants