Skip to content

pre-commit: Switch to GitHub action; add eslint fixer #1404

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

Merged
merged 14 commits into from
Apr 11, 2023

Conversation

pokey
Copy link
Member

@pokey pokey commented Apr 9, 2023

Checklist

@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch from ef0f53b to 6ee8083 Compare April 9, 2023 11:55
@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch from bd85ba8 to 25f75e3 Compare April 9, 2023 13:37
@pokey
Copy link
Member Author

pokey commented Apr 9, 2023

Huh pre-commit.ci lite unfortunately doesn't seem to work. I tried changing a lint rule to see if it would auto-fix, but nothing happens 😕

edit: Ok it did work, but man was it slow 😅

@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch 2 times, most recently from 361752c to c3fbe0a Compare April 9, 2023 13:55
@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch from e25eff6 to c9d5568 Compare April 9, 2023 13:59
@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch from 0d8bc03 to 49da5ad Compare April 9, 2023 14:06
@pokey
Copy link
Member Author

pokey commented Apr 9, 2023

Ok I switched the push action to https://github.com/stefanzweifel/git-auto-commit-action instead of pre-commit.ci lite, because the former is basically instant, whereas the latter seems to take a while

@pokey pokey marked this pull request as ready for review April 9, 2023 14:08
@pokey pokey changed the title pre-commit: Use pre-commit.ci lite; add eslint fixer pre-commit: Switch to GitHub action; add eslint fixer Apr 9, 2023
cache: pnpm
- run: pnpm --color install
- uses: pre-commit/[email protected]
- uses: stefanzweifel/git-auto-commit-action@v4
Copy link
Member

Choose a reason for hiding this comment

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

Does this work for forks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. I'll give it a whirl

Copy link
Member Author

@pokey pokey Apr 10, 2023

Choose a reason for hiding this comment

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

Haven't tested yet, but looks like a bit of a hornet's nest and potentially introduces security vulnerability to get it to work 😬 stefanzweifel/git-auto-commit-action#211

So do we switch to pre-commit lite and deal with really slow commit, or switch to the setup from my other attempt with syncing versions? Downside of the latter is we can't easily run custom fixers like if we wanted to autoformat our recorded tests using our custom yaml writer

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. It might be possible to get something working with the completion of this workflow triggering another workflow that runs in the main context? That'd be super complex though, and sounds like even more of a nightmare.

I've seen workflows that use a personal access token to get this sort of thing to work, but that's probably just as risky.

Copy link
Member

Choose a reason for hiding this comment

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

Confirmed that this setup doesn't work for forks. See https://github.com/cursorless-dev/cursorless/actions/runs/4658630193/jobs/8244534702?pr=1409:

remote: Permission to cursorless-bot/cursorless-fork-test-2.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/cursorless-bot/cursorless-fork-test-2/': The requested URL returned error: 403

Going to take another swing at pre-commit.ci lite; maybe the slowness was just a one-off 🤷‍♂️

Copy link
Member Author

@pokey pokey Apr 10, 2023

Choose a reason for hiding this comment

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

Ok I switched back to pre-commit.ci lite; was actually quite fast this time around, so I'd be tempted to just ship it. Being able to run our own custom fixers using node scripts etc I think is worth the price of slower CI fixes

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 do wonder why GitHub's security policy doesn't allow GitHub actions to push from the context of the forked repo to a branch on that repo 🤔

@auscompgeek
Copy link
Member

auscompgeek commented Apr 10, 2023

FWIW we don't have to abandon pre-commit.ci entirely, we can skip eslint/prettier on pre-commit.ci and just run eslint and prettier on GitHub Actions

@pokey
Copy link
Member Author

pokey commented Apr 10, 2023

FWIW we don't have to abandon pre-commit.ci entirely, we can skip eslint/prettier on pre-commit.ci and just run eslint and prettier on GitHub Actions

What's the benefit of having both systems active?

@auscompgeek
Copy link
Member

🤷

There's a potential cache speed benefit with pre-commit.ci, but I guess we don't know exactly how much caching will help us here since the cache doesn't exist on main for the workflow to use yet.

@pokey pokey force-pushed the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch from 463745f to 48226ec Compare April 10, 2023 14:23
@pokey
Copy link
Member Author

pokey commented Apr 10, 2023

🤷

There's a potential cache speed benefit with pre-commit.ci, but I guess we don't know exactly how much caching will help us here since the cache doesn't exist on main for the workflow to use yet.

pre-commit.ci is significantly faster, as you suspect, but tbh most of the fixes come from prettier, so I'm not sure the benefit of putting the other fixers in a different CI system justify the complexity / races of running two systems

@pokey pokey requested a review from auscompgeek April 10, 2023 16:11
@pokey pokey added this pull request to the merge queue Apr 11, 2023
Merged via the queue into main with commit 36c7644 Apr 11, 2023
@pokey pokey deleted the pokey/pre-commit-use-pre-commitci-lite-add-eslint-fixer branch April 11, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants