Skip to content

Commit cfa611f

Browse files
authored
ci: fix the react-native-macos-init pipeline (#2228)
* ci: fix the `react-native-macos-init` pipeline The pipeline wasn't actually publishing anything and we've been testing against latest on npm all this time. * fix(react-native): `xcodeProject.path` may not always be present
1 parent fec7910 commit cfa611f

File tree

5 files changed

+88
-80
lines changed

5 files changed

+88
-80
lines changed
Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
jobs:
22
- job: CliInit
3-
displayName: Verify react-native-macos-init
3+
displayName: Verify react-native-macos in a new project
44
pool:
55
vmImage: $(VmImageApple)
66
steps:
@@ -13,80 +13,59 @@ jobs:
1313

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

16-
- task: CmdLine@2
17-
displayName: yarn install react-native-macos-init
18-
inputs:
19-
script: |
20-
set -eox pipefail
21-
cd packages/react-native-macos-init
22-
yarn install
16+
- script: |
17+
set -eox pipefail
18+
yarn install
19+
displayName: Install npm dependencies
2320
24-
- task: CmdLine@2
21+
- script: |
22+
set -eox pipefail
23+
yarn build
24+
displayName: Build @react-native/community-cli-plugin
25+
26+
- script: |
27+
set -eox pipefail
28+
yarn build
29+
workingDirectory: packages/react-native-macos-init
2530
displayName: Build react-native-macos-init
26-
inputs:
27-
script: |
28-
set -eox pipefail
29-
cd packages/react-native-macos-init
30-
yarn build
3131
3232
- template: /.ado/templates/verdaccio-init.yml@self
3333

34-
- template: /.ado/templates/verdaccio-publish.yml@self
35-
36-
# First do a build of the local package, since we point the cli at the local files, it needs to be pre-built
37-
- task: CmdLine@2
38-
displayName: yarn install (local react-native-macos)
39-
inputs:
40-
script: |
41-
set -eox pipefail
42-
yarn install --immutable
43-
44-
- task: CmdLine@2
45-
displayName: yarn install (local react-native-macos-init)
46-
inputs:
47-
script: |
48-
set -eox pipefail
49-
cd packages/react-native-macos-init
50-
yarn install --immutable
34+
- script: |
35+
.ado/scripts/verdaccio.sh publish --branch origin/$(System.PullRequest.TargetBranch)
36+
displayName: Publish react-native-macos to Verdaccio
5137
52-
- task: CmdLine@2
53-
displayName: yarn build (local react-native-macos-init)
54-
inputs:
55-
script: |
56-
set -eox pipefail
57-
cd packages/react-native-macos-init
58-
yarn build
38+
- script: |
39+
set -eox pipefail
40+
npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install
41+
workingDirectory: $(Agent.BuildDirectory)
42+
displayName: Initialize a new project
5943
60-
- task: CmdLine@2
61-
displayName: Init new project
62-
inputs:
63-
script: |
64-
set -eox pipefail
65-
npx --yes @react-native-community/cli init testcli --version 0.75 --skip-install
66-
workingDirectory: $(Agent.BuildDirectory)
44+
- script: |
45+
set -eox pipefail
46+
yarn install --mode=update-lockfile
47+
# `update-lockfile` skips the linking step, so we need to run `yarn install` again
48+
yarn install
49+
workingDirectory: $(Agent.BuildDirectory)/testcli
50+
displayName: Install npm dependencies (new project)
6751
68-
- task: CmdLine@2
69-
displayName: yarn install (testcli)
70-
inputs:
71-
script: |
72-
set -eox pipefail
73-
yarn install --mode=update-lockfile
74-
# `update-lockfile` skips the linking step, so we need to run `yarn install` again
75-
yarn install
76-
workingDirectory: $(Agent.BuildDirectory)/testcli
52+
- script: |
53+
set -eox pipefail
54+
# We need to set the npm registry here otherwise it won't stick
55+
$(Build.Repository.LocalPath)/.ado/scripts/verdaccio.sh configure
56+
node $(Build.Repository.LocalPath)/packages/react-native-macos-init/bin.js --verbose --version latest --overwrite --prerelease
57+
yarn why react-native-macos
58+
workingDirectory: $(Agent.BuildDirectory)/testcli
59+
displayName: Apply macOS template (new project)
7760
78-
- task: CmdLine@2
79-
displayName: Apply macos template
80-
inputs:
81-
script: |
82-
set -eox pipefail
83-
npx react-native-macos-init --version latest --overwrite --prerelease
84-
workingDirectory: $(Agent.BuildDirectory)/testcli
61+
- script: |
62+
set -eox pipefail
63+
npx react-native build-macos
64+
workingDirectory: $(Agent.BuildDirectory)/testcli
65+
displayName: Build macOS app (new project)
8566
86-
- task: CmdLine@2
87-
displayName: Run macos [test]
88-
inputs:
89-
script: |
90-
set -eox pipefail
91-
npx react-native run-macos
92-
workingDirectory: $(Agent.BuildDirectory)/testcli
67+
- script: |
68+
set -eox pipefail
69+
npx react-native run-macos
70+
workingDirectory: $(Agent.BuildDirectory)/testcli
71+
displayName: Run macOS app (new project)

.ado/scripts/verdaccio.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
NPM_REGISTRY=http://localhost:4873
4+
5+
project_root=$(cd -P "$(dirname $0)" && pwd)
6+
7+
set -eox pipefail
8+
9+
case ${1-} in
10+
"configure")
11+
yarn config set npmRegistryServer $NPM_REGISTRY
12+
yarn config set unsafeHttpWhitelist --json '["localhost"]'
13+
;;
14+
15+
"init")
16+
npm set registry $NPM_REGISTRY
17+
npx verdaccio --config $project_root/.ado/verdaccio/config.yaml &
18+
node $project_root/.ado/waitForVerdaccio.js
19+
node $project_root/.ado/npmAddUser.js user pass [email protected] $NPM_REGISTRY
20+
;;
21+
22+
"publish")
23+
checkpoint=$(git rev-parse HEAD)
24+
yarn set-version 1000.0.0-pr
25+
git commit --all --message 'bump' --no-verify
26+
packages=()
27+
for json in $(yarn workspaces list --no-private --json); do
28+
packages+=(--package $(node --print "JSON.parse('$json').name"))
29+
done
30+
npx beachball change --no-fetch --type patch --message 'bump for testing purposes' ${packages[@]}
31+
npx beachball $* --no-push --registry $NPM_REGISTRY --yes --access public --no-generate-changelog
32+
git reset --hard $checkpoint
33+
;;
34+
esac

