Skip to content

Add Koa: async/await Node.js framework by the Express team (~36k ⭐) #159

Add Koa: async/await Node.js framework by the Express team (~36k ⭐)

Add Koa: async/await Node.js framework by the Express team (~36k ⭐) #159

Workflow file for this run

name: PR Commands
on:
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: write
actions: write
jobs:
handle-command:
if: github.event.issue.pull_request && (contains(github.event.comment.body, '/validate') || contains(github.event.comment.body, '/benchmark'))
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
fetch-depth: 0
- name: Parse command
id: parse
run: |
PR="$PR_NUMBER"
echo "pr=$PR" >> "$GITHUB_OUTPUT"
# Detect changed frameworks from PR files via API (most reliable)
FRAMEWORKS=$(gh api "/repos/$REPO/pulls/$PR/files" --jq '.[].filename' | grep '^frameworks/' | cut -d'/' -f2 | sort -u | head -1)
echo "framework=$FRAMEWORKS" >> "$GITHUB_OUTPUT"
echo "Detected framework: $FRAMEWORKS"
if echo "$COMMENT_BODY" | grep -q '/benchmark'; then
echo "command=benchmark" >> "$GITHUB_OUTPUT"
# Extract optional profile: /benchmark baseline
PROFILE=$(echo "$COMMENT_BODY" | grep -oP '/benchmark\s+\K\S+' || echo "")
echo "profile=$PROFILE" >> "$GITHUB_OUTPUT"
elif echo "$COMMENT_BODY" | grep -q '/validate'; then
echo "command=validate" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_BODY: ${{ github.event.comment.body }}
PR_NUMBER: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
- name: React to comment
run: |
gh api "/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" -f content="rocket"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run validate
if: steps.parse.outputs.command == 'validate' && steps.parse.outputs.framework != ''
run: |
FRAMEWORK="${{ steps.parse.outputs.framework }}"
echo "Validating $FRAMEWORK..."
if ./scripts/validate.sh "$FRAMEWORK" 2>&1 | tee /tmp/validate.log; then
STATUS="✅ Validation **passed** for \`$FRAMEWORK\`"
else
STATUS="❌ Validation **failed** for \`$FRAMEWORK\`"
fi
BODY="$STATUS"$'\n\n'"<details><summary>Full log</summary>"$'\n\n```\n'"$(tail -100 /tmp/validate.log)"$'\n```\n</details>'
gh pr comment "${{ steps.parse.outputs.pr }}" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run benchmark
if: steps.parse.outputs.command == 'benchmark' && steps.parse.outputs.framework != ''
run: |
gh workflow run benchmark-pr.yml \
-f pr=${{ steps.parse.outputs.pr }} \
-f framework=${{ steps.parse.outputs.framework }} \
-f profile="${{ steps.parse.outputs.profile }}"
gh pr comment "${{ steps.parse.outputs.pr }}" --body "🚀 Benchmark run triggered for \`${{ steps.parse.outputs.framework }}\`${{ steps.parse.outputs.profile && format(' (profile: {0})', steps.parse.outputs.profile) || ' (all profiles)' }}. Results will be posted here when done."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: No framework detected
if: steps.parse.outputs.framework == ''
run: |
gh pr comment "${{ steps.parse.outputs.pr }}" --body "⚠️ Couldn't detect which framework to test. Make sure the PR modifies files under \`frameworks/<name>/\`."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}