Skip to content

Commit 7b196fa

Browse files
authored
Add Azure DevOps build pipeline (#7096)
1 parent 695ca75 commit 7b196fa

17 files changed

+267
-175
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Create React App [![Build Status](https://travis-ci.org/facebook/create-react-app.svg?branch=master)](https://travis-ci.org/facebook/create-react-app) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls)
1+
# Create React App [![Build Status](https://dev.azure.com/facebook/create-react-app/_apis/build/status/facebook.create-react-app?branchName=master)](https://dev.azure.com/facebook/create-react-app/_build/latest?definitionId=1&branchName=master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls)
22

33
Create React apps with no build configuration.
44

azure-pipelines-test-job.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Azure Pipelines job for building and testing create-react-app on Linux, Windows, and macOS.
3+
#
4+
5+
parameters:
6+
name: ''
7+
testScript: ''
8+
configurations:
9+
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
10+
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
11+
WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
12+
WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }
13+
14+
jobs:
15+
- job: ${{ parameters.name }}
16+
strategy:
17+
matrix:
18+
${{ insert }}: ${{ parameters.configurations }}
19+
pool:
20+
vmImage: $(vmImage)
21+
steps:
22+
- script: |
23+
git config --global core.autocrlf false
24+
git config --global user.name "Create React App"
25+
git config --global user.email "cra@email.com"
26+
displayName: 'Initialize Git config'
27+
28+
- checkout: self
29+
path: create-react-app
30+
31+
- task: NodeTool@0
32+
inputs:
33+
versionSpec: $(nodeVersion)
34+
displayName: 'Install Node.js'
35+
36+
- script: yarn --frozen-lockfile
37+
displayName: 'Run yarn'
38+
39+
- bash: ${{ parameters.testScript }}
40+
displayName: 'Run tests'

azure-pipelines.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS.
3+
#
4+
5+
trigger:
6+
- master
7+
8+
variables:
9+
CI: true
10+
# Overrides the Yarn and NPM cache directories so they are on the same drive as the source. This helps improve build performance on Windows hosted agents.
11+
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache
12+
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache
13+
# Sets TEMP to be on the same drive as the cloned source on Windows. This avoids test scripts that "cd" into a directory under TEMP from failing because this directory is on a different drive from the current directory.
14+
VSTS_OVERWRITE_TEMP: True
15+
# Override Verdaccio package to use. This is temoporary and is needed to avoid socket timeouts on hosted Windows agent (on Azure). This also changes Verdaccio to return a 503 (service unavailable) instead of a 404 (not found) when the connection to the uplink timesout.
16+
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz
17+
18+
# ******************************************************************************
19+
# Simple test suite
20+
# ******************************************************************************
21+
jobs:
22+
- template: azure-pipelines-test-job.yml
23+
parameters:
24+
name: Simple
25+
testScript: tasks/e2e-simple.sh
26+
27+
# ******************************************************************************
28+
# Installs test suite
29+
# ******************************************************************************
30+
- template: azure-pipelines-test-job.yml
31+
parameters:
32+
name: Installs
33+
testScript: tasks/e2e-installs.sh
34+
35+
# ******************************************************************************
36+
# Kitchensink test suite
37+
# ******************************************************************************
38+
- template: azure-pipelines-test-job.yml
39+
parameters:
40+
name: Kitchensink
41+
testScript: tasks/e2e-kitchensink.sh
42+
43+
# ******************************************************************************
44+
# Kitchensink Eject test suite
45+
# ******************************************************************************
46+
- template: azure-pipelines-test-job.yml
47+
parameters:
48+
name: KitchensinkEject
49+
testScript: tasks/e2e-kitchensink-eject.sh
50+
51+
# ******************************************************************************
52+
# Behavior test suite
53+
# ******************************************************************************
54+
- template: azure-pipelines-test-job.yml
55+
parameters:
56+
name: Behavior
57+
testScript: tasks/e2e-behavior.sh
58+
configurations:
59+
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
60+
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
61+
WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
62+
WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }
63+
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x }
64+
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x }
65+
66+
# ******************************************************************************
67+
# Old Node test suite
68+
# ******************************************************************************
69+
- job: OldNode
70+
pool:
71+
vmImage: ubuntu-16.04
72+
steps:
73+
- task: NodeTool@0
74+
inputs:
75+
versionSpec: 6.x
76+
displayName: 'Install Node.js 6.x'
77+
- bash: tasks/e2e-old-node.sh
78+
displayName: 'Run tests'

