test(ci): verify reviewdog functionality #780
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: Code Quality | |
on: | |
push: | |
branches: [dev] | |
pull_request: | |
branches: [main, dev] | |
types: [opened, synchronize, reopened] | |
jobs: | |
quality-checks: | |
name: Quality Checks | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 # Prevent hanging jobs | |
permissions: | |
id-token: write # Needed for auth with Deno Deploy | |
contents: read # Needed to clone the repository | |
pull-requests: write # Needed for PR comments | |
env: | |
CSRF_SECRET_KEY: "12323" # Placeholder key | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Cache npm dependencies | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install npm dependencies | |
run: npm ci # More reliable than npm install | |
- name: Validate OpenAPI Schema | |
run: npm run validate:ci | |
# Cache Deno dependencies | |
- name: Setup Deno | |
uses: denoland/setup-deno@v2 | |
with: | |
deno-version: v2.1.4 | |
- name: Cache Deno dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.deno | |
~/.cache/deno | |
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }} | |
restore-keys: | | |
${{ runner.os }}-deno- | |
- name: Install reviewdog | |
uses: reviewdog/action-setup@v1 | |
with: | |
reviewdog_version: latest | |
# Code Quality Checks | |
- name: Check formatting | |
id: fmt | |
if: always() | |
run: | | |
deno task check:fmt > fmt_output.txt || true | |
echo "Formatting check output:" | |
cat fmt_output.txt | |
- name: Check linting | |
id: lint | |
if: always() | |
run: | | |
deno task check:lint > lint_output.txt || true | |
echo "Lint check output:" | |
cat lint_output.txt | |
- name: Run reviewdog | |
if: always() | |
run: | | |
# Process and report formatting issues | |
echo "Processing format issues..." | |
current_file="" | |
while IFS= read -r line; do | |
if [[ $line =~ ^from[[:space:]](.+): ]]; then | |
current_file="${BASH_REMATCH[1]}" | |
echo "Processing file: $current_file" | |
elif [[ $line =~ ^[[:space:]]*[0-9]+[[:space:]]*\| ]]; then | |
line_num=$(echo "$line" | grep -o '^[[:space:]]*[0-9]\+' | tr -d ' ') | |
echo "$current_file:$line_num:1:[deno-fmt] Formatting issue detected" >> fmt_processed.txt | |
fi | |
done < fmt_output.txt | |
# Process and report linting issues | |
echo "Processing lint issues..." | |
while IFS= read -r line; do | |
if [[ $line =~ ^error:[[:space:]](.+) ]]; then | |
error_msg="${BASH_REMATCH[1]}" | |
read -r file_line | |
if [[ $file_line =~ ^[[:space:]]*at[[:space:]](.+:[0-9]+:[0-9]+) ]]; then | |
file_info="${BASH_REMATCH[1]}" | |
echo "$file_info: $error_msg" >> lint_processed.txt | |
fi | |
fi | |
done < lint_output.txt | |
# Debug output | |
echo "=== Debug: Processed Files ===" | |
echo "fmt_processed.txt contents:" | |
cat fmt_processed.txt || echo "No formatting issues found" | |
echo "lint_processed.txt contents:" | |
cat lint_processed.txt || echo "No linting issues found" | |
echo "=== End Debug ===" | |
# Report formatting issues | |
if [ -f fmt_processed.txt ]; then | |
echo "Sending formatting issues to ReviewDog..." | |
cat fmt_processed.txt | reviewdog -f=golint -name=deno-fmt -reporter=github-pr-review -filter-mode=file -level=warning -tee | |
fi | |
# Report linting issues | |
if [ -f lint_processed.txt ]; then | |
echo "Sending linting issues to ReviewDog..." | |
cat lint_processed.txt | reviewdog -f=golint -name=deno-lint -reporter=github-pr-review -filter-mode=file -level=warning -tee | |
fi | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REVIEWDOG_DEBUG: 1 | |
# Fail the workflow if any checks failed | |
- name: Check for failures | |
if: steps.fmt.outcome == 'failure' || steps.lint.outcome == 'failure' | |
run: exit 1 | |
# Build check | |
- name: Build project | |
run: deno task build | |
# Commented out for future implementation | |
# - name: Type check | |
# run: deno task check:types | |
# continue-on-error: true # Optional: allow type checks to fail for now |