Collect nightlies results (#50488)

Summary:
This change adds a job to collect nightlies results so we can then post on discord or internally

## Changelog:
[Internal] - Add a job to collect nightlies results

Pull Request resolved: https://github.com/facebook/react-native/pull/50488

Test Plan: GHA - tested as a job on PRs: https://github.com/facebook/react-native/actions/runs/14283415968/job/40035831913

Reviewed By: cortinico

Differential Revision: D72555358

Pulled By: cipolleschi

fbshipit-source-id: 35ec7e571992f5f27179256570b5d143e0d76586
This commit is contained in:
Riccardo Cipolleschi
2025-04-07 09:55:14 -07:00
committed by Facebook GitHub Bot
parent 1853957773
commit 26a6ae0e89
2 changed files with 117 additions and 2 deletions
@@ -0,0 +1,74 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const fs = require('fs');
const path = require('path');
function readOutcomes() {
const baseDir = '/tmp';
let outcomes = {};
fs.readdirSync(baseDir).forEach(file => {
const fullPath = path.join(baseDir, file);
if (fullPath.endsWith('outcome') && fs.statSync(fullPath).isDirectory) {
fs.readdirSync(fullPath).forEach(subFile => {
const subFullPath = path.join(fullPath, subFile);
if (subFullPath.endsWith('outcome')) {
const [library, status] = String(fs.readFileSync(subFullPath, 'utf8'))
.trim()
.split(':');
const platform = subFile.includes('android') ? 'Android' : 'iOS';
console.log(
`[${platform}] ${library} completed with status ${status}`,
);
outcomes[library.trim()] = {
platform,
status: status.trim(),
};
}
});
} else if (fullPath.endsWith('outcome')) {
const [library, status] = String(fs.readFileSync(fullPath, 'utf8'))
.trim()
.split(':');
const platform = file.includes('android') ? 'Android' : 'iOS';
console.log(`[${platform}] ${library} completed with status ${status}`);
outcomes[library.trim()] = {
platform,
status: status.trim(),
};
}
});
return outcomes;
}
function printFailures(outcomes) {
console.log('Printing failures...');
let failures = 0;
Object.entries(outcomes).forEach(([library, value]) => {
if (value.status !== 'success') {
console.log(
`❌ [${value.platform}] ${library} failed with status ${value.status}`,
);
failures++;
}
});
return failures > 0;
}
function collectResults() {
const outcomes = readOutcomes();
const failures = printFailures(outcomes);
if (failures) {
process.exit(1);
}
console.log('✅ All tests passed!');
}
module.exports = {
collectResults,
};
@@ -48,11 +48,22 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test ${{ inputs.library-name }}
- name: Test ${{ matrix.library }}
id: run-test
uses: ./.github/actions/test-library-on-nightly
with:
library-npm-package: ${{ matrix.library }}
platform: android
- name: Save outcome
if: always()
run: |
echo "${{matrix.library}}: ${{steps.run-test.outcome}}" >> "/tmp/${{matrix.library}}-android-outcome"
- name: Upload Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.library }}-android-outcome
path: /tmp/${{ matrix.library }}-android-outcome
test-library-on-nightly-ios:
name: "[iOS] ${{ matrix.library }}"
@@ -95,8 +106,38 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test ${{ inputs.library-name }}
- name: Test ${{ matrix.library }}
id: run-test
uses: ./.github/actions/test-library-on-nightly
with:
library-npm-package: ${{ matrix.library }}
platform: ios
- name: Save outcome
if: always()
run: |
echo "${{matrix.library}}: ${{steps.run-test.outcome}}" > "/tmp/${{matrix.library}}-ios-outcome"
- name: Upload Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.library }}-ios-outcome
path: /tmp/${{ matrix.library }}-ios-outcome
collect-results:
runs-on: ubuntu-latest
needs: [test-library-on-nightly-android, test-library-on-nightly-ios]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore outcomes
uses: actions/download-artifact@v4
with:
pattern: '*-outcome'
path: /tmp
- name: Collect failures
uses: actions/github-script@v6
with:
script: |
const {collectResults} = require('./.github/workflow-scripts/collectNightlyOutcomes.js');
collectResults();