Skip to content

Commit

Permalink
ci: update eslint and prettier rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ZL-Asica committed Nov 5, 2024
1 parent 5406579 commit afb5820
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 50 deletions.
50 changes: 20 additions & 30 deletions .github/workflows/firebase-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ on:
branches:
- main
paths:
- 'src/**' # Changes to the source code
- 'public/**' # Changes to the public folder
- 'firebase.json' # Changes to the Firebase configuration
- 'package.json' # Changes to the package.json file
- 'index.html' # Changes to the index.html file
- 'vitest.config.js' # Changes to the Vitest configuration
- '.firebaserc' # Changes to the Firebase configuration
- '.github/workflows/*' # Changes to the workflow file
- 'src/**'
- 'public/**'
- 'firebase.json'
- 'package.json'
- 'index.html'
- 'vitest.config.js'
- '.firebaserc'
- '.github/workflows/*'

concurrency:
group: firebase-deploy-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ๐Ÿงช Test before Build
build-and-deploy:
name: ๐Ÿ› ๏ธ Build, Test, and Deploy
runs-on: ubuntu-latest

steps:
Expand All @@ -36,34 +36,24 @@ jobs:
- name: ๐Ÿ“‚ Install Packages
run: npm ci

- name: ๐Ÿงช Run Tests with Vitest
run: npm run test:ci
- name: ๐Ÿšจ Lint Code
run: npm run lint:fix

deploy:
name: ๐Ÿš€ Deploy to Firebase
needs: build # Only run this job if the build job is successful
runs-on: ubuntu-latest
- name: ๐ŸŽจ Format Code
run: npm run format

steps:
- name: ๐Ÿ“ฅ Checkout Code
uses: actions/checkout@v4

- name: ๐Ÿ› ๏ธ Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'

- name: ๐Ÿ“‚ Install Packages
run: npm ci
- name: ๐Ÿงช Run Tests with Vitest
run: npm run test:ci

- name: ๐Ÿงฑ Build
- name: ๐Ÿงฑ Build Project
run: npm run build

- name: ๐ŸŒ Install Firebase Tools
if: success()
run: npm install -g firebase-tools

- name: ๐Ÿš€ Deploy to Firebase
if: success()
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: firebase deploy --token "${{ secrets.FIREBASE_TOKEN }}" --non-interactive
run: firebase deploy --non-interactive
61 changes: 41 additions & 20 deletions .github/workflows/firebase-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,61 @@ jobs:
- name: ๐Ÿ”จ Build the app
run: npm run build

# ๐Ÿšจ Run Lint check
- name: ๐Ÿšจ Run Lint
run: npm run lint:fix | tee lint-results.txt

# ๐ŸŽจ Run Prettier format check
- name: ๐ŸŽจ Run Prettier
run: npm run format | tee prettier-results.txt

- name: ๐Ÿงช Test the app with Vitest
run: npm run test:ci | tee test-results.txt
# ๐Ÿšฎ Clean up all results for comment
- name: ๐Ÿšฎ Clean up results
run: |
sed -i 's/\x1b\[[0-9;]*m//g' prettier-results.txt
sed -i 's/\x1b\[[0-9;]*m//g' lint-results.txt
sed -i 's/\x1b\[[0-9;]*m//g' test-results.txt
# ๐Ÿšฎ Clean up test results for comment
- name: ๐Ÿšฎ Clean up test results
run: sed -i 's/\x1b\[[0-9;]*m//g' test-results.txt # Removes ANSI color codes

# ๐Ÿ“„ Format test results for better readability
- name: ๐Ÿ“„ Format test results
# ๐Ÿ“„ Format all results for better readability
- name: ๐Ÿ“„ Format all results
run: |
{
echo "### ๐Ÿงช Test Results"
echo ""
if grep -q "failed" test-results.txt; then
# Extract failed test details if any
echo "โŒ **Some tests failed**:"
echo '```'
grep -E "Test Files|Tests|Duration|failed" test-results.txt
echo '```'
echo ""
echo "๐Ÿ’ฅ Please review the failed tests above."
else
# Format output for passing tests
grep -E "(Test Files|Tests|Duration)" test-results.txt | while read -r line; do
if [[ $line == *"Test Files"* ]]; then
echo "๐Ÿ—‚ **Test Summary**: $line"
elif [[ $line == *"Tests"* ]]; then
echo "โœ… **Tests Passed**: $line"
elif [[ $line == *"Duration"* ]]; then
echo "โฑ๏ธ **Total Duration**: $line"
fi
done
echo ""
echo "๐ŸŽ‰ All tests passed successfully!"
echo "โœ… **Tests Passed**: All tests passed successfully!"
fi
echo ""
echo "---"
echo ""
echo "### ๐ŸŽจ Prettier Format Check"
echo ""
if grep -q "(changed)" prettier-results.txt; then
echo "โš ๏ธ **Prettier Issues Found** - Some format issues are fixed automatically by Prettier:"
echo '```'
grep -E "\s+\(changed\)" prettier-results.txt || true
echo '```'
else
echo "โœ… **Prettier**: No formatting issues found!"
fi
echo ""
echo "### ๐ŸŽจ Lint Check"
echo ""
if grep -qE "^[^0]* problems" lint-results.txt; then
echo "โš ๏ธ **Lint Issues Found** - PLEASE FIX THEM!"
echo '```'
cat lint-results.txt
echo '```'
else
echo "โœ… **Lint**: No linting issues found!"
fi
} > formatted-results.txt
Expand Down

0 comments on commit afb5820

Please sign in to comment.