Patchwork checker #3936
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) 2025 Andrea Cervesato <andrea.cervesato@suse.com> | |
| name: "Patchwork checker" | |
| on: | |
| push: | |
| schedule: | |
| - cron: '*/15 * * * *' | |
| env: | |
| PATCHWORK_CI_FILE: patchwork-ci-output.txt | |
| jobs: | |
| checker: | |
| if: ${{ github.repository == 'linux-test-project/ltp' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@v1 | |
| - name: Get last successful run timestamp | |
| id: last_run | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const runs = await github.rest.actions.listWorkflowRuns({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'ci-patchwork-trigger.yml', | |
| status: 'success', | |
| per_page: 1, | |
| exclude_pull_requests: true, | |
| }); | |
| if (runs.data.workflow_runs.length > 0) { | |
| const since = runs.data.workflow_runs[0].run_started_at; | |
| console.log(`Last successful run: ${since}`); | |
| core.exportVariable('PATCHWORK_SINCE_DATE', since); | |
| } else { | |
| console.log('No previous successful run found, using default lookback'); | |
| } | |
| - name: Verify new patches | |
| id: verify | |
| run: | | |
| ./ci/tools/patchwork.sh verify > "$PATCHWORK_CI_FILE" | |
| cat "$PATCHWORK_CI_FILE" | |
| - name: Run tests | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const output = fs.readFileSync(process.env.PATCHWORK_CI_FILE, 'utf8'); | |
| if (output.length === 0) { | |
| console.log("'patchwork-ci.sh verify' output is empty"); | |
| return; | |
| } | |
| const lines = output.split('\n'); | |
| if (lines.length === 0) { | |
| console.log("No new patch-series found"); | |
| return; | |
| } | |
| const workflows = [ | |
| 'ci-docker-build.yml', | |
| 'ci-sphinx-doc.yml' | |
| ]; | |
| for (const data of lines) { | |
| const [series_id, series_mbox] = data.split('|'); | |
| if (series_id.length === 0 || series_mbox.length === 0) { | |
| console.log(`Malformed data: ${data}`); | |
| continue; | |
| } | |
| for (const workflow of workflows) { | |
| const response = await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: context.ref, | |
| workflow_id: workflow, | |
| inputs: { | |
| SERIES_ID: series_id, | |
| SERIES_MBOX: series_mbox, | |
| } | |
| }); | |
| console.log(response); | |
| }; | |
| } |