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