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

Rework how we extract lint failures into GitHub annotations #1961

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

ebroder
Copy link
Member

@ebroder ebroder commented Jan 9, 2024

Fix presentation of lint failures as GitHub annotations, originally introduced in #725 and broken (I think) in #1197.

For background, GitHub's annotation extraction requires that file paths be absolute and reflect the working directory that the repository is checked out into. That doesn't work great for us because we do our builds inside of a Docker container under a different path. So we need to rewrite file paths in the outputs that we get from running lint inside Docker. We do that using a Docker argument (i.e. environment variable) that gets passed in. Previously, we needed to escape our use of that variable in the lint script so that Docker itself wouldn't apply variable substitution that we didn't want, but with new style heredocs, Docker wasn't applying those substitutions anymore. We didn't notice at the time because, well, we didn't have any lint failures.

Separately from all of that, we've only historically supported extracting annotations for eslint failures and not failures for our other lint steps. tsc and stylelint don't support custom output formatters, as far as I can tell, but GitHub does support extracting annotations using regexes ("problem matchers") instead of requiring custom output formatting from the tools themselves. For consistency, switch eslint to use a problem matcher as well, rather than having a mix of approaches.

Here's what a PR looks like with failures now:

Screenshot 2024-01-09 at 4 31 18 PM

My biggest complaint with this is that there's no way to tell which tool threw a particular error, but as far as I can tell there's no way to add that information.

@ebroder ebroder force-pushed the evan/test-eslint-formatter-gha branch 7 times, most recently from 9bb7e60 to 34f0a3b Compare January 10, 2024 00:25
This was - I think - broken in 7784c15,
when we changed our heredoc style. Previously, we had to escape shell
variables so that Docker _wouldn't_ substitute them, leaving them in
place for bash to substitute them. However, with new-style heredocs,
Docker doesn't do substitutions, so the escapes were left behind to be
consumed by bash.

Additionally, instead of using a formatter for eslint, we can use
"problem matchers" - i.e. regexes - which extract the relevant errors.
This works for tsc and stylelint in addition to eslint.
@ebroder ebroder force-pushed the evan/test-eslint-formatter-gha branch from 34f0a3b to d982c25 Compare January 10, 2024 00:32
@ebroder ebroder changed the title Add some testing Rework how we extract lint failures into GitHub annotations Jan 10, 2024
@ebroder ebroder requested a review from zarvox January 10, 2024 00:43
@ebroder ebroder marked this pull request as ready for review January 10, 2024 00:43
@ebroder ebroder enabled auto-merge January 10, 2024 00:43
@ebroder ebroder merged commit 7dec89d into main Jan 10, 2024
1 check passed
@ebroder ebroder deleted the evan/test-eslint-formatter-gha branch January 10, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants