Skip to content

Commit 3832191

Browse files
committed
[RN][CI] Collect nightlies results
1 parent 22f4c57 commit 3832191

File tree

2 files changed

+117
-2
lines changed

2 files changed

+117
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
const fs = require('fs');
11+
const path = require('path');
12+
13+
function readOutcomes() {
14+
const baseDir = '/tmp';
15+
let outcomes = {};
16+
fs.readdirSync(baseDir).forEach(file => {
17+
const fullPath = path.join(baseDir, file);
18+
if (fullPath.endsWith('outcome') && fs.statSync(fullPath).isDirectory) {
19+
fs.readdirSync(fullPath).forEach(subFile => {
20+
const subFullPath = path.join(fullPath, subFile);
21+
if (subFullPath.endsWith('outcome')) {
22+
const [library, status] = String(fs.readFileSync(subFullPath, 'utf8'))
23+
.trim()
24+
.split(':');
25+
const platform = subFile.includes('android') ? 'Android' : 'iOS';
26+
console.log(
27+
`[${platform}] ${library} completed with status ${status}`,
28+
);
29+
outcomes[library.trim()] = {
30+
platform,
31+
status: status.trim(),
32+
};
33+
}
34+
});
35+
} else if (fullPath.endsWith('outcome')) {
36+
const [library, status] = String(fs.readFileSync(fullPath, 'utf8'))
37+
.trim()
38+
.split(':');
39+
const platform = file.includes('android') ? 'Android' : 'iOS';
40+
console.log(`[${platform}] ${library} completed with status ${status}`);
41+
outcomes[library.trim()] = {
42+
platform,
43+
status: status.trim(),
44+
};
45+
}
46+
});
47+
return outcomes;
48+
}
49+
50+
function printFailures(outcomes) {
51+
console.log('Printing failures...');
52+
let failures = 0;
53+
Object.entries(outcomes).forEach(([library, value]) => {
54+
if (value.status !== 'success') {
55+
console.log(
56+
`❌ [${value.platform}] ${library} failed with status ${value.status}`,
57+
);
58+
failures++;
59+
}
60+
});
61+
return failures > 0;
62+
}
63+
64+
function collectResults() {
65+
const outcomes = readOutcomes();
66+
const failures = printFailures(outcomes);
67+
if (failures) {
68+
process.exit(1);
69+
}
70+
console.log('✅ All tests passed!');
71+
}
72+
module.exports = {
73+
collectResults,
74+
};

.github/workflows/test-libraries-on-nightlies.yml

+43-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,22 @@ jobs:
4848
steps:
4949
- name: Checkout
5050
uses: actions/checkout@v4
51-
- name: Test ${{ inputs.library-name }}
51+
- name: Test ${{ matrix.library }}
52+
id: run-test
5253
uses: ./.github/actions/test-library-on-nightly
5354
with:
5455
library-npm-package: ${{ matrix.library }}
5556
platform: android
57+
- name: Save outcome
58+
if: always()
59+
run: |
60+
echo "${{matrix.library}}: ${{steps.run-test.outcome}}" >> "/tmp/${{matrix.library}}-android-outcome"
61+
- name: Upload Artifact
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: ${{ matrix.library }}-android-outcome
66+
path: /tmp/${{ matrix.library }}-android-outcome
5667

5768
test-library-on-nightly-ios:
5869
name: "[iOS] ${{ matrix.library }}"
@@ -95,8 +106,38 @@ jobs:
95106
steps:
96107
- name: Checkout
97108
uses: actions/checkout@v4
98-
- name: Test ${{ inputs.library-name }}
109+
- name: Test ${{ matrix.library }}
110+
id: run-test
99111
uses: ./.github/actions/test-library-on-nightly
100112
with:
101113
library-npm-package: ${{ matrix.library }}
102114
platform: ios
115+
- name: Save outcome
116+
if: always()
117+
run: |
118+
echo "${{matrix.library}}: ${{steps.run-test.outcome}}" > "/tmp/${{matrix.library}}-ios-outcome"
119+
- name: Upload Artifact
120+
if: always()
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: ${{ matrix.library }}-ios-outcome
124+
path: /tmp/${{ matrix.library }}-ios-outcome
125+
126+
127+
collect-results:
128+
runs-on: ubuntu-latest
129+
needs: [test-library-on-nightly-android, test-library-on-nightly-ios]
130+
steps:
131+
- name: Checkout
132+
uses: actions/checkout@v4
133+
- name: Restore outcomes
134+
uses: actions/download-artifact@v4
135+
with:
136+
pattern: '*-outcome'
137+
path: /tmp
138+
- name: Collect failures
139+
uses: actions/github-script@v6
140+
with:
141+
script: |
142+
const {collectResults} = require('./.github/workflow-scripts/collectNightlyOutcomes.js');
143+
collectResults();

0 commit comments

Comments
 (0)