Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix the react-native-macos-init pipeline #2228

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 47 additions & 68 deletions .ado/jobs/test-react-native-macos-init.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jobs:
- job: CliInit
displayName: Verify react-native-macos-init
displayName: Verify react-native-macos in a new project
pool:
vmImage: $(VmImageApple)
steps:
Expand All @@ -13,80 +13,59 @@ jobs:

- template: /.ado/templates/apple-tools-setup.yml@self

- task: CmdLine@2
displayName: yarn install react-native-macos-init
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn install
- script: |
set -eox pipefail
yarn install
displayName: Install npm dependencies

- task: CmdLine@2
- script: |
set -eox pipefail
yarn build
displayName: Build @react-native/community-cli-plugin

- script: |
set -eox pipefail
yarn build
workingDirectory: packages/react-native-macos-init
displayName: Build react-native-macos-init
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn build

- template: /.ado/templates/verdaccio-init.yml@self

- template: /.ado/templates/verdaccio-publish.yml@self

# First do a build of the local package, since we point the cli at the local files, it needs to be pre-built
- task: CmdLine@2
displayName: yarn install (local react-native-macos)
inputs:
script: |
set -eox pipefail
yarn install --immutable

- task: CmdLine@2
displayName: yarn install (local react-native-macos-init)
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn install --immutable
- script: |
.ado/scripts/verdaccio.sh publish --branch origin/$(System.PullRequest.TargetBranch)
displayName: Publish react-native-macos to Verdaccio

- task: CmdLine@2
displayName: yarn build (local react-native-macos-init)
inputs:
script: |
set -eox pipefail
cd packages/react-native-macos-init
yarn build
- script: |
set -eox pipefail
npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install
workingDirectory: $(Agent.BuildDirectory)
displayName: Initialize a new project

- task: CmdLine@2
displayName: Init new project
inputs:
script: |
set -eox pipefail
npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install
workingDirectory: $(Agent.BuildDirectory)
- script: |
set -eox pipefail
yarn install --mode=update-lockfile
# `update-lockfile` skips the linking step, so we need to run `yarn install` again
yarn install
workingDirectory: $(Agent.BuildDirectory)/testcli
displayName: Install npm dependencies (new project)

- task: CmdLine@2
displayName: yarn install (testcli)
inputs:
script: |
set -eox pipefail
yarn install --mode=update-lockfile
# `update-lockfile` skips the linking step, so we need to run `yarn install` again
yarn install
workingDirectory: $(Agent.BuildDirectory)/testcli
- script: |
set -eox pipefail
# 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)

- task: CmdLine@2
displayName: Apply macos template
inputs:
script: |
set -eox pipefail
npx react-native-macos-init --version latest --overwrite --prerelease
workingDirectory: $(Agent.BuildDirectory)/testcli
- script: |
set -eox pipefail
npx react-native build-macos
workingDirectory: $(Agent.BuildDirectory)/testcli
displayName: Build macOS app (new project)

- task: CmdLine@2
displayName: Run macos [test]
inputs:
script: |
set -eox pipefail
npx react-native run-macos
workingDirectory: $(Agent.BuildDirectory)/testcli
- script: |
set -eox pipefail
npx react-native run-macos
workingDirectory: $(Agent.BuildDirectory)/testcli
displayName: Run macOS app (new project)
34 changes: 34 additions & 0 deletions .ado/scripts/verdaccio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

NPM_REGISTRY=http://localhost:4873

project_root=$(cd -P "$(dirname $0)" && pwd)

set -eox pipefail

case ${1-} in
"configure")
yarn config set npmRegistryServer $NPM_REGISTRY
yarn config set unsafeHttpWhitelist --json '["localhost"]'
;;

"init")
npm set registry $NPM_REGISTRY
npx verdaccio --config $project_root/.ado/verdaccio/config.yaml &
node $project_root/.ado/waitForVerdaccio.js
node $project_root/.ado/npmAddUser.js user pass mail@nomail.com $NPM_REGISTRY
;;

"publish")
checkpoint=$(git rev-parse HEAD)
yarn set-version 1000.0.0-pr
git commit --all --message 'bump' --no-verify
packages=()
for json in $(yarn workspaces list --no-private --json); do
packages+=(--package $(node --print "JSON.parse('$json').name"))
done
npx beachball change --no-fetch --type patch --message 'bump for testing purposes' ${packages[@]}
npx beachball $* --no-push --registry $NPM_REGISTRY --yes --access public --no-generate-changelog
git reset --hard $checkpoint
;;
esac
6 changes: 0 additions & 6 deletions .ado/templates/verdaccio-publish.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,8 @@ vendor/
# Ccache
.ccache

# macOS]
# ADO
.ado/Brewfile.lock.json
.ado/verdaccio/htpasswd
.ado/verdaccio/storage/.verdaccio-db.json
# macOS]
7 changes: 2 additions & 5 deletions packages/react-native-macos-init/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ You can either downgrade your version of ${chalk.yellow(RNPKG)} to ${chalk.cyan(
const pkgmgr = isProjectUsingYarn(process.cwd())
? `yarn add${verbose ? '' : ' --silent'}`
: `npm install --save${verbose ? '' : ' --silent'}`;
const execOptions = verbose ? {stdio: 'inherit' as 'inherit'} : {};
const execOptions = verbose ? {stdio: 'inherit' as const} : {};
execSync(`${pkgmgr} "${MACOSPKG}@${version}"`, execOptions);

console.log(`${pkgLatest} ${chalk.green('successfully installed!')}`);
Expand All @@ -301,10 +301,7 @@ You can either downgrade your version of ${chalk.yellow(RNPKG)} to ${chalk.cyan(
}

const generateMacOS = require(reactNativeMacOSGeneratePath());
generateMacOS(process.cwd(), name, {
overwrite,
verbose,
});
generateMacOS(process.cwd(), name, {overwrite, verbose});
} catch (error) {
printError(error.message, error);
process.exit(EXITCODE_UNKNOWN_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/local-cli/runMacOS/runMacOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function buildProject(sourceDir, xcodeProject, scheme, args) {
return new Promise((resolve, reject) => {
const xcodebuildArgs = [
xcodeProject.isWorkspace ? '-workspace' : '-project',
path.join(sourceDir, xcodeProject.path, xcodeProject.name),
path.join(sourceDir, xcodeProject.path || '.', xcodeProject.name),
tido64 marked this conversation as resolved.
Show resolved Hide resolved
'-configuration',
args.mode,
'-scheme',
Expand Down
Loading