diff --git a/shared-overwrite/.github/actions/handle-parse-failure/action.yml b/shared-overwrite/.github/actions/handle-parse-failure/action.yml new file mode 100644 index 00000000..0274dccb --- /dev/null +++ b/shared-overwrite/.github/actions/handle-parse-failure/action.yml @@ -0,0 +1,53 @@ +# ORIGINAL FILE: https://github.com/mtransitapps/commons/tree/master/shared-overwrite +name: MT handle parse failure +description: 'Create a GitHub issue when a parse step fails' +inputs: + step-name: + description: "Name of the failed parse step (e.g. 'MT parse current')" + required: true + run-id: + description: "GitHub Actions run ID" + required: true + github-token: + description: "GitHub token with issue creation permissions" + required: true + +runs: + using: "composite" + steps: + - name: MT create issue for failed parse step + shell: bash + run: | + STEP_NAME="${{ inputs.step-name }}" + RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ inputs.run-id }}" + FAILED_LOGS=$(gh run view ${{ inputs.run-id }} --log-failed 2>&1 || echo "Failed to fetch logs") + HOW_TO_FIX="Need to update \`config/gtfs/*.json\` if available or \`agency-parser/src/main/java/org/mtransit/parser/*/*AgencyTools.java\` to fix. +Look at [parser](https://github.com/mtransitapps/parser) repository for available options in [\`src/main/java/org/mtransit/parser/config/gtfs/data/*Config.kt\`](https://github.com/mtransitapps/parser/tree/master/src/main/java/org/mtransit/parser/config/gtfs/data) and [\`src/main/java/org/mtransit/parser/DefaultAgencyTools.java\`](https://github.com/mtransitapps/parser/blob/master/src/main/java/org/mtransit/parser/DefaultAgencyTools.java) +Open a **draft** pull request when ready. +Notify \`@mtransitapps/reviewers\` in the pull request comment" + ISSUE_BODY="## ${STEP_NAME} failed + +**Run:** [${STEP_NAME} - ${{ inputs.run-id }}](${RUN_URL}) +**Raw logs:** ${RUN_URL} (see failed step) + +
+Failed step logs + +\`\`\` +${FAILED_LOGS} +\`\`\` + +
+ +## How to fix + +${HOW_TO_FIX}" + ISSUE_URL=$(gh issue create \ + --title "${STEP_NAME} failed" \ + --type "Bug" \ + --label "bug" \ + --body "${ISSUE_BODY}" \ + --assignee "copilot") + gh issue comment "${ISSUE_URL}" --body "@mtransitapps/reviewers please review" + env: + GH_TOKEN: ${{ inputs.github-token }} diff --git a/shared-overwrite/.github/workflows/mt-sync-code-data.yml b/shared-overwrite/.github/workflows/mt-sync-code-data.yml index edd0b2a0..39e6a08d 100644 --- a/shared-overwrite/.github/workflows/mt-sync-code-data.yml +++ b/shared-overwrite/.github/workflows/mt-sync-code-data.yml @@ -123,15 +123,33 @@ jobs: echo "Schedule files deletion completed."; - name: MT parse current + id: mt-parse-current if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} timeout-minutes: 40 run: ./parse_current.sh + - name: MT parse current failed - create issue + if: ${{ failure() && steps.mt-parse-current.outcome == 'failure' }} + uses: ./.github/actions/handle-parse-failure + with: + step-name: "MT parse current" + run-id: ${{ github.run_id }} + github-token: ${{ secrets.MT_PAT }} + - name: MT parse next + id: mt-parse-next if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} timeout-minutes: 40 run: ./parse_next.sh + - name: MT parse next failed - create issue + if: ${{ failure() && steps.mt-parse-next.outcome == 'failure' }} + uses: ./.github/actions/handle-parse-failure + with: + step-name: "MT parse next" + run-id: ${{ github.run_id }} + github-token: ${{ secrets.MT_PAT }} + - name: MT parse list change if: ${{ env.MT_IS_AGENCY_BIKE != 'true' && env.MT_IS_MAIN_REPO != 'true' }} run: ./parse_list_change.sh