Commit 66d9970144
Unsigned
Layout: unified · split
.github/workflows/pr-check.yml +103 −29
| @@ -10,65 +10,131 @@ permissions: | ||
| 10 | 10 | pull-requests: read |
| 11 | 11 | |
| 12 | 12 | jobs: |
| 13 | check-pr: | |
| 14 | name: Check PR | |
| 13 | detect-changes: | |
| 14 | name: Detect changes | |
| 15 | 15 | runs-on: ubuntu-latest |
| 16 | ||
| 16 | outputs: | |
| 17 | yaml_changed: ${{ steps.changes.outputs.yaml_changed }} | |
| 18 | non_yaml_changed: ${{ steps.changes.outputs.non_yaml_changed }} | |
| 17 | 19 | steps: |
| 18 | 20 | - uses: actions/checkout@v4 |
| 19 | 21 | with: |
| 20 | 22 | fetch-depth: 0 |
| 21 | ||
| 22 | - name: Fetch base ref | |
| 23 | run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | |
| 24 | ||
| 23 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | |
| 25 | 24 | - uses: actions/setup-python@v5 |
| 26 | 25 | with: |
| 27 | 26 | python-version: "3.12" |
| 28 | ||
| 29 | 27 | - run: pip install -q -r lib/requirements.txt |
| 30 | ||
| 31 | 28 | - name: Detect changed files |
| 32 | 29 | id: changes |
| 33 | 30 | run: python lib/checks/detect-changes.py --base-ref ${{ github.event.pull_request.base.sha }} |
| 31 | - name: Non-YAML changes warning | |
| 32 | if: steps.changes.outputs.non_yaml_changed == 'true' | |
| 33 | run: python lib/checks/warn-non-yaml.py --base-ref ${{ github.event.pull_request.base.sha }} | |
| 34 | 34 | |
| 35 | readme: | |
| 36 | name: README edits | |
| 37 | runs-on: ubuntu-latest | |
| 38 | steps: | |
| 39 | - uses: actions/checkout@v4 | |
| 40 | with: | |
| 41 | fetch-depth: 0 | |
| 42 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | |
| 43 | - uses: actions/setup-python@v5 | |
| 44 | with: | |
| 45 | python-version: "3.12" | |
| 46 | - run: pip install -q -r lib/requirements.txt | |
| 35 | 47 | - name: Check for direct README edits |
| 36 | id: readme | |
| 37 | 48 | run: python lib/checks/check-readme-edits.py --base-ref ${{ github.event.pull_request.base.sha }} |
| 38 | 49 | |
| 39 | - name: Schema validation | |
| 40 | id: schema | |
| 41 | if: steps.changes.outputs.yaml_changed == 'true' | |
| 50 | schema: | |
| 51 | name: Schema validation | |
| 52 | needs: detect-changes | |
| 53 | if: needs.detect-changes.outputs.yaml_changed == 'true' | |
| 54 | runs-on: ubuntu-latest | |
| 55 | steps: | |
| 56 | - uses: actions/checkout@v4 | |
| 57 | - uses: actions/setup-python@v5 | |
| 58 | with: | |
| 59 | python-version: "3.12" | |
| 60 | - run: pip install -q -r lib/requirements.txt | |
| 61 | - name: Validate schema | |
| 42 | 62 | run: make validate |
| 43 | 63 | |
| 64 | diff: | |
| 65 | name: Single-entry rule | |
| 66 | needs: detect-changes | |
| 67 | if: needs.detect-changes.outputs.yaml_changed == 'true' | |
| 68 | runs-on: ubuntu-latest | |
| 69 | outputs: | |
| 70 | has_service_changes: ${{ steps.diff.outputs.has_service_changes }} | |
| 71 | steps: | |
| 72 | - uses: actions/checkout@v4 | |
| 73 | with: | |
| 74 | fetch-depth: 0 | |
| 75 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | |
| 76 | - uses: actions/setup-python@v5 | |
| 77 | with: | |
| 78 | python-version: "3.12" | |
| 79 | - run: pip install -q -r lib/requirements.txt | |
| 44 | 80 | - name: YAML diff analysis |
| 45 | 81 | id: diff |
| 46 | if: steps.changes.outputs.yaml_changed == 'true' | |
| 47 | 82 | run: python lib/checks/check-yaml-diff.py --base-ref ${{ github.event.pull_request.base.sha }} |
| 48 | ||
| 49 | - name: Link validation | |
| 50 | if: steps.changes.outputs.yaml_changed == 'true' && steps.diff.outputs.has_service_changes == 'true' | |
| 83 | - name: Upload diff data | |
| 84 | if: always() | |
| 85 | uses: actions/upload-artifact@v4 | |
| 86 | with: | |
| 87 | name: pr-diff | |
| 88 | path: /tmp/pr-diff.json | |
| 89 | if-no-files-found: ignore | |
| 90 | ||
| 91 | links: | |
| 92 | name: Link validation | |
| 93 | needs: diff | |
| 94 | if: needs.diff.result == 'success' && needs.diff.outputs.has_service_changes == 'true' | |
| 95 | runs-on: ubuntu-latest | |
| 96 | steps: | |
| 97 | - uses: actions/checkout@v4 | |
| 98 | - uses: actions/setup-python@v5 | |
| 99 | with: | |
| 100 | python-version: "3.12" | |
| 101 | - run: pip install -q -r lib/requirements.txt | |
| 102 | - name: Download diff data | |
| 103 | uses: actions/download-artifact@v4 | |
| 104 | with: | |
| 105 | name: pr-diff | |
| 106 | path: /tmp | |
| 107 | - name: Validate links | |
| 51 | 108 | run: python lib/checks/check-links.py --diff-json /tmp/pr-diff.json |
| 52 | 109 | |
| 110 | template: | |
| 111 | name: PR template | |
| 112 | runs-on: ubuntu-latest | |
| 113 | steps: | |
| 114 | - uses: actions/checkout@v4 | |
| 115 | - uses: actions/setup-python@v5 | |
| 116 | with: | |
| 117 | python-version: "3.12" | |
| 118 | - run: pip install -q -r lib/requirements.txt | |
| 53 | 119 | - name: PR template check |
| 54 | id: template | |
| 55 | 120 | env: |
| 56 | 121 | PR_BODY: ${{ github.event.pull_request.body }} |
| 57 | 122 | run: python lib/checks/check-template.py |
| 58 | 123 | |
| 59 | - name: Non-YAML changes warning | |
| 60 | if: steps.changes.outputs.non_yaml_changed == 'true' | |
| 61 | run: python lib/checks/warn-non-yaml.py --base-ref ${{ github.event.pull_request.base.sha }} | |
| 62 | ||
| 124 | comment: | |
| 125 | name: Summary | |
| 126 | if: always() | |
| 127 | needs: [readme, schema, diff, links, template] | |
| 128 | runs-on: ubuntu-latest | |
| 129 | steps: | |
| 63 | 130 | - name: Save PR metadata |
| 64 | if: always() | |
| 65 | 131 | run: | |
| 66 | 132 | mkdir -p /tmp/pr-meta |
| 67 | 133 | echo "${{ github.event.pull_request.number }}" > /tmp/pr-meta/number.txt |
| 68 | 134 | echo "${{ github.run_id }}" > /tmp/pr-meta/run-id.txt |
| 69 | 135 | |
| 70 | 136 | - name: Build failure comment |
| 71 | if: failure() | |
| 137 | if: contains(needs.*.result, 'failure') | |
| 72 | 138 | run: | |
| 73 | 139 | cat > /tmp/pr-meta/comment.md << 'HEADER' |
| 74 | 140 | <!-- pr-check-bot --> |
| @@ -76,7 +142,7 @@ jobs: | ||
| 76 | 142 | > ## PR check failed |
| 77 | 143 | HEADER |
| 78 | 144 | |
| 79 | if [ "${{ steps.readme.outcome }}" = "failure" ]; then | |
| 145 | if [ "${{ needs.readme.result }}" = "failure" ]; then | |
| 80 | 146 | cat >> /tmp/pr-meta/comment.md << 'EOF' |
| 81 | 147 | |
| 82 | 148 | ### Direct README edits |
| @@ -85,7 +151,7 @@ jobs: | ||
| 85 | 151 | EOF |
| 86 | 152 | fi |
| 87 | 153 | |
| 88 | if [ "${{ steps.schema.outcome }}" = "failure" ]; then | |
| 154 | if [ "${{ needs.schema.result }}" = "failure" ]; then | |
| 89 | 155 | cat >> /tmp/pr-meta/comment.md << 'EOF' |
| 90 | 156 | |
| 91 | 157 | ### Schema validation failed |
| @@ -94,7 +160,7 @@ jobs: | ||
| 94 | 160 | EOF |
| 95 | 161 | fi |
| 96 | 162 | |
| 97 | if [ "${{ steps.diff.outcome }}" = "failure" ]; then | |
| 163 | if [ "${{ needs.diff.result }}" = "failure" ]; then | |
| 98 | 164 | cat >> /tmp/pr-meta/comment.md << 'EOF' |
| 99 | 165 | |
| 100 | 166 | ### Single-entry rule |
| @@ -103,7 +169,16 @@ jobs: | ||
| 103 | 169 | EOF |
| 104 | 170 | fi |
| 105 | 171 | |
| 106 | if [ "${{ steps.template.outcome }}" = "failure" ]; then | |
| 172 | if [ "${{ needs.links.result }}" = "failure" ]; then | |
| 173 | cat >> /tmp/pr-meta/comment.md << 'EOF' | |
| 174 | ||
| 175 | ### Link validation failed | |
| 176 | One or more URLs in your entry could not be verified. | |
| 177 | Please ensure all links are correct and accessible. | |
| 178 | EOF | |
| 179 | fi | |
| 180 | ||
| 181 | if [ "${{ needs.template.result }}" = "failure" ]; then | |
| 107 | 182 | cat >> /tmp/pr-meta/comment.md << 'EOF' |
| 108 | 183 | |
| 109 | 184 | ### PR template incomplete |
| @@ -112,7 +187,6 @@ jobs: | ||
| 112 | 187 | EOF |
| 113 | 188 | fi |
| 114 | 189 | |
| 115 | # Footer with link to logs | |
| 116 | 190 | printf '\n---\n*See the [workflow logs](%s/%s/actions/runs/%s) for full details.*\n' \ |
| 117 | 191 | "${{ github.server_url }}" "${{ github.repository }}" "${{ github.run_id }}" \ |
| 118 | 192 | >> /tmp/pr-meta/comment.md |