@@ -9,14 +9,15 @@ concurrency:
99 cancel-in-progress : true
1010
1111jobs :
12- check_export :
12+ check_exemptions :
1313 if : github.repository == 'react/react-native'
1414 runs-on : ubuntu-latest
1515 permissions :
1616 contents : read
1717 pull-requests : read
1818 outputs :
1919 exported : ${{ steps.check.outputs.exported }}
20+ build_tooling : ${{ steps.check.outputs.build_tooling }}
2021 steps :
2122 - name : Checkout trusted base
2223 uses : actions/checkout@v6
@@ -25,20 +26,40 @@ jobs:
2526 persist-credentials : false
2627 # Do this before the model job, including on the PR-opened event: the
2728 # meta-codesync label may not have arrived yet.
28- - name : Identify Meta-exported pull requests
29+ - name : Identify PRs exempt from Meta import risk triage
2930 id : check
3031 uses : actions/github-script@v8
3132 with :
3233 script : |
3334 const isMetaExportedPullRequest = require('./.github/workflow-scripts/isMetaExportedPullRequest');
35+ const buildToolingOnly = require('./.github/workflow-scripts/buildToolingOnly');
3436 const {data: pr} = await github.rest.pulls.get({
3537 ...context.repo, pull_number: context.issue.number,
3638 });
37- core.setOutput('exported', isMetaExportedPullRequest(pr));
39+ const exported = isMetaExportedPullRequest(pr);
40+ core.setOutput('exported', exported);
41+ if (exported) {
42+ core.setOutput('build_tooling', 'none');
43+ return;
44+ }
45+ // On a transient file-list error, let the classifier retry and
46+ // conservatively report an unknown risk if it cannot inspect the PR.
47+ let category = null;
48+ try {
49+ const files = await github.paginate(github.rest.pulls.listFiles, {
50+ ...context.repo, pull_number: context.issue.number, per_page: 100,
51+ });
52+ category = buildToolingOnly(files, pr.labels);
53+ } catch {
54+ core.warning('Could not inspect changed paths for build-tooling exemption.');
55+ }
56+ core.setOutput('build_tooling', category ?? 'none');
3857
3958 classify :
40- needs : check_export
41- if : needs.check_export.outputs.exported == 'false'
59+ needs : check_exemptions
60+ if : >-
61+ needs.check_exemptions.outputs.exported == 'false' &&
62+ needs.check_exemptions.outputs.build_tooling == 'none'
4263 runs-on : ubuntu-latest
4364 timeout-minutes : 10
4465 permissions :
@@ -76,13 +97,15 @@ jobs:
7697 }
7798
7899 label :
79- needs : [check_export , classify]
100+ needs : [check_exemptions , classify]
80101 # A newer PR event cancels the old run. Do not treat its missing output as
81102 # an unknown risk; only an explicit unknown from the classifier is fail-safe.
82103 if : >-
83104 always() && !cancelled() && github.repository == 'react/react-native' &&
84- (needs.check_export.outputs.exported == 'true' ||
85- (needs.check_export.outputs.exported == 'false' &&
105+ (needs.check_exemptions.outputs.exported == 'true' ||
106+ contains(fromJSON('["gradle","cocoapods"]'), needs.check_exemptions.outputs.build_tooling) ||
107+ (needs.check_exemptions.outputs.exported == 'false' &&
108+ needs.check_exemptions.outputs.build_tooling == 'none' &&
86109 contains(fromJSON('["low","high","unknown"]'), needs.classify.outputs.risk)))
87110 runs-on : ubuntu-latest
88111 permissions :
@@ -101,7 +124,8 @@ jobs:
101124 - name : Apply Meta Review Required when needed
102125 uses : actions/github-script@v8
103126 env :
104- EXPORTED : ${{ needs.check_export.outputs.exported }}
127+ EXPORTED : ${{ needs.check_exemptions.outputs.exported }}
128+ BUILD_TOOLING : ${{ needs.check_exemptions.outputs.build_tooling }}
105129 RISK : ${{ needs.classify.outputs.risk }}
106130 with :
107131 script : |
@@ -126,6 +150,18 @@ jobs:
126150 core.setFailed('Export status changed after preflight; wait for a new PR event to classify it.');
127151 return;
128152 }
153+ if (process.env.BUILD_TOOLING !== 'none' && !labels.includes('high-risk')) {
154+ if (pr.head.sha !== context.payload.pull_request.head.sha) {
155+ core.setFailed('PR head changed after build-tooling preflight; wait for a new PR event.');
156+ return;
157+ }
158+ if (labels.includes('Meta Review Required')) {
159+ await github.rest.issues.removeLabel({
160+ owner, repo, issue_number: number, name: 'Meta Review Required',
161+ });
162+ }
163+ return;
164+ }
129165 const stale = pr.head.sha !== context.payload.pull_request.head.sha;
130166 if (process.env.RISK === 'low' && !stale && !labels.includes('high-risk')) {
131167 return;
0 commit comments