SCRAPE-10: Implement recordScraperRun() for scraper_runs #15

Merged
stephen merged 3 commits from scraper/record-run into dev 2026-02-06 02:00:20 -07:00
3 changed files with 369 additions and 16 deletions
Showing only changes of commit 74dc62c53f - Show all commits

View File

@ -109,11 +109,23 @@ jobs:
steps: steps:
- name: Send results to n8n webhook - name: Send results to n8n webhook
env:
LINT_STATUS: ${{ needs.lint.result }}
TEST_STATUS: ${{ needs.test.result }}
RAW_LINT_OUTPUT: ${{ needs.lint.outputs.output }}
RAW_TEST_OUTPUT: ${{ needs.test.outputs.output }}
GH_REPO: ${{ github.repository }}
GH_BRANCH: ${{ github.head_ref || github.ref_name }}
GH_SHA: ${{ github.sha }}
GH_COMMIT_MSG: ${{ github.event.head_commit.message || github.event.pull_request.title || 'N/A' }}
GH_ACTOR: ${{ github.actor }}
GH_EVENT: ${{ github.event_name }}
GH_PR_NUMBER: ${{ github.event.pull_request.number || '' }}
GH_RUN_ID: ${{ github.run_id }}
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
WEBHOOK_URL: ${{ secrets.N8N_WEBHOOK_URL }}
run: | run: |
# Determine overall status # Determine overall status
LINT_STATUS="${{ needs.lint.result }}"
TEST_STATUS="${{ needs.test.result }}"
if [ "$LINT_STATUS" = "success" ] && [ "$TEST_STATUS" = "success" ]; then if [ "$LINT_STATUS" = "success" ] && [ "$TEST_STATUS" = "success" ]; then
OVERALL_STATUS="success" OVERALL_STATUS="success"
else else
@ -121,21 +133,21 @@ jobs:
fi fi
# Truncate outputs if too long (max 10000 chars each) # Truncate outputs if too long (max 10000 chars each)
LINT_OUTPUT=$(echo '${{ needs.lint.outputs.output }}' | head -c 10000) LINT_OUTPUT=$(echo "$RAW_LINT_OUTPUT" | head -c 10000)
TEST_OUTPUT=$(echo '${{ needs.test.outputs.output }}' | head -c 10000) TEST_OUTPUT=$(echo "$RAW_TEST_OUTPUT" | head -c 10000)
# Build JSON payload # Build JSON payload
PAYLOAD=$(jq -n \ PAYLOAD=$(jq -n \
--arg repo "${{ github.repository }}" \ --arg repo "$GH_REPO" \
--arg branch "${{ github.head_ref || github.ref_name }}" \ --arg branch "$GH_BRANCH" \
--arg commit "${{ github.sha }}" \ --arg commit "$GH_SHA" \
--arg commit_short "$(echo '${{ github.sha }}' | cut -c1-7)" \ --arg commit_short "${GH_SHA:0:7}" \
--arg commit_message "${{ github.event.head_commit.message || github.event.pull_request.title || 'N/A' }}" \ --arg commit_message "$GH_COMMIT_MSG" \
--arg author "${{ github.actor }}" \ --arg author "$GH_ACTOR" \
--arg event "${{ github.event_name }}" \ --arg event "$GH_EVENT" \
--arg pr_number "${{ github.event.pull_request.number || '' }}" \ --arg pr_number "$GH_PR_NUMBER" \
--arg run_id "${{ github.run_id }}" \ --arg run_id "$GH_RUN_ID" \
--arg run_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ --arg run_url "$GH_RUN_URL" \
--arg overall_status "$OVERALL_STATUS" \ --arg overall_status "$OVERALL_STATUS" \
--arg lint_status "$LINT_STATUS" \ --arg lint_status "$LINT_STATUS" \
--arg lint_output "$LINT_OUTPUT" \ --arg lint_output "$LINT_OUTPUT" \
@ -175,7 +187,7 @@ jobs:
curl -X POST \ curl -X POST \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$PAYLOAD" \ -d "$PAYLOAD" \
"${{ secrets.N8N_WEBHOOK_URL }}" \ "$WEBHOOK_URL" \
--fail --silent --show-error --fail --silent --show-error
- name: Fail if lint or tests failed - name: Fail if lint or tests failed