Skip to content
Open
27 changes: 0 additions & 27 deletions .ado/scripts/export-versions.mjs

This file was deleted.

35 changes: 35 additions & 0 deletions .github/scripts/export-versions.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node
/**
* Export react and react-native version information from packages/react-native/package.json.
*
* Outputs (written to $GITHUB_OUTPUT):
* react_version – the React peer dependency version (e.g. "19.0.0")
* react_native_version – the coerced major.minor React Native version (e.g. "0.79")
*/
import * as fs from "node:fs";
import { URL } from "node:url";

function coerce(version: string): string {
const [major, minor = "0"] = version.split("-")[0].split(".");
return `${major}.${minor}`;
}

function exportValue(name: string, value: string): void {
const githubOutput = process.env.GITHUB_OUTPUT;
if (githubOutput) {
fs.appendFileSync(githubOutput, `${name}=${value}\n`);
} else {
// Fallback: print to stdout for local debugging
console.log(`${name}=${value}`);
}
}

const manifestPath = new URL(
"../../packages/react-native/package.json",
import.meta.url
);
const json = fs.readFileSync(manifestPath, { encoding: "utf-8" });
const { dependencies, peerDependencies } = JSON.parse(json);

exportValue("react_version", peerDependencies["react"]);
exportValue("react_native_version", coerce(dependencies["@react-native/codegen"]));
14 changes: 6 additions & 8 deletions .github/workflows/microsoft-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ jobs:
if: ${{ endsWith(github.base_ref, '-stable') }}
uses: ./.github/workflows/microsoft-test-react-native-macos-init.yml

# https://github.com/microsoft/react-native-macos/issues/2344
# Disable these tests because verdaccio hangs
# react-native-test-app-integration:
# name: "Test react-native-test-app integration"
# permissions: {}
# if: ${{ endsWith(github.base_ref, '-stable') }}
# uses: ./.github/workflows/microsoft-react-native-test-app-integration.yml
react-native-test-app-integration:
name: "Test react-native-test-app integration"
permissions: {}
if: ${{ endsWith(github.base_ref, '-stable') }}
uses: ./.github/workflows/microsoft-react-native-test-app-integration.yml

PR:
name: "PR"
Expand All @@ -171,7 +169,7 @@ jobs:
- build-rntester
- prebuild-macos-core
- test-react-native-macos-init
# - react-native-test-app-integration
- react-native-test-app-integration
steps:
- name: Check for failures or cancellations
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
Expand Down
77 changes: 48 additions & 29 deletions .github/workflows/microsoft-react-native-test-app-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,83 @@ jobs:
run: yarn install

- name: Build community CLI plugin
run: yarn build
run: |
yarn build
# yarn build rewrites package.json exports; restore them
git checkout -- packages/*/package.json

- name: Build react-native-macos-init
working-directory: packages/react-native-macos-init
run: yarn build

- name: Start Verdaccio server
run: |
set -euo pipefail
nohup npx --yes verdaccio --config .ado/verdaccio/config.yaml >/dev/null 2>&1 &
echo $! > $RUNNER_TEMP/verdaccio.pid
- name: Wait for Verdaccio to be ready
run: node .ado/scripts/waitForVerdaccio.mjs http://localhost:4873

- name: Configure npm for Verdaccio
run: .ado/scripts/verdaccio.sh init
- name: Export versions
id: versions
run: node .github/scripts/export-versions.mts

- name: Publish to Verdaccio
run: .ado/scripts/verdaccio.sh publish --branch origin/${{ github.base_ref }}
- name: Pack local react-native-macos
working-directory: packages/react-native
run: |
set -eox pipefail
yarn pack -o ${{ runner.temp }}/react-native-macos.tgz

- name: Clone react-native-test-app
run: |
git clone --filter=blob:none --progress https://github.com/microsoft/react-native-test-app.git

- name: Export versions
run: node .ado/scripts/export-versions.mjs

- name: Configure react-native-test-app dependencies
working-directory: react-native-test-app/packages/app
run: |
node scripts/internal/set-react-version.mts ${{ steps.versions.outputs.react_native_version }} --overrides '{ "react-native-macos": "file:${{ runner.temp }}/react-native-macos.tgz" }'

- name: Force react-native-macos to local tarball in all workspaces
working-directory: react-native-test-app
run: |
npm run set-react-version $(cat ${{ github.workspace }}/.react_native_version) -- --overrides '{ "react-native-macos": "1000.0.0" }'
node -e "
const fs = require('fs');
const tarball = 'file:${{ runner.temp }}/react-native-macos.tgz';

// Add root-level resolution
const root = JSON.parse(fs.readFileSync('package.json', 'utf8'));
root.resolutions = root.resolutions || {};
root.resolutions['react-native-macos'] = tarball;

// Pin @types/react to a single version so react-native-macos does
// not get virtualized twice (the test app tree carries both 19.1.x
// and 19.2.x, both satisfying its '^19.1.0' peer, which produces
// two virtual copies and trips the duplicate-dependency checker).
root.resolutions['@types/react'] = '~19.1.0';
fs.writeFileSync('package.json', JSON.stringify(root, null, 2) + '\n');

// Override direct dependency in example-macos
const exMacosPath = 'packages/example-macos/package.json';
const exMacos = JSON.parse(fs.readFileSync(exMacosPath, 'utf8'));
if (exMacos.dependencies && exMacos.dependencies['react-native-macos']) {
exMacos.dependencies['react-native-macos'] = tarball;
fs.writeFileSync(exMacosPath, JSON.stringify(exMacos, null, 2) + '\n');
}
"

- name: Install dependencies in test app
working-directory: react-native-test-app
env:
YARN_ENABLE_HARDENED_MODE: 0
YARN_NPM_MINIMAL_AGE_GATE: 0
run: |
set -eo pipefail
${{ github.workspace }}/.ado/scripts/verdaccio.sh configure
yarn --no-immutable

- name: Bundle JavaScript
working-directory: react-native-test-app/example
working-directory: react-native-test-app/packages/example-macos
run: |
yarn build:macos || yarn build:macos

- name: Install Pods
working-directory: react-native-test-app/example
working-directory: react-native-test-app/packages/example-macos
run: |
rm -f macos/Podfile.lock
pod install --project-directory=macos

- name: Build test app
working-directory: react-native-test-app/example
run: |
../scripts/build/xcodebuild.sh macos/Example.xcworkspace build

- name: Stop Verdaccio
if: always()
working-directory: react-native-test-app/packages/example-macos
run: |
if [ -f "$RUNNER_TEMP/verdaccio.pid" ]; then
kill "$(cat $RUNNER_TEMP/verdaccio.pid)" || true
fi
../../scripts/xcodebuild.sh macos/Example.xcworkspace build
Loading