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

workflows: add actionlint workflow #15210

Merged
merged 1 commit into from Apr 12, 2023
Merged

Conversation

carlocab
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This will help us avoid future actionlint errors in our workflows.

  • workflows: add actionlint workflow
  • Add actionlint error for testing WIP

@carlocab carlocab force-pushed the actionlint branch 5 times, most recently from 37f1f36 to e0b01e2 Compare April 12, 2023 05:10
@carlocab carlocab marked this pull request as ready for review April 12, 2023 05:11
.github/workflows/actionlint.yml Outdated Show resolved Hide resolved
self-hosted-runner:
# Labels of self-hosted runner in array of strings.
labels:
- 11-arm64
Copy link
Member

Choose a reason for hiding this comment

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

I assume it just doesn't complain about the others?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, it doesn't know what to do with a dynamically generated runner label so just ignores it.

run: |
brew install actionlint shellcheck

# Annotations work only relative to GITHUB_WORKSPACE
Copy link
Member

@Bo98 Bo98 Apr 12, 2023

Choose a reason for hiding this comment

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

Annotations should work fine (see: test-bot in Homebrew/core). Are you referring to add-matcher or the process the matcher later does?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you referring to add-matcher or the process the matcher later does?

Both. Annotations work for us otherwise because we use GitHub::Actions::Annotation, which handles emitting the correct relative paths:

@file = self.class.path_relative_to_workspace(file)

I couldn't get this to show annotations without moving everything into GITHUB_WORKSPACE at Homebrew/homebrew-core#128075. I didn't bother trying here, though.

Copy link
Member

Choose a reason for hiding this comment

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

Ok looks like this actions/runner#765.

.github/workflows/actionlint.yml Show resolved Hide resolved
Comment on lines 29 to 31
defaults:
run:
shell: /bin/bash -e {0}
Copy link
Member

Choose a reason for hiding this comment

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

The default is bash -e {0}. Are we avoiding another bash somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

IIUC correctly in containers the default is sh. Or an sh masquerading as bash.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, weird. I know I've had trouble with [[, ]] in Homebrew/core workflows when I don't set shell: /bin/bash.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now getting

shellcheck reported issue in this script: SC2115:warning:4:27: Use "${var:?}" to ensure this never expands to /* 

After dropping this.

Copy link
Member

@Bo98 Bo98 Apr 12, 2023

Choose a reason for hiding this comment

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

It says it's running:

shell: /usr/bin/bash -e {0}

Is /usr/bin/bash different? Don't think it should be with 22.04.

Though with that said, throwing that error feels like correct behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

Though with that said, throwing that error feels like correct behaviour?

Yes, agreed. Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

It's possible it might just not run shellcheck with custom shells, which could make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

I get

/__w/_temp/b13f8fe9-518c-4fd3-af62-a31519cf8e56.sh: 5: shopt: not found

when running without setting the shell to /bin/bash in Homebrew/core. Must have something to do with running in a container, since the shell there is reported as sh -e {0}.

https://github.com/Homebrew/homebrew-core/actions/runs/4678530113/jobs/8287369304?pr=128075#step:5:34

Copy link
Member

@Bo98 Bo98 Apr 12, 2023

Choose a reason for hiding this comment

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

Ah yes, that'll be because the shell is evaluated before the container is started, so it won't know whether bash is available.

Unless we need/want to avoid --noprofile --norc -o pipefail, we could pass shell: bash simply which should still allow shellcheck to run.

Some other parts of homebrew-core CI have the explicit /bin/bash to avoid Homebrew bash which some tests may install, so those are unavoidable.

Co-authored-by: Bo Anderson <mail@boanderson.me>
@carlocab
Copy link
Member Author

This should be ready to merge.

@carlocab carlocab enabled auto-merge April 12, 2023 13:38
@carlocab carlocab merged commit b15e448 into Homebrew:master Apr 12, 2023
25 checks passed
@MikeMcQuaid
Copy link
Member

Thanks @carlocab!

@carlocab carlocab deleted the actionlint branch April 12, 2023 14:26
@github-actions github-actions bot added the outdated PR was locked due to age label May 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants