.github/workflows/pr-check.yml
195 lines · 6570 bytes
1name: PR Check
2
3on:
4 pull_request:
5 branches: [main]
6 types: [opened, edited, synchronize, reopened]
7 paths:
8 - 'awesome-privacy.yml'
9 - '.github/README.md'
10
11permissions:
12 contents: read
13 pull-requests: read
14 security-events: read
15
16jobs:
17 pr-compliance:
18 name: PR Compliance
19 runs-on: ubuntu-latest
20 steps:
21 - uses: actions/checkout@v5
22 with:
23 fetch-depth: 0
24 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
25 - uses: actions/setup-python@v6
26 with:
27 python-version: "3.12"
28 - name: Check README edits
29 id: readme
30 continue-on-error: true
31 run: python lib/checks/check-readme-edits.py --base-ref ${{ github.event.pull_request.base.sha }}
32 - name: Check PR metadata
33 id: meta
34 env:
35 PR_TITLE: ${{ github.event.pull_request.title }}
36 PR_BODY: ${{ github.event.pull_request.body }}
37 PR_DRAFT: ${{ github.event.pull_request.draft }}
38 BASE_REF: ${{ github.event.pull_request.base.sha }}
39 README_FAILED: ${{ steps.readme.outcome == 'failure' && 'true' || 'false' }}
40 run: python lib/checks/check-pr-meta.py
41 - name: Upload findings
42 if: always()
43 uses: actions/upload-artifact@v6
44 with:
45 name: findings-compliance
46 path: /tmp/findings-compliance.json
47 if-no-files-found: ignore
48 - name: Fail if critical
49 if: steps.readme.outcome == 'failure' || steps.meta.outcome == 'failure'
50 run: exit 1
51
52 data-validation:
53 name: Data Validation
54 runs-on: ubuntu-latest
55 outputs:
56 yaml_changed: ${{ steps.changes.outputs.yaml_changed }}
57 steps:
58 - uses: actions/checkout@v5
59 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
60 - uses: actions/setup-python@v6
61 with:
62 python-version: "3.12"
63 - name: Detect changes
64 id: changes
65 run: python lib/checks/detect-changes.py --base-ref ${{ github.event.pull_request.base.sha }}
66 - name: Install dependencies
67 if: steps.changes.outputs.yaml_changed == 'true'
68 run: pip install -q -r lib/requirements.txt
69 - name: Schema validation
70 if: steps.changes.outputs.yaml_changed == 'true'
71 id: schema
72 continue-on-error: true
73 run: make validate
74 - name: YAML diff
75 if: steps.changes.outputs.yaml_changed == 'true'
76 id: diff
77 continue-on-error: true
78 run: python lib/checks/check-yaml-diff.py --base-ref ${{ github.event.pull_request.base.sha }}
79 - name: Check additions
80 if: steps.changes.outputs.yaml_changed == 'true'
81 id: additions
82 continue-on-error: true
83 env:
84 SCHEMA_OUTCOME: ${{ steps.schema.outcome }}
85 run: python lib/checks/check-additions.py
86 - name: Upload diff data
87 if: always()
88 uses: actions/upload-artifact@v6
89 with:
90 name: pr-diff
91 path: |
92 /tmp/pr-diff.json
93 /tmp/pr-diff-summary.md
94 if-no-files-found: ignore
95 - name: Upload findings
96 if: always()
97 uses: actions/upload-artifact@v6
98 with:
99 name: findings-data
100 path: /tmp/findings-data.json
101 if-no-files-found: ignore
102 - name: Fail if critical
103 if: steps.changes.outputs.yaml_changed == 'true' && (steps.schema.outcome == 'failure' || steps.diff.outcome == 'failure' || steps.additions.outcome == 'failure')
104 run: exit 1
105
106 submission-eligibility:
107 name: Submission Eligibility
108 needs: data-validation
109 if: "!cancelled() && needs.data-validation.outputs.yaml_changed == 'true'"
110 runs-on: ubuntu-latest
111 outputs:
112 has_repo_stats: ${{ steps.repo-stats.outputs.exists }}
113 steps:
114 - uses: actions/checkout@v5
115 - uses: actions/setup-python@v6
116 with:
117 python-version: "3.12"
118 - run: pip install -q -r lib/requirements.txt
119 - name: Download diff data
120 uses: actions/download-artifact@v7
121 with:
122 name: pr-diff
123 path: /tmp
124 continue-on-error: true
125 - name: Check project health
126 env:
127 PR_USER: ${{ github.event.pull_request.user.login }}
128 PR_BODY: ${{ github.event.pull_request.body }}
129 GITHUB_TOKEN: ${{ github.token }}
130 run: python lib/checks/check-project.py
131 - name: Generate repo stats
132 continue-on-error: true
133 env:
134 GITHUB_TOKEN: ${{ github.token }}
135 run: python lib/checks/make-info-stats.py
136 - name: Check for repo stats
137 if: always()
138 id: repo-stats
139 run: test -f /tmp/repo-stats.md && echo "exists=true" >> "$GITHUB_OUTPUT" || echo "exists=false" >> "$GITHUB_OUTPUT"
140 - name: Upload repo stats
141 if: steps.repo-stats.outputs.exists == 'true'
142 uses: actions/upload-artifact@v6
143 with:
144 name: repo-stats
145 path: /tmp/repo-stats.md
146 - name: Upload findings
147 if: always()
148 uses: actions/upload-artifact@v6
149 with:
150 name: findings-project
151 path: /tmp/findings-project.json
152 if-no-files-found: ignore
153
154 summary:
155 name: Summary
156 if: always()
157 needs: [pr-compliance, data-validation, submission-eligibility]
158 runs-on: ubuntu-latest
159 steps:
160 - uses: actions/checkout@v5
161 - uses: actions/setup-python@v6
162 with:
163 python-version: "3.12"
164 - name: Download all findings
165 uses: actions/download-artifact@v7
166 with:
167 pattern: findings-*
168 path: /tmp/artifacts
169 merge-multiple: true
170 continue-on-error: true
171 - name: Download diff data
172 uses: actions/download-artifact@v7
173 with:
174 name: pr-diff
175 path: /tmp/artifacts
176 continue-on-error: true
177 - name: Download repo stats
178 if: needs.submission-eligibility.outputs.has_repo_stats == 'true'
179 uses: actions/download-artifact@v7
180 with:
181 name: repo-stats
182 path: /tmp/artifacts
183 continue-on-error: true
184 - name: Format comment
185 env:
186 PR_USER: ${{ github.event.pull_request.user.login }}
187 PR_NUMBER: ${{ github.event.pull_request.number }}
188 RUN_ID: ${{ github.run_id }}
189 run: python lib/checks/format-comment.py
190 - name: Upload PR metadata
191 if: always()
192 uses: actions/upload-artifact@v6
193 with:
194 name: pr-meta
195 path: /tmp/pr-meta/