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/setup-node@v3.4.1
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/setup-node@v3.4.1
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
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
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
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
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
Want results from more Discord servers?
Add your server