Skip to content

Commit

Permalink
Merge pull request #2 from willsmythe/master
Browse files Browse the repository at this point in the history
Azure Pipelines support (Linux, macOS, and Windows)
  • Loading branch information
ianschmitz authored May 1, 2019
2 parents a55dc7a + a3b6629 commit 582ccf1
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 106 deletions.
40 changes: 40 additions & 0 deletions azure-pipelines-test-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Azure Pipelines job for building and testing create-react-app on Linux, Windows, and macOS.
#

parameters:
name: ''
testScript: ''
configurations:
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }

jobs:
- job: ${{ parameters.name }}
strategy:
matrix:
${{ insert }}: ${{ parameters.configurations }}
pool:
vmImage: $(vmImage)
steps:
- script: |
git config --global core.autocrlf false
git config --global user.name "Create React App"
git config --global user.email "cra@email.com"
displayName: 'Initialize Git config'
- checkout: self
path: create-react-app

- task: NodeTool@0
inputs:
versionSpec: $(nodeVersion)
displayName: 'Install Node.js'

- script: yarn --frozen-lockfile
displayName: 'Run yarn'

- bash: ${{ parameters.testScript }}
displayName: 'Run tests'
84 changes: 78 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,78 @@
pool:
vmImage: 'Ubuntu 16.04'

steps:
- script: echo Hello world!
displayName: Say hello
#
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS.
#

trigger:
- master

variables:
CI: true
# 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.
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache
# 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.
VSTS_OVERWRITE_TEMP: True
# 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.
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz

# ******************************************************************************
# Simple test suite
# ******************************************************************************
jobs:
- template: azure-pipelines-test-job.yml
parameters:
name: Simple
testScript: tasks/e2e-simple.sh

# ******************************************************************************
# Installs test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Installs
testScript: tasks/e2e-installs.sh

# ******************************************************************************
# Kitchensink test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Kitchensink
testScript: tasks/e2e-kitchensink.sh

# ******************************************************************************
# Kitchensink Eject test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: KitchensinkEject
testScript: tasks/e2e-kitchensink-eject.sh

# ******************************************************************************
# Behavior test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Behavior
testScript: tasks/e2e-behavior.sh
configurations:
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x }
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x }

# ******************************************************************************
# Old Node test suite
# ******************************************************************************
- job: OldNode
pool:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
inputs:
versionSpec: 6.x
displayName: 'Install Node.js 6.x'
- bash: tasks/e2e-old-node.sh
displayName: 'Run tests'
2 changes: 1 addition & 1 deletion packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
setupFilesAfterEnv: setupTestsFile ? [setupTestsFile] : [],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*(*.)@(spec|test).{js,jsx,ts,tsx}',
],
testEnvironment: 'jest-environment-jsdom-fourteen',
transform: {
Expand Down
28 changes: 8 additions & 20 deletions tasks/e2e-behavior.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ cd "$(dirname "$0")"
# CLI, app, and test module temporary locations
# http://unix.stackexchange.com/a/84980
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
custom_registry_url=http://localhost:4873
original_npm_registry_url=`npm get registry`
original_yarn_registry_url=`yarn config get registry`

# Load functions for working with local NPM registry (Verdaccio)
source local-registry.sh

function cleanup {
echo 'Cleaning up.'
ps -ef | grep 'verdaccio' | grep -v grep | awk '{print $2}' | xargs kill -9
echo 'Cleaning up.'
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
cd "$root_path"
npm set registry "$original_npm_registry_url"
yarn config set registry "$original_yarn_registry_url"
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
stopLocalRegistry
}

# Error messages are redirected to stderr
Expand Down Expand Up @@ -75,18 +73,8 @@ yarn
# First, publish the monorepo.
# ******************************************************************************

# Start local registry
tmp_registry_log=`mktemp`
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

# Login so we can publish packages
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Publish the monorepo
git clean -df
Expand Down
25 changes: 7 additions & 18 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ cd "$(dirname "$0")"
# CLI and app temporary locations
# http://unix.stackexchange.com/a/84980
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
custom_registry_url=http://localhost:4873
original_npm_registry_url=`npm get registry`
original_yarn_registry_url=`yarn config get registry`

# Load functions for working with local NPM registry (Verdaccio)
source local-registry.sh

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

# Error messages are redirected to stderr
Expand Down Expand Up @@ -96,18 +95,8 @@ yarn
# First, publish the monorepo.
# ******************************************************************************

# Start local registry
tmp_registry_log=`mktemp`
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

# Login so we can publish packages
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Publish the monorepo
git clean -df
Expand Down
25 changes: 7 additions & 18 deletions tasks/e2e-kitchensink-eject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ cd "$(dirname "$0")"
# http://unix.stackexchange.com/a/84980
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
custom_registry_url=http://localhost:4873
original_npm_registry_url=`npm get registry`
original_yarn_registry_url=`yarn config get registry`

# Load functions for working with local NPM registry (Verdaccio)
source local-registry.sh

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

# Error messages are redirected to stderr
Expand Down Expand Up @@ -78,18 +77,8 @@ yarn
# First, publish the monorepo.
# ******************************************************************************

# Start local registry
tmp_registry_log=`mktemp`
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

# Login so we can publish packages
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Publish the monorepo
git clean -df
Expand Down
25 changes: 7 additions & 18 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ cd "$(dirname "$0")"
# http://unix.stackexchange.com/a/84980
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
custom_registry_url=http://localhost:4873
original_npm_registry_url=`npm get registry`
original_yarn_registry_url=`yarn config get registry`

# Load functions for working with local NPM registry (Verdaccio)
source local-registry.sh

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

# Error messages are redirected to stderr
Expand Down Expand Up @@ -78,18 +77,8 @@ yarn
# First, publish the monorepo.
# ******************************************************************************

# Start local registry
tmp_registry_log=`mktemp`
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

# Login so we can publish packages
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Publish the monorepo
git clean -df
Expand Down
29 changes: 11 additions & 18 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ cd "$(dirname "$0")"
# App temporary location
# http://unix.stackexchange.com/a/84980
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
custom_registry_url=http://localhost:4873
original_npm_registry_url=`npm get registry`
original_yarn_registry_url=`yarn config get registry`

# Load functions for working with local NPM registry (Verdaccio)
source local-registry.sh

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

# Error messages are redirected to stderr
Expand Down Expand Up @@ -85,18 +84,8 @@ fi
# Bootstrap monorepo
yarn

# Start local registry
tmp_registry_log=`mktemp`
(cd && nohup npx verdaccio@3.8.2 -c "$root_path"/tasks/verdaccio.yaml &>$tmp_registry_log &)
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

# Login so we can publish packages
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Lint own code
./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/
Expand Down Expand Up @@ -270,6 +259,10 @@ verify_module_scope
# Eject...
echo yes | npm run eject

# Temporary workaround for https://github.com/facebook/create-react-app/issues/6099
rm yarn.lock
yarn add @babel/plugin-transform-react-jsx-source @babel/plugin-syntax-jsx @babel/plugin-transform-react-jsx @babel/plugin-transform-react-jsx-self

# Test ejected files were staged
test -n "$(git diff --staged --name-only)"

Expand Down
Loading

0 comments on commit 582ccf1

Please sign in to comment.