-
Notifications
You must be signed in to change notification settings - Fork 29
Use Regex instead of taplo
to extract channel in linter action
#526
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
Conversation
I believe Bash is treating `"${REGEX}"` as a raw Regex pattern, and doesn't interpolate the value of `$REGEX` into the string. It seems to support the `$REGEX` syntax, however.
I couldn't get Bash's built-in Regex matching to work, so I switched to `sed`.
I switched the action over to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good imo. Tested the commands locally and it works as expected!
bevy_lint/action.yml
Outdated
toolchain: ${{ steps.channel.outputs.channel }} | ||
# These components are hard-coded because they are unlikely to change. They should match | ||
# `rust-toolchain.toml`. | ||
components: rustc-dev, llvm-tools-preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Could we not also use a sed command like:
sed -nE 's/^components = \[(.*)\]/\1/p' rust-toolchain.toml | tr -d '"'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I didn't know about tr
until now! I was so concerned with parsing the array that I never considered simply stripping all of the "
, clever!
Fixes #510.
This PR modifies
bevy_lint
's action to use Regex to capture the toolchain channel inrust-toolchain.toml
. Specifically, it uses this pattern:I recommend looking at this in Regex101 to understand what its doing. In short, it looks for the line
channel = "..."
and captures everything between the double quotes.Additionally, I switched the toolchain components to be completely hard-coded within the action. As these components are unlikely to ever change, I figured it was far simpler than trying to use more Regex to extract them fromrust-toolchain.toml
. This can be changed in the future!