Skip to content

Commit

Permalink
Merge remote-tracking branch 'ms/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-un committed Apr 7, 2020
2 parents 408dae3 + f9df0ae commit bdaa8ad
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .ado/ado-start-verdaccio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -ex

# Script used by the Azure DevOps build agent to start the verdaccio npm proxy server

THIS_DIR=$PWD

COMMAND="$TMPDIR/launchVerdaccio.command"
echo "cd ${THIS_DIR}; sudo n 10 ; verdaccio --config ./.ado/verdaccio/config.yaml &> ./.ado/verdaccio/console.log" > "$COMMAND"
chmod +x "$COMMAND"
open "$COMMAND"
31 changes: 23 additions & 8 deletions .ado/apple-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This file defines the Apple PR build steps used during the CI loop
name: $(Date:yyyyMMdd).$(Rev:.r)

variables:
- template: variables/mac.yml

trigger: none # will disable CI builds entirely

pr:
Expand All @@ -17,7 +20,7 @@ jobs:
public:
apply_office_patches: 'false'
pool:
vmImage: macOS-10.14
vmImage: $(VmImage)
demands: ['xcode', 'sh', 'npm']
steps:
- template: templates/apple-job-javascript.yml
Expand All @@ -36,12 +39,6 @@ jobs:
xcode_actions_debug: 'build test'
xcode_actions_release: 'build'
apply_office_patches: 'false'
# Microsoft- We don't use tvOS, so don't bother maintaining the infra
# tvos:
# packager_platform: 'ios'
# xcode_sdk: appletvsimulator
# xcode_scheme: 'RNTester-tvOS'
# xcode_destination: 'platform=tvOS Simulator,OS=latest,name=Apple TV'
macos:
packager_platform: 'macos'
xcode_sdk: macosx
Expand All @@ -67,7 +64,7 @@ jobs:
xcode_actions_release: 'build'
apply_office_patches: 'true'
pool:
vmImage: macOS-10.14
vmImage: $(VmImage)
demands: ['xcode', 'sh', 'npm']
timeoutInMinutes: 60 # how long to run the job before automatically cancelling
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
Expand All @@ -82,3 +79,21 @@ jobs:
xcode_actions_release: $(xcode_actions_release)
xcode_destination: $(xcode_destination)
apply_office_patches: $(apply_office_patches)

- job: CliInit
displayName: Verify react-native-macos-init
strategy:
matrix:
MacDebug:
configuration: Debug
pool:
vmImage: $(VmImage)
demands: ['xcode', 'sh', 'npm']
steps:
- task: UseNode@1
inputs:
version: '10.x'

- template: templates/react-native-macos-init.yml
parameters:
configuration: $(configuration)
40 changes: 40 additions & 0 deletions .ado/npmAddUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node
// @ts-check

const child_process = require("child_process");

const username = process.argv[2];
const password = process.argv[3];
const email = process.argv[4];
const registry = process.argv[5];

if (!username) {
console.error("Please specify username");
process.exit(1);
}

if (!password) {
console.error("Please specify password");
process.exit(1);
}

if (!email) {
console.error("Please specify email");
process.exit(1);
}

const child = child_process.exec(`npm adduser${registry? (' --registry ' + registry) :''}` );

child.stdout.on("data", d => {
const data = d.toString();
process.stdout.write(d + "\n");
if (data.match(/username/i)) {
child.stdin.write(username + "\n");
} else if (data.match(/password/i)) {
child.stdin.write(password + "\n");
} else if (data.match(/email/i)) {
child.stdin.write(email + "\n");
} else if (data.match(/logged in as/i)) {
child.stdin.end();
}
});
99 changes: 99 additions & 0 deletions .ado/templates/react-native-macos-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
parameters:
configuration:

steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
# fetchDepth: 2 # the depth of commits to ask Git to fetch
lfs: false # whether to download Git-LFS files
submodules: false # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: false # set to 'true' to leave the OAuth token in the Git config after the initial fetch

# 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: yarn install --frozen-lockfile

