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