fix: Use correct error type from hono's error response (#40) #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Test Pipeline 🛠️ | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
issues: write | |
steps: | |
# 🛎️ Checkout repository | |
- name: 🛎️ Checkout repository | |
uses: actions/checkout@v4 | |
# 🔧 Set up Node.js | |
- name: 🔧 Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' # Use LTS version of Node.js | |
# 📦 Install Yarn | |
- name: 📦 Install Yarn | |
run: corepack enable && yarn set version stable | |
# 📥 Install dependencies | |
- name: 📥 Install dependencies | |
run: yarn install | |
# 🚨 Run Lint check | |
- name: 🚨 Run Lint | |
run: yarn run lint | tee lint-results.txt | |
# 🎨 Run Prettier format check | |
- name: 🎨 Run Prettier | |
run: yarn run format | tee prettier-results.txt | |
# 🧪 Run tests | |
- name: 🧪 Run tests | |
run: yarn 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 | |
# 📄 Format all results for better readability | |
- name: 📄 Format all results | |
run: | | |
{ | |
echo "### 🧪 Test Results" | |
echo "" | |
if grep -q "failed" test-results.txt; then | |
echo "❌ **Some tests failed**:" | |
echo '```' | |
grep -E "Test Files|Tests|Duration|failed" test-results.txt | |
echo '```' | |
echo "💥 Please review the failed tests above." | |
else | |
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 | |
# 💬 Post all results to PR | |
- name: 💬 Comment results | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const allResults = fs.readFileSync('formatted-results.txt', 'utf8'); | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: allResults | |
}); |