@@ -48,36 +48,56 @@ jobs:
4848 ref: context.sha
4949 });
5050 for (const status of res.data) {
51- if (
52- status.context === 'ci/circleci: process_artifacts_combined' &&
53- status.state === 'success'
54- ) {
55- // The status does not include a build ID, but we can extract it
56- // from the URL. I couldn't find a better way to do this.
57- const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec(
58- status.target_url,
59- )[1];
60- console.log(`CircleCI build id found: ${ciBuildId}`);
61- if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) {
62- artifactsUrl =
63- `https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`;
64- break spinloop;
51+ if (/process_artifacts_combined/.test(status.context)) {
52+ switch (status.state) {
53+ case 'pending': {
54+ console.log(`${status.context} is still pending`);
55+ break;
56+ }
57+ case 'failure':
58+ case 'error': {
59+ throw new Error(`${status.context} has failed or errored`);
60+ }
61+ case 'success': {
62+ // The status does not include a build ID, but we can extract it
63+ // from the URL. I couldn't find a better way to do this.
64+ const ciBuildId = /\/facebook\/react\/([0-9]+)/.exec(
65+ status.target_url,
66+ )[1];
67+ console.log(`CircleCI build id found: ${ciBuildId}`);
68+ if (Number.parseInt(ciBuildId, 10) + '' === ciBuildId) {
69+ artifactsUrl =
70+ `https://circleci.com/api/v1.1/project/github/facebook/react/${ciBuildId}/artifacts`;
71+ break spinloop;
72+ } else {
73+ throw new Error(`${ciBuildId} isn't a number`);
74+ }
75+ break;
76+ }
77+ default: {
78+ throw new Error(`Unhandled status state: ${status.state}`);
79+ break;
80+ }
6581 }
6682 }
6783 }
6884 iter++;
6985 console.log("Sleeping for 60s...");
7086 await sleep(60_000);
7187 }
72- const res = await fetch(artifactsUrl);
73- const data = await res.json();
74- for (const artifact of data) {
75- if (artifact.path === 'build.tgz') {
76- console.log(`Downloading and unzipping ${artifact.url}`);
77- await execHelper(
78- `curl -L ${artifact.url} | tar -xvz`
79- );
88+ if (artifactsUrl != null) {
89+ const res = await fetch(artifactsUrl);
90+ const data = await res.json();
91+ for (const artifact of data) {
92+ if (artifact.path === 'build.tgz') {
93+ console.log(`Downloading and unzipping ${artifact.url}`);
94+ await execHelper(
95+ `curl -L ${artifact.url} | tar -xvz`
96+ );
97+ }
8098 }
99+ } else {
100+ process.exitCode = 1;
81101 }
82102 - name : Move relevant files into compiled
83103 run : |
0 commit comments