|
| 1 | +name: weekly checks |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 6 * * 1" |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + simulate_failure: |
| 9 | + description: "Skip the checks, fail on purpose, and open a test tracking issue" |
| 10 | + required: false |
| 11 | + default: false |
| 12 | + type: boolean |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + dependency-prereleases: |
| 19 | + if: ${{ !inputs.simulate_failure }} |
| 20 | + name: dependency pre-releases py3.12 |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + |
| 26 | + - uses: astral-sh/setup-uv@v7 |
| 27 | + with: |
| 28 | + python-version: "3.12" |
| 29 | + activate-environment: true |
| 30 | + |
| 31 | + - name: Install with pre-releases allowed |
| 32 | + run: uv pip install --prerelease allow . "pytest>=8" |
| 33 | + |
| 34 | + # `-o filterwarnings`, not `-W`: `-W` matches the module name exactly and would miss every submodule |
| 35 | + - name: Test |
| 36 | + run: | |
| 37 | + pytest tests -o $'filterwarnings=error::DeprecationWarning:dlccore\nerror::FutureWarning:dlccore' |
| 38 | +
|
| 39 | + build-release: |
| 40 | + if: ${{ !inputs.simulate_failure }} |
| 41 | + uses: ./.github/workflows/build_release.yml |
| 42 | + |
| 43 | + simulate-failure: |
| 44 | + if: ${{ inputs.simulate_failure }} |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - run: exit 1 |
| 48 | + |
| 49 | + notify: |
| 50 | + # A job of its own: a step-level `if: failure()` never runs when its job dies before reaching it |
| 51 | + needs: [dependency-prereleases, build-release, simulate-failure] |
| 52 | + if: failure() && (github.event_name == 'schedule' || inputs.simulate_failure) |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + contents: read |
| 56 | + issues: write |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Open or update the tracking issue |
| 60 | + env: |
| 61 | + GH_TOKEN: ${{ github.token }} |
| 62 | + REPO: ${{ github.repository }} |
| 63 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 64 | + PRERELEASE_RESULT: ${{ needs['dependency-prereleases'].result }} |
| 65 | + BUILD_RESULT: ${{ needs['build-release'].result }} |
| 66 | + SIMULATED: ${{ inputs.simulate_failure }} |
| 67 | + run: | |
| 68 | + set -euo pipefail |
| 69 | + if [ "$SIMULATED" = "true" ]; then |
| 70 | + title="Weekly checks failing (notification test)" |
| 71 | + label="weekly checks test" |
| 72 | + banner="> **Test.** Opened by a manual dispatch with *simulate_failure*; nothing is broken. Close it." |
| 73 | + else |
| 74 | + title="Weekly checks failing" |
| 75 | + label="weekly checks" |
| 76 | + banner="" |
| 77 | + fi |
| 78 | + gh label create "$label" --repo "$REPO" --color B60205 \ |
| 79 | + --description "Tracking issue for the weekly CI checks" --force |
| 80 | +
|
| 81 | + summary=$(printf '%s\n' \ |
| 82 | + "| Check | Result |" \ |
| 83 | + "| --- | --- |" \ |
| 84 | + "| dependency pre-releases | $PRERELEASE_RESULT |" \ |
| 85 | + "| build and test release | $BUILD_RESULT |") |
| 86 | +
|
| 87 | + existing=$(gh issue list --repo "$REPO" --state open --label "$label" --json number --jq '.[0].number // empty') |
| 88 | + if [ -n "$existing" ]; then |
| 89 | + gh issue comment "$existing" --repo "$REPO" --body "$(printf '%s\n' "Still failing: [run $GITHUB_RUN_ID]($RUN_URL)" "" "$summary")" |
| 90 | + else |
| 91 | + body=$(printf '%s\n' \ |
| 92 | + "Weekly checks failed: [run $GITHUB_RUN_ID]($RUN_URL)" \ |
| 93 | + "" \ |
| 94 | + "$summary" \ |
| 95 | + "" \ |
| 96 | + "These run against dependency pre-releases and the built wheel: a failure is usually an upstream change or a packaging problem, not a regression from a PR." \ |
| 97 | + "" \ |
| 98 | + "## Resolving" \ |
| 99 | + "" \ |
| 100 | + "1. Fix the failing job on a branch." \ |
| 101 | + "2. Re-run the check on that branch: Actions -> build and test release -> Run workflow, or Actions -> weekly checks -> Run workflow." \ |
| 102 | + "3. Merge the fix, dispatch Actions -> weekly checks on main, and close this issue. While it is open, later failures are added as comments.") |
| 103 | + if [ -n "$banner" ]; then |
| 104 | + body=$(printf '%s\n' "$banner" "" "$body") |
| 105 | + fi |
| 106 | + gh issue create --repo "$REPO" --title "$title" --body "$body" --label "$label" |
| 107 | + fi |
0 commit comments