tasks/e2e-behavior.sh

+9-22
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ cd "$(dirname "$0")"
1515
# CLI, app, and test module temporary locations
1616
# http://unix.stackexchange.com/a/84980
1717
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
18-
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
19-
custom_registry_url=http://localhost:4873
20-
original_npm_registry_url=`npm get registry`
21-
original_yarn_registry_url=`yarn config get registry`
18+
19+
# Load functions for working with local NPM registry (Verdaccio)
20+
source local-registry.sh
2221

2322
function cleanup {
24-
echo 'Cleaning up.'
25-
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
23+
echo 'Cleaning up.'
2624
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
2725
cd "$root_path"
28-
npm set registry "$original_npm_registry_url"
29-
yarn config set registry "$original_yarn_registry_url"
26+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
27+
stopLocalRegistry
3028
}
3129

3230
# Error messages are redirected to stderr
@@ -75,22 +73,11 @@ yarn
7573
# First, publish the monorepo.
7674
# ******************************************************************************
7775

78-
# Start local registry
79-
tmp_registry_log=`mktemp`
80-
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
81-
# Wait for `verdaccio` to boot
82-
grep -q 'http address' <(tail -f $tmp_registry_log)
83-
84-
# Set registry to local registry
85-
npm set registry "$custom_registry_url"
86-
yarn config set registry "$custom_registry_url"
87-
88-
# Login so we can publish packages
89-
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
76+
# Start the local NPM registry
77+
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
9078

9179
# Publish the monorepo
92-
git clean -df
93-
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
80+
publishToLocalRegistry
9481

9582
# ******************************************************************************
9683
# Now that we have published them, run all tests as if they were released.

tasks/e2e-installs.sh

+8-20
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ cd "$(dirname "$0")"
1515
# CLI and app temporary locations
1616
# http://unix.stackexchange.com/a/84980
1717
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
18-
custom_registry_url=http://localhost:4873
19-
original_npm_registry_url=`npm get registry`
20-
original_yarn_registry_url=`yarn config get registry`
18+
19+
# Load functions for working with local NPM registry (Verdaccio)
20+
source local-registry.sh
2121

2222
function cleanup {
2323
echo 'Cleaning up.'
24-
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
2524
cd "$root_path"
2625
rm -rf "$temp_app_path"
27-
npm set registry "$original_npm_registry_url"
28-
yarn config set registry "$original_yarn_registry_url"
26+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
27+
stopLocalRegistry
2928
}
3029

3130
# Error messages are redirected to stderr
@@ -96,22 +95,11 @@ yarn
9695
# First, publish the monorepo.
9796
# ******************************************************************************
9897

99-
# Start local registry
100-
tmp_registry_log=`mktemp`
101-
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
102-
# Wait for `verdaccio` to boot
103-
grep -q 'http address' <(tail -f $tmp_registry_log)
104-
105-
# Set registry to local registry
106-
npm set registry "$custom_registry_url"
107-
yarn config set registry "$custom_registry_url"
108-
109-
# Login so we can publish packages
110-
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
98+
# Start the local NPM registry
99+
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
111100

112101
# Publish the monorepo
113-
git clean -df
114-
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
102+
publishToLocalRegistry
115103

116104
echo "Create React App Version: "
117105
npx create-react-app --version

tasks/e2e-kitchensink-eject.sh

+8-20
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ cd "$(dirname "$0")"
1616
# http://unix.stackexchange.com/a/84980
1717
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
1818
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
19-
custom_registry_url=http://localhost:4873
20-
original_npm_registry_url=`npm get registry`
21-
original_yarn_registry_url=`yarn config get registry`
19+
20+
# Load functions for working with local NPM registry (Verdaccio)
21+
source local-registry.sh
2222

2323
function cleanup {
2424
echo 'Cleaning up.'
2525
unset BROWSERSLIST
26-
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
2726
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
2827
cd "$root_path"
2928
# TODO: fix "Device or resource busy" and remove ``|| $CI`
3029
rm -rf "$temp_app_path" "$temp_module_path" || $CI
31-
npm set registry "$original_npm_registry_url"
32-
yarn config set registry "$original_yarn_registry_url"
30+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
31+
stopLocalRegistry
3332
}
3433

3534
# Error messages are redirected to stderr
@@ -78,22 +77,11 @@ yarn
7877
# First, publish the monorepo.
7978
# ******************************************************************************
8079

