Skip to content

Commit dad9f4e

Browse files
authored
ci: add eslint ratcheting (supabase#40156)
* chore: add eslint ratchet script * chore: add eslint ratchet action * refactor(ratchet script): convert to typescript * ci(ratchet script): add --decrease-baselines flag Allows us to decrease the baselines on schedule as we fix warnings * ci(ratchet): add action to decrease baseline if possible every week * chore(eslint): fix exhaustive-deps error * docs(internal): improve docs for eslint ratchet script * chore(ratchet): add new ratchet rules Add: - import/no-anonymous-default-export - @tanstack/query/exhaustive-deps - @tanstack/query/no-deprecated-options Not adding `no-restricted-exports` even though we have many violations because we first need to reconfigure it (if possible) to ignore those files where Next.js requires a default export.
1 parent 597110a commit dad9f4e

File tree

6 files changed

+449
-15
lines changed

6 files changed

+449
-15
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Decrease studio lint ratchet baselines
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * SUN'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
decrease-baselines:
14+
runs-on: blacksmith-4vcpu-ubuntu-2404
15+
16+
steps:
17+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
18+
with:
19+
sparse-checkout: |
20+
.github
21+
apps/studio
22+
packages
23+
24+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
25+
name: Install pnpm
26+
with:
27+
run_install: false
28+
29+
- name: Use Node.js
30+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
31+
with:
32+
node-version-file: '.nvmrc'
33+
cache: 'pnpm'
34+
35+
- name: Install deps
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Decrease ESLint ratchet baselines and open PR
39+
env:
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
42+
run: |
43+
set -eo pipefail
44+
DEFAULT_BRANCH=${DEFAULT_BRANCH:-master}
45+
46+
BRANCH="bot/decrease-eslint-ratchet-baselines"
47+
48+
git fetch origin "$DEFAULT_BRANCH" --depth=1
49+
if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then
50+
git fetch origin "$BRANCH":"$BRANCH" --depth=1
51+
git switch "$BRANCH"
52+
git reset --hard "origin/$DEFAULT_BRANCH"
53+
else
54+
git switch --create "$BRANCH" "origin/$DEFAULT_BRANCH"
55+
fi
56+
57+
pnpm --filter studio run lint:ratchet --decrease-baselines
58+
59+
if git diff --quiet; then
60+
echo "No baseline updates detected."
61+
exit 0
62+
fi
63+
64+
git config user.name 'github-actions[bot]'
65+
git config user.email 'github-actions[bot]@users.noreply.github.com'
66+
67+
git add apps/studio/.github/eslint-rule-baselines.json
68+
git commit --message "chore: decrease ESLint ratchet baselines"
69+
git push --force origin "$BRANCH"
70+
71+
pr_url=$(gh pr list --state open --head "$BRANCH" --json url --jq '.[0].url // ""' 2>/dev/null || echo "")
72+
if [ -z "$pr_url" ]; then
73+
gh pr create \
74+
--title "[bot] Decrease ESLint ratchet baselines" \
75+
--body "Automated weekly decrease of ESLint ratchet baselines." \
76+
--base "$DEFAULT_BRANCH" \
77+
--head "$BRANCH"
78+
else
79+
gh pr comment "$pr_url" --body "Updated ESLint ratchet baselines with the latest weekly decreases."
80+
fi
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Ratchet studio lint checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'apps/studio/**'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
ratchet:
19+
# Uses larger hosted runner as it significantly decreases build times
20+
runs-on: blacksmith-4vcpu-ubuntu-2404
21+
22+
steps:
23+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
24+
with:
25+
sparse-checkout: |
26+
.github
27+
apps/studio
28+
packages
29+
30+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
31+
name: Install pnpm
32+
with:
33+
run_install: false
34+
35+
- name: Use Node.js
36+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
37+
with:
38+
node-version-file: '.nvmrc'
39+
cache: 'pnpm'
40+
41+
- name: Install deps
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Run ratchet script
45+
run: pnpm --filter studio run lint:ratchet
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rules": {
3+
"react-hooks/exhaustive-deps": 238,
4+
"import/no-anonymous-default-export": 62,
5+
"@tanstack/query/exhaustive-deps": 19,
6+
"@tanstack/query/no-deprecated-options": 2
7+
}
8+
}

apps/studio/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "next build && ./../../scripts/upload-static-assets.sh",
99
"start": "next start",
1010
"lint": "eslint .",
11+
"lint:ratchet": "tsx scripts/ratchet-eslint-rules.ts --rule react-hooks/exhaustive-deps --rule import/no-anonymous-default-export --rule @tanstack/query/exhaustive-deps --rule @tanstack/query/no-deprecated-options",
1112
"clean": "rimraf node_modules tsconfig.tsbuildinfo .next .turbo",
1213
"test": "vitest --run --coverage",
1314
"test:watch": "vitest watch",

apps/studio/pages/project/[ref]/merge.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,28 +313,14 @@ const MergePage: NextPageWithLayout = () => {
313313
})
314314
}
315315

316-
const handleReadyForReview = () => {
317-
if (!ref || !parentProjectRef) return
318-
updateBranch(
319-
{
320-
branchRef: ref,
321-
projectRef: parentProjectRef,
322-
requestReview: true,
323-
},
324-
{
325-
onSuccess: () => toast.success('Successfully marked as ready for review'),
326-
}
327-
)
328-
}
329-
330316
const breadcrumbs = useMemo(
331317
() => [
332318
{
333319
label: 'Merge requests',
334320
href: `/project/${project?.ref}/branches/merge-requests`,
335321
},
336322
],
337-
[parentProjectRef]
323+
[project?.ref]
338324
)
339325

340326
const currentTab = (router.query.tab as string) || 'database'

0 commit comments

Comments
 (0)