.ado/templates/verdaccio-publish.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,8 @@ vendor/
180180
# Ccache
181181
.ccache
182182

183-
# macOS]
183+
# ADO
184+
.ado/Brewfile.lock.json
185+
.ado/verdaccio/htpasswd
186+
.ado/verdaccio/storage/.verdaccio-db.json
187+
# macOS]

packages/react-native-macos-init/src/cli.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ You can either downgrade your version of ${chalk.yellow(RNPKG)} to ${chalk.cyan(
300300
const pkgmgr = isProjectUsingYarn(process.cwd())
301301
? `yarn add${verbose ? '' : ' --silent'}`
302302
: `npm install --save${verbose ? '' : ' --silent'}`;
303-
const execOptions = verbose ? {stdio: 'inherit' as 'inherit'} : {};
303+
const execOptions = verbose ? {stdio: 'inherit' as const} : {};
304304
execSync(`${pkgmgr} "${MACOSPKG}@${version}"`, execOptions);
305305

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

313313
const generateMacOS = require(reactNativeMacOSGeneratePath());
314-
generateMacOS(process.cwd(), name, {
315-
overwrite,
316-
verbose,
317-
});
314+
generateMacOS(process.cwd(), name, {overwrite, verbose});
318315
} catch (error) {
319316
printError(`${error}`, error);
320317
process.exit(EXITCODE_UNKNOWN_ERROR);

0 commit comments

Comments
 (0)