81-
# Start local registry
82-
tmp_registry_log=`mktemp`
83-
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
84-
# Wait for `verdaccio` to boot
85-
grep -q 'http address' <(tail -f $tmp_registry_log)
86-
87-
# Set registry to local registry
88-
npm set registry "$custom_registry_url"
89-
yarn config set registry "$custom_registry_url"
90-
91-
# Login so we can publish packages
92-
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
80+
# Start the local NPM registry
81+
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
9382

9483
# Publish the monorepo
95-
git clean -df
96-
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
84+
publishToLocalRegistry
9785

9886
# ******************************************************************************
9987
# Now that we have published them, create a clean app folder and install them.

tasks/e2e-kitchensink.sh

+8-20
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ cd "$(dirname "$0")"
1616
# http://unix.stackexchange.com/a/84980
1717
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
1818
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
19-
custom_registry_url=http://localhost:4873
20-
original_npm_registry_url=`npm get registry`
21-
original_yarn_registry_url=`yarn config get registry`
19+
20+
# Load functions for working with local NPM registry (Verdaccio)
21+
source local-registry.sh
2222

2323
function cleanup {
2424
echo 'Cleaning up.'
2525
unset BROWSERSLIST
26-
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
2726
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
2827
cd "$root_path"
2928
# TODO: fix "Device or resource busy" and remove ``|| $CI`
3029
rm -rf "$temp_app_path" "$temp_module_path" || $CI
31-
npm set registry "$original_npm_registry_url"
32-
yarn config set registry "$original_yarn_registry_url"
30+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
31+
stopLocalRegistry
3332
}
3433

3534
# Error messages are redirected to stderr
@@ -78,22 +77,11 @@ yarn
7877
# First, publish the monorepo.
7978
# ******************************************************************************
8079

81-
# Start local registry
82-
tmp_registry_log=`mktemp`
83-
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
84-
# Wait for `verdaccio` to boot
85-
grep -q 'http address' <(tail -f $tmp_registry_log)
86-
87-
# Set registry to local registry
88-
npm set registry "$custom_registry_url"
89-
yarn config set registry "$custom_registry_url"
90-
91-
# Login so we can publish packages
92-
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
80+
# Start the local NPM registry
81+
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
9382

9483
# Publish the monorepo
95-
git clean -df
96-
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
84+
publishToLocalRegistry
9785

9886
# ******************************************************************************
9987
# Now that we have published them, create a clean app folder and install them.

tasks/e2e-simple.sh

+9-20
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ cd "$(dirname "$0")"
1515
# App temporary location
1616
# http://unix.stackexchange.com/a/84980
1717
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
18-
custom_registry_url=http://localhost:4873
19-
original_npm_registry_url=`npm get registry`
20-
original_yarn_registry_url=`yarn config get registry`
18+
19+
# Load functions for working with local NPM registry (Verdaccio)
20+
source local-registry.sh
2121

2222
function cleanup {
2323
echo 'Cleaning up.'
24-
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
2524
cd "$root_path"
2625
# Uncomment when snapshot testing is enabled by default:
2726
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
2827
rm -rf "$temp_app_path"
29-
npm set registry "$original_npm_registry_url"
30-
yarn config set registry "$original_yarn_registry_url"
28+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
29+
stopLocalRegistry
3130
}
3231

3332
# Error messages are redirected to stderr
@@ -85,18 +84,8 @@ fi
8584
# Bootstrap monorepo
8685
yarn
8786

88-
# Start local registry
89-
tmp_registry_log=`mktemp`
90-
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
91-
# Wait for `verdaccio` to boot
92-
grep -q 'http address' <(tail -f $tmp_registry_log)
93-
94-
# Set registry to local registry
95-
npm set registry "$custom_registry_url"
96-
yarn config set registry "$custom_registry_url"
97-
98-
# Login so we can publish packages
99-
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
87+
# Start the local NPM registry
88+
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
10089

10190
# Lint own code
10291
./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/
@@ -149,8 +138,8 @@ CI=true yarn test
149138
# Test local start command
150139
yarn start --smoke-test
151140

152-
git clean -df
153-
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
141+
# Publish the monorepo
142+
publishToLocalRegistry
154143

155144
# ******************************************************************************
156145
# Install react-scripts prerelease via create-react-app prerelease.

0 commit comments

Comments
 (0)