|
| 1 | +name: Nightly Checks |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Runs at 09Z (3am MDT) |
| 6 | + - cron: "0 9 * * 2" |
| 7 | + |
| 8 | + # Allow a manual run |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + # Run if we modify the workflow |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + - .github/workflows/nightly-builds.yml |
| 17 | + - .github/workflows/unstable-builds.yml |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - .github/workflows/nightly-builds.yml |
| 21 | + - .github/workflows/unstable-builds.yml |
| 22 | + |
| 23 | +jobs: |
| 24 | + Builds: |
| 25 | + uses: ./.github/workflows/unstable-builds.yml |
| 26 | + |
| 27 | + Report: |
| 28 | + name: Report |
| 29 | + needs: Builds |
| 30 | + if: failure() || github.event_name == 'pull_request' |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + issues: write |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Download logs |
| 37 | + uses: actions/download-artifact@v4 |
| 38 | + with: |
| 39 | + path: /tmp/workspace/logs |
| 40 | + |
| 41 | + - name: Grab log files |
| 42 | + run: | |
| 43 | + cp /tmp/workspace/logs/log-*/*.log . || true |
| 44 | + touch tests-nightly.log build.log linkchecker.log |
| 45 | +
|
| 46 | + - name: Report failures |
| 47 | + uses: actions/github-script@v7 |
| 48 | + with: |
| 49 | + script: | |
| 50 | + const fs = require('fs'); |
| 51 | + const title = "Nightly build is failing"; |
| 52 | + const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; |
| 53 | + body = `The [Nightly workflow](${workflow_url}) is failing.\n`; |
| 54 | +
|
| 55 | + if ('${{ needs.Builds.outputs.tests_result }}' === 'failure') { |
| 56 | + const test_log = fs.readFileSync('tests-nightly.log', 'utf8').substring(0, 21000); |
| 57 | + body += `The tests failed.\nLog:\n<details><pre>${test_log}</pre></details>`; |
| 58 | + } |
| 59 | + if ('${{ needs.Builds.outputs.docs_result }}' === 'failure') { |
| 60 | + const build_log = fs.readFileSync('build.log', 'utf8').substring(0, 21000); |
| 61 | + const linkchecker = fs.readFileSync('linkchecker.log', 'utf8').substring(0, 21000); |
| 62 | + body += `The documentation build failed.\nLog:\n<details><pre>${build_log}</pre></details>`; |
| 63 | + body += `\nLinkchecker output:\n<details><pre>${linkchecker}</pre></details>`; |
| 64 | + } |
| 65 | +
|
| 66 | + // See if we have an existing issue |
| 67 | + const items = await github.rest.issues.listForRepo({ |
| 68 | + owner: context.repo.owner, |
| 69 | + repo: context.repo.repo, |
| 70 | + state: 'open', |
| 71 | + creator: 'github-actions[bot]' |
| 72 | + }); |
| 73 | + const existing = items.data.filter(i => i.title === title); |
| 74 | +
|
| 75 | + params = { |
| 76 | + owner: context.repo.owner, |
| 77 | + repo: context.repo.repo, |
| 78 | + body: body, |
| 79 | + title: title, |
| 80 | + labels: ['Type: Maintenance'] |
| 81 | + }; |
| 82 | + |
| 83 | + // On PRs, avoid actually issuing an API request, since we don't have permission |
| 84 | + if ( context.eventName === 'pull_request' ) { |
| 85 | + github.hook.wrap('request', (request, options) => { return {}; }) |
| 86 | + } |
| 87 | + |
| 88 | + if (existing.length === 0) { |
| 89 | + console.log('Creating new issue.') |
| 90 | + github.rest.issues.create(params) |
| 91 | + } else { |
| 92 | + params.issue_number = existing[0].number; |
| 93 | + console.log(`Updating existing issue: ${params.issue_number}`) |
| 94 | + github.rest.issues.update(params) |
| 95 | + } |
0 commit comments