diff --git a/.github/upstream-failure-issue-template.md b/.github/upstream-failure-issue-template.md new file mode 100644 index 000000000..4b6a58fe8 --- /dev/null +++ b/.github/upstream-failure-issue-template.md @@ -0,0 +1,11 @@ +# Upstream testing failure + +**Workflow:** {{WORKFLOW}} +**Run:** [{{RUN_ID}}]({{RUN_URL}}) +**Date:** {{DATE}} + +Upstream testing has failed. + +Please check the [workflow run]({{RUN_URL}}) for details. + +This issue was automatically generated from the CI Upstream workflow. diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml index 51a7d8b28..fb40d888c 100644 --- a/.github/workflows/upstream-dev-ci.yml +++ b/.github/workflows/upstream-dev-ci.yml @@ -12,13 +12,16 @@ jobs: upstream-dev: name: upstream-dev runs-on: ubuntu-latest + continue-on-error: true defaults: run: shell: bash -l {0} strategy: fail-fast: false matrix: - python-version: [ "3.12" ] + python-version: [ "3.13" ] + outputs: + testresults: ${{ steps.tests.outcome }} steps: - name: Checkout @@ -50,5 +53,66 @@ jobs: conda list - name: Running Tests + id: tests run: | python -m pytest test -v --cov=./uxarray --cov-report=xml + + failure-issue: + name: failure-issue + needs: [upstream-dev] + if: | + needs.upstream-dev.testresults != 'success' + && github.repository == 'UXARRAY/uxarray' + && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - name: checkout + uses: actions/checkout@v6.0.2 + + - name: Create or update failure issue + shell: bash + run: | + # Read the template + template=$(cat .github/upstream-failure-issue-template.md) + + # Replace placeholders + issue_body="${template//\{\{WORKFLOW\}\}/${{ github.workflow }}}" + issue_body="${issue_body//\{\{RUN_ID\}\}/${{ github.run_id }}}" + issue_body="${issue_body//\{\{RUN_URL\}\}/${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}}" + issue_body="${issue_body//\{\{DATE\}\}/$(date -u)}" + + # Check for existing open issue with same title + issue_title="🤖 Upstream testing failure" + existing_issue=$(gh issue list --state open --label "CI" --search "\"$issue_title\" in:title" --json number --jq '.[0].number // empty') + + if [ -n "$existing_issue" ]; then + echo "Found existing open issue #$existing_issue, updating it..." + echo "$issue_body" | gh issue edit "$existing_issue" --body-file - + echo "Updated existing issue #$existing_issue" + else + echo "No existing open issue found, creating new one..." + echo "$issue_body" | gh issue create \ + --title "$issue_title" \ + --body-file - \ + --label "CI" + echo "Created new issue" + fi + env: + GH_TOKEN: ${{ github.token }} + + report-failed: + name: report-failed + needs: [ upstream-dev, failure-issue ] + if: ${{needs.upstream-dev.outputs.testresults != 'success'}} + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - name: make sure to report a failed workflow + shell: bash + run: | + exit 1;