- task: CmdLine@2
displayName: yarn install (local react-native-macos-init)
inputs:
script: |
cd packages/react-native-macos-init
yarn install
- task: CmdLine@2
displayName: yarn build (local react-native-macos-init)
inputs:
script: |
cd packages/react-native-macos-init
yarn build
- task: CmdLine@2
displayName: Install Verdaccio
inputs:
script: |
npm install --global verdaccio
- task: CmdLine@2
displayName: Install n used by ado-start-verdaccio.sh
inputs:
script: |
npm install --global n
- task: ShellScript@2
displayName: Launch test npm server (verdaccio)
inputs:
scriptPath: '.ado/ado-start-verdaccio.sh'
disableAutoCwd: true
cwd: ''

- script: |
npm set registry http://localhost:4873
displayName: Modify default npm config to point to local verdaccio server
- script: |
node .ado/waitForVerdaccio.js
displayName: Wait for verdaccio server to boot
- script: |
node .ado/npmAddUser.js user pass mail@nomail.com http://localhost:4873
displayName: Add npm user to verdaccio
- task: CmdLine@2
displayName: Bump package version
inputs:
script: node .ado/bumpFileVersions.js

- task: CmdLine@2
displayName: "Prepare package.json for npm publishing as react-native-macos"
inputs:
script: node .ado/renamePackageToMac.js

- script: |
npm publish --registry http://localhost:4873
displayName: Publish react-native-macos to verdaccio
- script: |
cd packages/react-native-macos-init
npx --no-install beachball publish --branch origin/$(System.PullRequest.TargetBranch) --no-push --registry http://localhost:4873 --yes --access public
displayName: Publish react-native-macos-init to verdaccio
- task: CmdLine@2
displayName: Install react-native cli
inputs:
script: npm install -g react-native-cli

- task: CmdLine@2
displayName: Init new project
inputs:
script: react-native init testcli
workingDirectory: $(Agent.BuildDirectory)

- task: CmdLine@2
displayName: Apply macos template
inputs:
script: npx react-native-macos-init --version latest --overwrite --prerelease
workingDirectory: $(Agent.BuildDirectory)/testcli

# TODO: react-native run-macos and test when implemented
2 changes: 2 additions & 0 deletions .ado/variables/mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
variables:
VmImage: macOS-10.14
25 changes: 25 additions & 0 deletions .ado/verdaccio/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
max_fails: 40
maxage: 30m
timeout: 60s
agent_options:
keepAlive: true
maxSockets: 40
maxFreeSockets: 10
packages:
'@*/*':
access: $all
publish: $all
proxy: npmjs
'**':
access: $all
publish: $all
proxy: npmjs
logs:
- {type: file, path: verdaccio.log, format: pretty, level: debug}
5 changes: 4 additions & 1 deletion .ado/versionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const fs = require("fs");
const path = require("path");

const pkgJsonPath = path.resolve(__dirname, "../package.json");
const publishBranchName = process.env.BUILD_SOURCEBRANCH.match(/refs\/heads\/(.*)/)[1];
let publishBranchName = '';
try {
publishBranchName = process.env.BUILD_SOURCEBRANCH.match(/refs\/heads\/(.*)/)[1];
} catch (error) {}

function gatherVersionInfo() {
let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
Expand Down
29 changes: 29 additions & 0 deletions .ado/waitForVerdaccio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node
// @ts-check

const http = require('http');
const fs = require('fs');
const path = require('path');

function queryForServerStatus() {

http.get('http://localhost:4873', res => {
console.log(`Server status: ${res.statusCode}`);
if (res.statusCode != 200) {
setTimeout(queryForServerStatus, 2000);
}
}).on('error', err => {
console.log(err.message);
try {
const logFile = fs.readFileSync(path.resolve(__dirname, 'verdaccio/console.log')).toString('utf8');
console.log('verdaccio console output: ' + logFile);
} catch (error) {
console.log('no verdaccio console output yet.');
}
setTimeout(queryForServerStatus, 2000);
});
}

console.log('Waiting for verdaccio instance to respond...');

queryForServerStatus();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "0.60.0-microsoft.68",
"version": "0.60.0-microsoft.69",
"description": "[Microsoft Fork] A framework for building native apps using React",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit bdaa8ad

Please sign in to comment.