Skip to content

Commit 7e061e7

Browse files
committed
use action to run hooks
1 parent 10a0b57 commit 7e061e7

File tree

1 file changed

+13
-64
lines changed

1 file changed

+13
-64
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -11,74 +11,23 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
lint:
15-
name: Lint & format
14+
pre-commit:
15+
name: Pre-commit hooks
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v6
2020

21-
- name: Check for trailing whitespace
22-
run: |
23-
if grep -rn --include='*.md' --include='*.ts' --include='*.tsx' --include='*.astro' --include='*.json' --include='*.yaml' --include='*.yml' --include='*.css' '[[:blank:]]$' .; then
24-
echo "::error::Trailing whitespace found"
25-
exit 1
26-
fi
27-
28-
- name: Check for missing final newline
29-
run: |
30-
bad=0
31-
while IFS= read -r -d '' f; do
32-
if [ -s "$f" ] && [ "$(tail -c1 "$f" | wc -l)" -eq 0 ]; then
33-
echo "::error file=$f::Missing final newline"
34-
bad=1
35-
fi
36-
done < <(find . -type f \( -name '*.md' -o -name '*.ts' -o -name '*.tsx' -o -name '*.astro' -o -name '*.json' -o -name '*.yaml' -o -name '*.yml' -o -name '*.css' \) -not -path './node_modules/*' -not -path './.git/*' -print0)
37-
exit $bad
38-
39-
- name: Validate YAML files
40-
run: |
41-
pip install --quiet yamllint
42-
find . -type f \( -name '*.yaml' -o -name '*.yml' \) -not -path './node_modules/*' -not -path './.git/*' | xargs -r python3 -c "
43-
import sys, yaml
44-
for f in sys.argv[1:]:
45-
try:
46-
yaml.safe_load(open(f))
47-
except Exception as e:
48-
print(f'::error file={f}::{e}')
49-
sys.exit(1)
50-
"
51-
52-
- name: Validate JSON files
53-
run: |
54-
find . -type f -name '*.json' -not -path './node_modules/*' -not -path './.git/*' | xargs -r python3 -c "
55-
import sys, json
56-
for f in sys.argv[1:]:
57-
try:
58-
json.load(open(f))
59-
except Exception as e:
60-
print(f'::error file={f}::{e}')
61-
sys.exit(1)
62-
"
63-
64-
- name: Check for merge conflict markers
65-
run: |
66-
if grep -rn '<<<<<<< \|=======$\|>>>>>>> ' --include='*.md' --include='*.ts' --include='*.tsx' --include='*.astro' --include='*.json' --include='*.yaml' --include='*.yml' --include='*.css' .; then
67-
echo "::error::Merge conflict markers found"
68-
exit 1
69-
fi
70-
71-
- name: Check for large files
72-
run: |
73-
bad=0
74-
while IFS= read -r f; do
75-
size=$(stat --printf='%s' "$f" 2>/dev/null || stat -f'%z' "$f")
76-
if [ "$size" -gt 512000 ]; then
77-
echo "::error file=$f::File is $(( size / 1024 ))KB (max 500KB)"
78-
bad=1
79-
fi
80-
done < <(git diff --cached --name-only --diff-filter=d 2>/dev/null || git ls-files)
81-
exit $bad
21+
- name: Setup Bun
22+
uses: oven-sh/setup-bun@v2
23+
with:
24+
bun-version: latest
25+
26+
- name: Install dependencies
27+
run: bun install --frozen-lockfile
28+
29+
- name: Run pre-commit hooks via prek
30+
uses: j178/prek-action@v1
8231

8332
quality:
8433
name: Quality checks
@@ -114,7 +63,7 @@ jobs:
11463
build:
11564
name: Build
11665
runs-on: ubuntu-latest
117-
needs: [lint, quality, spellcheck]
66+
needs: [pre-commit, quality, spellcheck]
11867
steps:
11968
- name: Checkout
12069
uses: actions/checkout@v6

0 commit comments

Comments
 (0)