|
15 | 15 |
|
16 | 16 | const {danger, fail, /*message,*/ warn} = require('danger'); |
17 | 17 | const includes = require('lodash.includes'); |
18 | | -const fetch = require('node-fetch'); |
19 | 18 | const {validate: validateChangelog} = |
20 | 19 | require('@rnx-kit/rn-changelog-generator').default; |
21 | 20 |
|
@@ -101,84 +100,3 @@ if (isMergeRefStable) { |
101 | 100 | labels: ['Pick Request'], |
102 | 101 | }); |
103 | 102 | } |
104 | | - |
105 | | -// Wait for statuses and post a message if there are failures. |
106 | | -async function handleStatuses() { |
107 | | - const regex = /Test Suites: \d+ failed/; |
108 | | - let startChecking = Date.now(); |
109 | | - let done = false; |
110 | | - while (!done) { |
111 | | - let now = Date.now(); |
112 | | - if (now - startChecking > 90 * 60 * 1000) { |
113 | | - warn( |
114 | | - "One hour and a half have passed and the E2E jobs haven't finished yet.", |
115 | | - ); |
116 | | - done = true; |
117 | | - continue; |
118 | | - } |
119 | | - |
120 | | - const githubBaseURL = `https://api.github.com/repos/${danger.github.pr.base.repo.owner.login}/${danger.github.pr.base.repo.name}`; |
121 | | - const statusesURL = `${githubBaseURL}/commits/${danger.github.pr.head.sha}/statuses?per_page=100`; |
122 | | - |
123 | | - const response = await fetch(statusesURL, { |
124 | | - headers: { |
125 | | - Accept: 'application/vnd.github+json', |
126 | | - 'X-GitHub-Api-Version': '2022-11-28', |
127 | | - Authorization: `Bearer ${process.env.DANGER_GITHUB_API_TOKEN}`, |
128 | | - }, |
129 | | - }); |
130 | | - |
131 | | - const data = await response.json(); |
132 | | - const e2e_jobs = data.filter(job => { |
133 | | - return ( |
134 | | - job.context === 'ci/circleci: test_e2e_ios' |
135 | | - // test_e2e_android does not currently tun |
136 | | - // || job.context === 'ci/circleci: test_e2e_android' |
137 | | - ); |
138 | | - }); |
139 | | - if (e2e_jobs.length <= 0) { |
140 | | - console.log('No e2e jobs found yet, retrying in 5 minutes.'); |
141 | | - await new Promise(resolve => setTimeout(resolve, 5 * 60 * 1000)); |
142 | | - continue; |
143 | | - } |
144 | | - |
145 | | - const jobFinished = e2e_jobs.every(job => job.state !== 'pending'); |
146 | | - if (!jobFinished) { |
147 | | - console.log("E2E jobs haven't finished yet, retrying in 5 minutes."); |
148 | | - await new Promise(resolve => setTimeout(resolve, 5 * 60 * 1000)); |
149 | | - continue; |
150 | | - } |
151 | | - |
152 | | - e2e_jobs.forEach(async job => { |
153 | | - const url = job.target_url; |
154 | | - const components = url.split('/'); |
155 | | - const jobId = components[components.length - 1]; |
156 | | - const jobUrl = `https://circleci.com/api/v2/project/gh/facebook/react-native/${jobId}`; |
157 | | - const artifactUrl = `${jobUrl}/artifacts`; |
158 | | - const artifactResponse = await fetch(artifactUrl); |
159 | | - const artifactData = await artifactResponse.json(); |
160 | | - const testLogs = artifactData.items.filter( |
161 | | - item => item.path === 'tmp/test_log', |
162 | | - ); |
163 | | - if (testLogs.length !== 1) { |
164 | | - warn( |
165 | | - `Can't find the E2E test log for ${job.context}. <a href=${jobUrl}>Job link</a>`, |
166 | | - ); |
167 | | - return; |
168 | | - } |
169 | | - |
170 | | - const logUrl = testLogs[0].url; |
171 | | - const logResponseText = await fetch(logUrl); |
172 | | - const logText = await logResponseText.text(); |
173 | | - |
174 | | - if (regex.test(logText)) { |
175 | | - warn( |
176 | | - `E2E tests for ${job.context} failed with errors. See the <a href="${logUrl}">logs for details<a/>`, |
177 | | - ); |
178 | | - } |
179 | | - }); |
180 | | - done = true; |
181 | | - } |
182 | | -} |
183 | | - |
184 | | -// handleStatuses(); |
0 commit comments