Skip to content

Commit bcc8d37

Browse files
author
Shaun Persad
authored
Merge pull request #566 from cloudflare/spersad/relax-checks
Relax PR checks
2 parents 8bbbcf2 + 6d380ff commit bcc8d37

File tree

6 files changed

+72
-6
lines changed

6 files changed

+72
-6
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
- package-ecosystem: "npm" # See documentation for possible values
99
directories:
1010
- "**/*"
11-
target-branch: "staging"
11+
target-branch: "main"
1212
schedule:
1313
# just in time for on-call handoff
1414
interval: "weekly"

.github/workflows/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
env:
1414
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
1515
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1617
TEMPLATES_API_CLIENT_ID: ${{ secrets.TEMPLATES_API_CLIENT_ID }}
1718
TEMPLATES_API_CLIENT_SECRET: ${{ secrets.TEMPLATES_API_CLIENT_SECRET }}
1819
steps:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Pull Request Deps"
2+
3+
on:
4+
pull_request: # this action runs in an untrusted but secure context with no secrets
5+
types:
6+
- opened
7+
- reopened
8+
9+
jobs:
10+
autofix-deps:
11+
if: github.actor == 'dependabot[bot]'
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 10
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}-autofix-deps
16+
cancel-in-progress: true
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ./.github/actions/setup
20+
21+
- name: Autofix
22+
run: pnpm -w fix:deps
23+
24+
- name: Install updated packages
25+
run: pnpm install
26+
27+
- name: Re-run other fixes with updated packages
28+
run: pnpm -w fix
29+
30+
- name: Run checks
31+
run: pnpm -w check
32+
33+
- name: Run tests
34+
run: pnpm -w test
35+
36+
- name: Commit and push changes
37+
run: |
38+
if [[ -n "$(git diff --exit-code)" ]]; then
39+
# configure user
40+
git config --global user.name "${{ github.actor }}"
41+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
42+
43+
git commit -m 'autofix dependabot PR'
44+
git push
45+
fi

cli/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { preview } from "./preview";
88
import { validateLiveDemoLinks } from "./validateLiveDemoLinks";
99
import { actionWithSummary } from "./util";
1010
import { validateD2CButtons } from "./validateD2CButtons";
11+
import { setupHooks } from "./setupHooks";
1112

1213
const program = new Command();
1314

@@ -162,4 +163,11 @@ program
162163
);
163164
});
164165

166+
program
167+
.command("setup-hooks")
168+
.description("sets up git hooks")
169+
.action(() => {
170+
setupHooks();
171+
});
172+
165173
program.parseAsync();

cli/src/setupHooks.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import fs from "node:fs";
2+
3+
const prePushHook = `
4+
#!/bin/bash
5+
pnpm run fix`.trim();
6+
7+
export function setupHooks() {
8+
fs.writeFileSync(".git/hooks/pre-push", prePushHook, {
9+
encoding: "utf-8",
10+
mode: 0o755,
11+
});
12+
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
]
2020
},
2121
"scripts": {
22-
"check": "pnpm run /^check:.*/ && git diff --exit-code",
22+
"check": "pnpm run check:templates && pnpm run check:lockfiles && pnpm run check:turbo && pnpm run check:prettier && git diff --exit-code",
2323
"check:lockfiles": "templates lint-npm-lockfiles",
2424
"check:prettier": "prettier . --check",
25-
"check:syncpack": "syncpack lint",
2625
"check:templates": "templates lint .",
2726
"check:turbo": "turbo run check cf-typegen",
2827
"deploy": "turbo run deploy",
29-
"fix": "pnpm run /^fix:.*/",
28+
"check:deps": "syncpack lint",
29+
"fix:deps": "syncpack format && syncpack fix-mismatches",
30+
"fix": "pnpm run fix:templates && pnpm run fix:lockfiles && pnpm run fix:turbo && pnpm run fix:prettier",
3031
"fix:lockfiles": "templates generate-npm-lockfiles",
3132
"fix:prettier": "prettier . --write",
32-
"fix:syncpack": "syncpack format && syncpack fix-mismatches",
3333
"fix:templates": "templates lint . --fix",
3434
"fix:turbo": "turbo run cf-typegen",
35-
"postinstall": "turbo run build",
35+
"postinstall": "turbo run build && templates setup-hooks",
3636
"preview": "templates preview",
3737
"test": "turbo run test -- --passWithNoTests",
3838
"test:cli": "vitest",

0 commit comments

Comments
 (0)