GitHub Action for Linting with Vercel

I’m trying to setup GitHub Actions to lint and prettify the code in my turborepo monorepo; it’s great and works really well to get everything set, but it’s throwing an error from Vercel; the lint-action user doesn’t have access to my Vercel account to create a preview deployment, and at the same time I don’t want linting to create a separate deployment. Given these things, is there a reason to use actions for this instead of something like lint-staged as a pre-commit hook?
38 Replies
Develliot
Develliot3y ago
You just need a job that does something like this
name: TestPR
on:
pull_request:
branches:
- master
concurrency:
cancel-in-progress: true
group: test-${{ github.head_ref }}
jobs:
ESLint:
runs-on: ubuntu-latest
steps:
- name: Checkout fundraising-web-app
uses: actions/checkout@v3
- name: Setup Node
uses: actions/[email protected]
with:
node-version: "14"
- name: Test
run: |
npm install
npm run eslint:test
name: TestPR
on:
pull_request:
branches:
- master
concurrency:
cancel-in-progress: true
group: test-${{ github.head_ref }}
jobs:
ESLint:
runs-on: ubuntu-latest
steps:
- name: Checkout fundraising-web-app
uses: actions/checkout@v3
- name: Setup Node
uses: actions/[email protected]
with:
node-version: "14"
- name: Test
run: |
npm install
npm run eslint:test
Don't deploy anything
theo (t3.gg)
theo (t3.gg)3y ago
Okay so to be very clear - is the action creating a commit with the formatting done? Want to gauge my roast appropriately
thejessewinton
thejessewintonOP3y ago
Yes…
theo (t3.gg)
theo (t3.gg)3y ago
Okay, that's very very bad Actions should flag code that is bad, not fix it
thejessewinton
thejessewintonOP3y ago
So don’t auto fix is what you’re saying?
theo (t3.gg)
theo (t3.gg)3y ago
Depends on your definition of "auto fix" The Git host is 10000% the wrong place to autofix The goal of CI is to validate, not fix Fwiw I don't even do typechecks on the Vercel build, I let it deploy if it is at all possible for it to build. I HARD BLOCK merging to main on our CI tho (typechecks, lint and prettier)
Develliot
Develliot3y ago
+1 for a pre commit hook that isn't a bad idea
theo (t3.gg)
theo (t3.gg)3y ago
I personally hate precommit hooks but that is the thing you're looking for here
thejessewinton
thejessewintonOP3y ago
I used this guy here: https://github.com/marketplace/actions/lint-action Is there a better way in?
GitHub
Lint Action - GitHub Marketplace
GitHub Action for detecting and fixing linting errors
theo (t3.gg)
theo (t3.gg)3y ago
This is cursed VERY cursed
Develliot
Develliot3y ago
The IDE should catch this stuff as you work to be fair
theo (t3.gg)
theo (t3.gg)3y ago
Never been so tempted to open an issue on a repo that's just "this is bad please archive it" But like,,, Please don't do this. This this this this If your editor is failing you, CI should ALERT you to that CI test for it if you're vaguely worried about it tbh CI is really cool I don't like precommit hooks because they force developers to use git a specific way, I don't like prescribing workflows to my teams But if you really want the "act of committing" to "imply that the code will auto-fix" for some reason, sure go nuts don't do that on github
thejessewinton
thejessewintonOP3y ago
Okay this is really good to know, I’m super new to actions tbh and I’ve been eliminating pre-commit hooks for precisely that reason.
theo (t3.gg)
theo (t3.gg)3y ago
Theo - ping.gg (@t3dotgg)
People have github actions that make code changes??? Oh god oh no this is like precommit hooks but 100x worse
Twitter
theo (t3.gg)
theo (t3.gg)3y ago
You inspired a tweet
thejessewinton
thejessewintonOP3y ago
Fuck Well, here’s to that not happening again. 🤙🏻
theo (t3.gg)
theo (t3.gg)3y ago
No worries lol The real inspo is the 400 stars that AWFUL plugin had Ty for bringing this to my attention
thejessewinton
thejessewintonOP3y ago
I mean, I’m honored. I got rid of this action as soon as I saw it making commits that were trying to deploy, but I was trying to figure out a better way to get the same effect. Do you recommend setting up actions to run deployments to Vercel, rather than the Git auto-deploy?
theo (t3.gg)
theo (t3.gg)3y ago
Nah the GitHub auto deploy is great What’s your specific goal with actions here? Preventing extra deploys?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
theo (t3.gg)
theo (t3.gg)3y ago
Do you block the Vercel deploy on the tests?
Develliot
Develliot3y ago
My main issue with pre commit hooks is them slowing work flow down enough to put people off atomic commits
haris
haris3y ago
I would higly recommend just using husky for this, I use it in a couple of my projects as a pre commit hook and it works great
thejessewinton
thejessewintonOP3y ago
Mostly just linting and prettifying, but talking this through made me realize that autoSave in the IDE should be doing all of that already. So what’s the way to lint/prettify/typecheck production deployments?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Develliot
Develliot3y ago
See my code snippet above
thejessewinton
thejessewintonOP3y ago
This was how I realized I needed to get rid of my pre-commit hooks; team members weren’t committing often enough and the hooks were doing stupid, unnecessary shit.
Develliot
Develliot3y ago
I once saw a team run all tests on it so it was mental
theo (t3.gg)
theo (t3.gg)3y ago
That answers my Q. Curious now why you ignore tests 👀👀 I have seen this a few times. PRECOMMIT HOOKS ARE NOT CI
Develliot
Develliot3y ago
My time is more valuable than the GitHub actions quota I ler CI find an issue and then I fix it later, then I'm not waiting I can do other stuff It doesn't deploy until it's all groovy unless I force it
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
theo (t3.gg)
theo (t3.gg)3y ago
AH the coverage rule. That’s silly I hate codecov
theo (t3.gg)
theo (t3.gg)3y ago
Malte Ubl (@cramforce)
@t3dotgg It can use ISR. The issue is that the Twitter API can only look back 7 days. So you need to store data somewhere and git is right there.
Twitter
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
theo (t3.gg)
theo (t3.gg)3y ago
What would you want the collab channel for? Actually don’t steal this Make a thread about it in #suggestions
thejessewinton
thejessewintonOP3y ago
I am sorry for what I’ve started 😂
theo (t3.gg)
theo (t3.gg)3y ago
To be fair it’s a very important convo and I’m learning…things Mostly how I am unsure of my choice in idols 😅😅😅
thejessewinton
thejessewintonOP3y ago
Same; glad we had this learning experience 😂. Like I said earlier, I’m brand new to using GitHub actions this has given me a lot more to research. 🫠🫠
Want results from more Discord servers?
Add your server