Skip to content

Commit 7dbf3d0

Browse files
authored
Update PR validation workflow to check formatting (#120)
* Update PR validation workflow to check formatting Replaced automatic formatting commit with a check for formatting issues. * Format: bun run format * Update formatting check to use Prettier * Test: formatting * Test: formatting * Add: githook pre-commit * Test: formatting * Prueba * Prueba * Prueba * Prueba * Prueba * Add: husky * Prueba
1 parent 54cac63 commit 7dbf3d0

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

.github/workflows/PRValidation.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,17 @@ jobs:
1919
uses: actions/checkout@v4
2020
with:
2121
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
22-
22+
2323
- name: Setup Bun
2424
uses: oven-sh/setup-bun@v2.0.2
2525

2626
- name: Install dependencies
2727
run: bun install
2828

29-
- name: Run formatter
30-
run: bun run format
31-
32-
- name: Commit changes
33-
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'develop' }}
34-
uses: stefanzweifel/git-auto-commit-action@v4
35-
with:
36-
commit_message: Apply formatting changes
37-
file_pattern: 'src/**'
38-
branch: ${{ github.event.pull_request.head.ref }}
39-
29+
- name: Check formatting
30+
run: |
31+
bun run prettier . --check || (echo "Formatting issues found. Please run bun run format locally." && exit 1)
32+
4033
pr-check:
4134
needs: format
4235
runs-on: ubuntu-latest

.husky/pre-commit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
# Hook: pre-commit
3+
# Este script formatea el código automáticamente antes de hacer commit.
4+
5+
echo "🔍 Ejecutando formateo antes del commit..."
6+
7+
# Ejecuta el formateador (ajusta el comando a tu proyecto)
8+
bun run format
9+
10+
# Verifica si hay cambios después del formateo
11+
if ! git diff --quiet; then
12+
echo "✨ Se aplicaron cambios de formato automáticamente. Añadiendo al commit..."
13+
git add -u
14+
else
15+
echo "✅ Código ya estaba correctamente formateado."
16+
fi
17+
18+
exit 0

bun.lockb

338 Bytes
Binary file not shown.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"format": "prettier . --write"
10+
"format": "prettier . --write",
11+
"format:check": "prettier . --check",
12+
"prepare": "husky"
1113
},
1214
"dependencies": {
1315
"@heroui/react": "^2.6.14",
@@ -44,6 +46,7 @@
4446
"autoprefixer": "^10.4.20",
4547
"eslint": "^9",
4648
"eslint-config-next": "15.1.3",
49+
"husky": "^9.1.7",
4750
"postcss": "^8.4.49",
4851
"tailwindcss": "^3.4.17",
4952
"typescript": "^5"

src/components/home/focus-cards.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const Card = React.memo(
3232
fill
3333
className="object-cover absolute inset-0"
3434
/>
35+
3536
<div
3637
className={cn(
3738
"absolute inset-0 bg-black/50 flex items-end py-8 px-4 transition-opacity duration-300",

0 commit comments

Comments
 (0)