Packages Daily Check #8
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
| name: Packages Daily Check | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| timezone: "Asia/Shanghai" | |
| workflow_dispatch: | |
| inputs: | |
| create_failure_issue: | |
| description: Create or update the failure issue when this manual run fails | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: {} | |
| concurrency: | |
| group: packages-daily-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| tools-check: | |
| if: ${{ github.repository == 'RT-Thread/packages' }} | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/aciont_tool.yml | |
| daily-url-check: | |
| if: ${{ github.repository == 'RT-Thread/packages' }} | |
| name: URL shard ${{ matrix.label }} | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 8 | |
| matrix: | |
| include: | |
| - shard_index: 0 | |
| label: "1/8" | |
| - shard_index: 1 | |
| label: "2/8" | |
| - shard_index: 2 | |
| label: "3/8" | |
| - shard_index: 3 | |
| label: "4/8" | |
| - shard_index: 4 | |
| label: "5/8" | |
| - shard_index: 5 | |
| label: "6/8" | |
| - shard_index: 6 | |
| label: "7/8" | |
| - shard_index: 7 | |
| label: "8/8" | |
| permissions: | |
| contents: read | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Install URL checker dependencies | |
| run: python -m pip install requests | |
| - name: Validate package URLs and metadata | |
| run: python ci.py --shard-count 8 --shard-index ${{ matrix.shard_index }} | |
| report-daily-failure: | |
| needs: | |
| - daily-url-check | |
| - tools-check | |
| if: ${{ always() && github.repository == 'RT-Thread/packages' && (github.event_name == 'schedule' || inputs.create_failure_issue) && (needs.daily-url-check.result == 'failure' || needs.tools-check.result == 'failure') }} | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| actions: read | |
| issues: write | |
| steps: | |
| - name: Create or update failure issue | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const marker = '<!-- daily-packages-check -->'; | |
| const title = '[CI] Daily packages check failed'; | |
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const urlResult = '${{ needs.daily-url-check.result }}'; | |
| const toolsResult = '${{ needs.tools-check.result }}'; | |
| const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.runId, | |
| filter: 'latest', | |
| per_page: 100, | |
| }); | |
| const failedJobs = jobs | |
| .filter((job) => job.conclusion === 'failure') | |
| .slice(0, 20) | |
| .map((job) => ` - [${job.name}](${job.html_url})`); | |
| const details = [ | |
| marker, | |
| '@CYFS3 @Rbb666', | |
| '', | |
| '每日软件包 URL/元数据检查失败,请协助处理。', | |
| '', | |
| `- URL/元数据检查:${urlResult}`, | |
| `- ToolsCI:${toolsResult}`, | |
| `- Commit:${context.sha}`, | |
| `- 运行记录:${runUrl}`, | |
| '', | |
| '失败 Jobs:', | |
| ...(failedJobs.length ? failedJobs : [' - 请查看运行记录中的失败步骤。']), | |
| ].join('\n'); | |
| const issues = await github.paginate(github.rest.issues.listForRepo, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| per_page: 100, | |
| }); | |
| const existing = issues.find((issue) => | |
| !issue.pull_request && issue.title === title && issue.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: existing.number, | |
| body: details, | |
| }); | |
| } else { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title, | |
| body: details, | |
| }); | |
| } |