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: check for changes to lints separate from writing changes #2117

Merged
merged 7 commits into from
Dec 5, 2024

Conversation

zimeg
Copy link
Member

@zimeg zimeg commented Dec 5, 2024

Summary

This PR adds the lint:fix job to write changes needed for linting to pass. The npm run lint command is changed to just check for changes. That'll cause CI to fail if changes are needed!

This matches the changes discussed in slack-samples/bolt-ts-starter-template#131 and follows slackapi/bolt-js#2357.

Preview

Before changes

https://github.com/slackapi/node-slack-sdk/actions/runs/12128359302/job/33814593433#step:8:11

After changes

Found in the action logs of this PR!

Requirements

@zimeg zimeg added tests M-T: Testing work only github_actions Pull requests that update GitHub Actions code labels Dec 5, 2024
@zimeg zimeg requested review from hello-ashleyintech and a team December 5, 2024 18:46
@zimeg zimeg self-assigned this Dec 5, 2024
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.66%. Comparing base (6750da0) to head (b4c57d2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2117   +/-   ##
=======================================
  Coverage   91.66%   91.66%           
=======================================
  Files          38       38           
  Lines       10317    10317           
  Branches      647      647           
=======================================
  Hits         9457     9457           
  Misses        848      848           
  Partials       12       12           
Flag Coverage Δ
cli-hooks 95.24% <ø> (ø)
cli-test 94.48% <ø> (ø)
oauth 77.39% <ø> (ø)
socket-mode 58.22% <ø> (ø)
web-api 96.88% <ø> (ø)
webhook 96.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

📝 Leaving a few notes for the kind reviewers!

I was running into interesting strangeness in the CI matrix and left a note on changes from that 👁️‍🗨️

Comment on lines +29 to +33
- name: Configure git settings (Windows)
if: matrix.os == 'windows-latest'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
Copy link
Member Author

Choose a reason for hiding this comment

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

This step is added to not convert files to ending lines with \r\n after a checkout.

Some searching hints at .gitattributes being an option for converting files to \n endings before a commit, which might be an option if lintings begin to fail due to files being committed with \r\n!

Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason why the files' ending lines are converted to this? I'm guessing we're getting rid of those ending lines because it's clashing with the linter's parsing?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems to be a Windows default as far as I can tell 🤔

Some suggestions add the following to .gitattributes to prefer lf but that might break editing experiences on certain setups that expect the \r\n:

* text eol=lf

And some repos treat text files as binary to never change endings on checkout:

* -text

That last example is so interesting to me. The linter does expect \n in all cases and was erroring if that wasn't found, and I'm hoping this change in CI is an alright enough workaround for matching expected line endings 👾

Comment on lines +37 to +38
"lint": "npx @biomejs/biome check .",
"lint:fix": "npx @biomejs/biome check --write .",
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is matched across all packages using biome 🙏

"*": [
"./types/*"
]
"*": ["./types/*"]
Copy link
Member Author

Choose a reason for hiding this comment

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

Other changes are made to fix errors from npm run lint 🔍

Copy link
Contributor

Choose a reason for hiding this comment

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

what error would be thrown without this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

$ npx @biomejs/biome check .
./tsconfig.json format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Formatter would have printed the following content:

    17 17 │       "baseUrl": ".",
    18 18 │       "paths": {
    19    │ - ······"*":·[
    20    │ - ········"./types/*"
    21    │ - ······]
       19 │ + ······"*":·["./types/*"]
    22 20 │       },
    23 21 │       "esModuleInterop": true
    ····· │
    27 25 │       // "resolveJsonModule": true,
    28 26 │     },
    29    │ - ··"include":·[
    30    │ - ····"src/**/*"
    31    │ - ··],
    32    │ - ··"exclude":·[
    33    │ - ····"src/**/*.spec.*"
    34    │ - ··],
       27 │ + ··"include":·["src/**/*"],
       28 │ + ··"exclude":·["src/**/*.spec.*"],
    35 29 │     "jsdoc": {
    36 30 │       "out": "support/jsdoc",


Checked 9 files in 3ms. No fixes applied.
Found 1 error.
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Some errors were emitted while running checks.


An expection of an inlined list. What a beautiful error message this is 🤧

My output even shows diff with red and green 🚙 💨 TBH I would've kept the separate lines but I agree with the linter 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

This is even an error that was changed with automagic 🪄 Quite impressive! ✨

Copy link
Contributor

@hello-ashleyintech hello-ashleyintech left a comment

Choose a reason for hiding this comment

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

PR generally LGTM, thanks for doing this! 🙇 left a few questions mostly for curiosity purposes

"*": [
"./types/*"
]
"*": ["./types/*"]
Copy link
Contributor

Choose a reason for hiding this comment

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

what error would be thrown without this change?

@zimeg
Copy link
Member Author

zimeg commented Dec 5, 2024

@hello-ashleyintech 🙏 Thank you for another fast review!

I'm glad a few updates from the linter were caught here, and I'm wondering if future updates from the great @dependabot might cause errors here? 👁️‍🗨️

For now, I think we're alright to merge these changes, but open to following up with other changes around line endings or similar! 🚢

@zimeg zimeg merged commit 96d846a into main Dec 5, 2024
57 checks passed
@zimeg zimeg deleted the zimeg-ci-lint branch December 5, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code tests M-T: Testing work only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants