From d124c375c79fab4213818e4490c77c0fec924da8 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:28:04 +0200 Subject: [PATCH] ci: re-enable `react-native-macos-init` pipeline (#2243) * ci: re-enable `react-native-macos-init` pipeline * break cycle? * fixup! ci: re-enable `react-native-macos-init` pipeline * fix `getBuildSettings()` * Update test-react-native-macos-init.yml --- .ado/apple-pr.yml | 12 ++++------ .ado/jobs/test-react-native-macos-init.yml | 7 ++++-- .ado/scripts/export-versions.mjs | 27 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 .ado/scripts/export-versions.mjs diff --git a/.ado/apple-pr.yml b/.ado/apple-pr.yml index bb345df8ee62f3..145176e7d30fb8 100644 --- a/.ado/apple-pr.yml +++ b/.ado/apple-pr.yml @@ -26,12 +26,10 @@ stages: dependsOn: [] jobs: - template: /.ado/jobs/test-javascript.yml@self - - template: /.ado/jobs/npm-publish-dry-run.yml@self - # - stage: Integration - # dependsOn: [] - # jobs: - #- template: /.ado/jobs/test-react-native-macos-init.yml@self - - # - template: /.ado/jobs/react-native-test-app-integration.yml@self \ No newline at end of file + - stage: Integration + dependsOn: [] + jobs: + - template: /.ado/jobs/test-react-native-macos-init.yml@self + #- template: /.ado/jobs/react-native-test-app-integration.yml@self diff --git a/.ado/jobs/test-react-native-macos-init.yml b/.ado/jobs/test-react-native-macos-init.yml index f7b66f472b4b80..5200d802e0bff5 100644 --- a/.ado/jobs/test-react-native-macos-init.yml +++ b/.ado/jobs/test-react-native-macos-init.yml @@ -35,9 +35,13 @@ jobs: .ado/scripts/verdaccio.sh publish --branch origin/$(System.PullRequest.TargetBranch) displayName: Publish react-native-macos to Verdaccio + - script: | + node .ado/scripts/export-versions.mjs + displayName: Determine react-native version + - script: | set -eox pipefail - npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install + npx --yes @react-native-community/cli init testcli --version $(react_native_version) --skip-install workingDirectory: $(Agent.BuildDirectory) displayName: Initialize a new project @@ -54,7 +58,6 @@ jobs: # We need to set the npm registry here otherwise it won't stick $(Build.Repository.LocalPath)/.ado/scripts/verdaccio.sh configure node $(Build.Repository.LocalPath)/packages/react-native-macos-init/bin.js --verbose --version latest --overwrite --prerelease - yarn why react-native-macos workingDirectory: $(Agent.BuildDirectory)/testcli displayName: Apply macOS template (new project) diff --git a/.ado/scripts/export-versions.mjs b/.ado/scripts/export-versions.mjs new file mode 100644 index 00000000000000..53fb6ae28323de --- /dev/null +++ b/.ado/scripts/export-versions.mjs @@ -0,0 +1,27 @@ +// @ts-check +import * as fs from "node:fs"; +import { URL } from "node:url"; + +/** + * @param {string} version + * @returns {string} + */ +function coerce(version) { + const [major, minor = 0] = version.split("-")[0].split("."); + return `${major}.${minor}`; +} + +/** + * @param {string} name + * @param {unknown} value + */ +function exportValue(name, value) { + console.log(`##vso[task.setvariable variable=${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"]));