.github/workflows/pr-check.yml
190 lines · 6282 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 steps:
112 - uses: actions/checkout@v5
113 - uses: actions/setup-python@v6
114 with:
115 python-version: "3.12"
116 - run: pip install -q -r lib/requirements.txt
117 - name: Download diff data
118 uses: actions/download-artifact@v7
119 with:
120 name: pr-diff
121 path: /tmp
122 continue-on-error: true
123 - name: Check project health
124 env:
125 PR_USER: ${{ github.event.pull_request.user.login }}
126 PR_BODY: ${{ github.event.pull_request.body }}
127 GITHUB_TOKEN: ${{ github.token }}
128 run: python lib/checks/check-project.py
129 - name: Generate repo stats
130 continue-on-error: true
131 env:
132 GITHUB_TOKEN: ${{ github.token }}
133 run: python lib/checks/make-info-stats.py
134 - name: Upload repo stats
135 if: always()
136 uses: actions/upload-artifact@v6
137 with:
138 name: repo-stats
139 path: /tmp/repo-stats.md
140 if-no-files-found: ignore
141 - name: Upload findings
142 if: always()
143 uses: actions/upload-artifact@v6
144 with:
145 name: findings-project
146 path: /tmp/findings-project.json
147 if-no-files-found: ignore
148
149 summary:
150 name: Summary
151 if: always()
152 needs: [pr-compliance, data-validation, submission-eligibility]
153 runs-on: ubuntu-latest
154 steps:
155 - uses: actions/checkout@v5
156 - uses: actions/setup-python@v6
157 with:
158 python-version: "3.12"
159 - name: Download all findings
160 uses: actions/download-artifact@v7
161 with:
162 pattern: findings-*
163 path: /tmp/artifacts
164 merge-multiple: true
165 continue-on-error: true
166 - name: Download diff data
167 uses: actions/download-artifact@v7
168 with:
169 name: pr-diff
170 path: /tmp/artifacts
171 continue-on-error: true
172 - name: Download repo stats
173 if: needs.submission-eligibility.result == 'success'
174 uses: actions/download-artifact@v7
175 with:
176 name: repo-stats
177 path: /tmp/artifacts
178 continue-on-error: true
179 - name: Format comment
180 env:
181 PR_USER: ${{ github.event.pull_request.user.login }}
182 PR_NUMBER: ${{ github.event.pull_request.number }}
183 RUN_ID: ${{ github.run_id }}
184 run: python lib/checks/format-comment.py
185 - name: Upload PR metadata
186 if: always()
187 uses: actions/upload-artifact@v6
188 with:
189 name: pr-meta
190 path: /tmp/pr-meta/