Skip to content

Commit

Permalink
[RN][CI]Update the testing-script to use github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cipolleschi committed Jun 13, 2024
1 parent b19bf2b commit 54bb605
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Test All

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
Expand Down
4 changes: 2 additions & 2 deletions scripts/release-testing/test-e2e-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const argv = yargs
default: true,
})
.option('c', {
alias: 'circleciToken',
alias: 'ciToken',
type: 'string',
})
.option('useLastSuccessfulPipeline', {
Expand Down Expand Up @@ -338,7 +338,7 @@ async function main() {

let circleCIArtifacts = await setupCircleCIArtifacts(
// $FlowIgnoreError[prop-missing]
argv.circleciToken,
argv.ciToken,
branchName,
// $FlowIgnoreError[prop-missing]
argv.useLastSuccessfulPipeline,
Expand Down
103 changes: 103 additions & 0 deletions scripts/release-testing/utils/github-actions-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env node
/**
* 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.
*
* @flow strict-local
* @format
*/

'use strict';

const chalk = require('chalk');
const fetch = require('node-fetch');
const {execSync: exec} = require('child_process');

let ciHeaders;
let jobs;
let baseTemporaryPath;

async function initialize(
ciToken /*: string */,
baseTempPath /*: string */,
branchName /*: string */,
useLastSuccessfulPipeline /*: boolean */ = false,
) {
console.info('Getting GHA information');
baseTemporaryPath = baseTempPath;

// ciHeaders = {'Circle-Token': ciToken};

// exec(`mkdir -p ${baseTemporaryPath}`);
// const pipeline = await (
// useLastSuccessfulPipeline ? _getLastSuccessfulPipeline : _getLatestPipeline
// )(branchName);
// const testsWorkflow = await _getTestsWorkflow(pipeline.id);
// const jobsResults = await _getCircleCIJobs(testsWorkflow.id);

// jobs = jobsResults.flatMap(j => j);
}

function downloadArtifact(
artifactURL /*: string */,
destination /*: string */,
) {
exec(`rm -rf ${destination}`);
exec(`curl ${artifactURL} -Lo ${destination}`);
}

async function artifactURLForJSCRNTesterAPK(
emulatorArch /*: string */,
) /*: Promise<string> */ {
// return _findUrlForJob(
// 'test_android',
// `rntester-apk/jsc/debug/app-jsc-${emulatorArch}-debug.apk`,
// );
}

async function artifactURLForHermesRNTesterAPK(
emulatorArch /*: string */,
) /*: Promise<string> */ {
// return _findUrlForJob(
// 'test_android',
// `rntester-apk/hermes/debug/app-hermes-${emulatorArch}-debug.apk`,
// );
}

async function artifactURLForMavenLocal() /*: Promise<string> */ {
// return _findUrlForJob('build_npm_package', 'maven-local.zip');
}

async function artifactURLHermesDebug() /*: Promise<string> */ {
// return _findUrlForJob('build_hermes_macos-Debug', 'hermes-ios-debug.tar.gz');
}

async function artifactURLForReactNative() /*: Promise<string> */ {
let shortCommit = exec('git rev-parse HEAD', {silent: true})
.toString()
.trim()
.slice(0, 9);
// return _findUrlForJob(
// 'build_npm_package',
// `react-native-1000.0.0-${shortCommit}.tgz`,
// );
}

function baseTmpPath() /*: string */ {
return baseTemporaryPath;
}



module.exports = {
initialize,
downloadArtifact,
artifactURLForJSCRNTesterAPK,
artifactURLForHermesRNTesterAPK,
artifactURLForMavenLocal,
artifactURLHermesDebug,
artifactURLForReactNative,
baseTmpPath,
}
27 changes: 27 additions & 0 deletions scripts/release-testing/utils/testing-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
generateiOSArtifacts,
} = require('../../releases/utils/release-utils');
const circleCIArtifactsUtils = require('./circle-ci-artifacts-utils.js');
const ghaArtifactsUtils = require('./github-actions-utils.js');
const fs = require('fs');
// $FlowIgnore[cannot-resolve-module]
const {spawn} = require('node:child_process');
Expand Down Expand Up @@ -177,6 +178,32 @@ async function setupCircleCIArtifacts(
return circleCIArtifactsUtils;
}

/**
* Setups the CircleCIArtifacts if a token has been passed
*
* Parameters:
* - @circleciToken a valid CircleCI Token.
* - @branchName the branch of the name we want to use to fetch the artifacts.
*/
async function setupGHAArtifacts(
ciToken /*: ?string */,
branchName /*: string */,
useLastSuccessfulPipeline /*: boolean */,
) /*: Promise<?typeof ghaArtifactsUtils> */ {
if (ciToken == null) {
return null;
}

const baseTmpPath = '/tmp/react-native-tmp';
await ghaArtifactsUtils.initialize(
ciToken,
baseTmpPath,
branchName,
useLastSuccessfulPipeline,
);
return ghaArtifactsUtils;
}

async function downloadArtifactsFromCircleCI(
circleCIArtifacts /*: typeof circleCIArtifactsUtils */,
mavenLocalPath /*: string */,
Expand Down

0 comments on commit 54bb605

Please sign in to comment.