Skip to content
Open
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
85 changes: 85 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#
# Azure Pipelines configuration for building and testing react on Linux, Windows, and macOS.
#

trigger:
- master

jobs:
- job: LinuxBasic
displayName: 'Linux: Basic Tests'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/linux/basic-tests.yml
- template: .azure-pipelines/common/publish-error-codes.yml
parameters:
artifactName: 'error-codes-linux-basic'

- job: LinuxProd
displayName: 'Linux: Prod Tests'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/linux/prod-tests.yml
- template: .azure-pipelines/common/publish-error-codes.yml
parameters:
artifactName: 'error-codes-linux-prod'
Comment thread
kaylangan marked this conversation as resolved.

- job: LinuxFire
displayName: 'Linux: React Fire Tests'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/linux/fire-tests.yml
- template: .azure-pipelines/common/publish-error-codes.yml
parameters:
artifactName: 'error-codes-linux-react-fire'

- job: LinuxArtifacts
displayName: 'Linux: Build and Upload Artifacts'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/linux/build-and-upload-artifacts.yml
- template: .azure-pipelines/common/publish-error-codes.yml
parameters:
artifactName: 'error-codes-linux-build'

- job: LinuxCoverage
displayName: 'Linux: Test Coverage'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/linux/test-coverage.yml

- job: WindowsTests
displayName: 'Windows: Basic Tests'
pool:
vmImage: 'vs2017-win2016'
steps:
- template: .azure-pipelines/common/install.yml
- template: .azure-pipelines/windows/basic-tests.yml
- template: .azure-pipelines/common/publish-error-codes.yml
parameters:
artifactName: 'error-codes-windows-basic'

- job: Lint
displayName: 'Lint'
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: .azure-pipelines/common/install.yml
- script: yarn lint
displayName: 'Run lint'

variables:
AZURE_PIPELINES_BRANCH: $(Build.SourceBranchName)
CI: true
CI_PULL_REQUEST: $[ eq( variables['Build.Reason'], 'PullRequest') ]
REPO_SLUG: $(Build.Repository.Name)
18 changes: 18 additions & 0 deletions .azure-pipelines/common/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Azure Pipelines setup configuration for react on Linux, Windows, and macOS.
#

steps:
- script: |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this step is only needed on Windows, you might move it to the WindowsTests job or into a Windows-specific step template that gets referenced from the WindowsTests job.

(on Linux and macOS jobs, it's just unnecessary noise in the results/log)

git config core.autocrlf input
git reset HEAD --hard
displayName: 'Preserve LF endings on checkout'

- task: NodeTool@0
inputs:
versionSpec: '10.x'
checkLatest: 'true'
displayName: 'Install Node.js'

- script: yarn --frozen-lockfile
displayName: 'Install packages'
10 changes: 10 additions & 0 deletions .azure-pipelines/common/publish-error-codes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Azure Pipelines step to publish error code artifacts for react on Linux, Windows, and macOS.
#

steps:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: './scripts/error-codes/codes.json'
artifactName: ${{ parameters.artifactName }}
displayName: 'Publish error-codes/codes.json'
36 changes: 36 additions & 0 deletions .azure-pipelines/linux/basic-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Azure Pipelines configuration for running tests and other checks on Linux/macOS.
#

steps:
# master branch is needed for Prettier step
- script: git fetch origin master:master
displayName: 'Fetch master branch'

- script: node ./scripts/prettier/index.js
displayName: 'Prettier'

- script: node ./scripts/tasks/flow-ci
displayName: 'Flow CI'

- script: |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd switch this to bash since it uses bash-specific keywords (which would fail if this step template is ever used on Windows). Of course, someone could always fix this later, but I've generally tried to use "bash" instead of just "script" when the script absolutely requires bash.

export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-basic-linux.xml
yarn test --maxWorkers=2
displayName: 'Run tests'

- script: ./scripts/circleci/check_license.sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They may balk at this (and suggest this gets done in a separate PR), but what about renaming scripts/circleci to scripts/ci? One more thing in a theme of generalizing and becoming less tied to any one CI service.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was going to suggest it in the PR description but leave it out for now.

displayName: 'Check license'

- script: ./scripts/circleci/check_modules.sh
displayName: 'Check modules'

- script: ./scripts/circleci/test_print_warnings.sh
displayName: 'Test print warnings'

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Basic'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-basic-linux.xml'
displayName: 'Publish test results to Azure Pipelines'
condition: succeededOrFailed()
55 changes: 55 additions & 0 deletions .azure-pipelines/linux/build-and-upload-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Azure Pipelines configuration for building and uploading artifacts on Linux/macOS.
#

steps:
- script: ./scripts/circleci/add_build_info_json.sh
displayName: 'Add build info json'

- script: ./scripts/circleci/update_package_versions.sh
displayName: 'Update package versions'

- script: ./scripts/circleci/build.sh
displayName: 'Build'

- script: |
export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-build-linux.xml
yarn test-build --maxWorkers=2
displayName: 'Run build tests'

- script: |
export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-build-prod-linux.xml
yarn test-build-prod --maxWorkers=2
displayName: 'Run build prod tests'

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Build'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-build-linux.xml'
displayName: 'Publish build test results to Azure Pipelines'
condition: succeededOrFailed()

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Build Prod'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-build-prod-linux.xml'
displayName: 'Publish build prod test results to Azure Pipelines'
condition: succeededOrFailed()

- script: node ./scripts/tasks/danger
displayName: 'Danger'

- script: ./scripts/circleci/upload_build.sh
displayName: 'Upload build'

- script: ./scripts/circleci/pack_and_store_artifact.sh
displayName: 'Pack artifacts'

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: './node_modules.tgz'
artifactName: 'node_modules'
publishLocation: 'container'
displayName: 'Publish node_modules.tgz'
30 changes: 30 additions & 0 deletions .azure-pipelines/linux/fire-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Azure Pipelines configuration for running React Fire tests on Linux/macOS.
#

steps:
- script: |
export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-fire-linux.xml
yarn test-fire --maxWorkers=2
displayName: 'Run Fire tests'

- script: |
export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-fire-prod-linux.xml
yarn test-fire-prod --maxWorkers=2
displayName: 'Run Fire prod tests'

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Fire'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-fire-linux.xml'
displayName: 'Publish Fire test results to Azure Pipelines'
condition: succeededOrFailed()

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Fire Prod'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-fire-prod-linux.xml'
displayName: 'Publish Fire prod test results to Azure Pipelines'
condition: succeededOrFailed()
17 changes: 17 additions & 0 deletions .azure-pipelines/linux/prod-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Azure Pipelines configuration for running prod tests on Linux/macOS.
#

steps:
- script: |
export JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-prod-linux.xml
yarn test-prod --maxWorkers=2
displayName: 'Run prod tests'

- task: PublishTestResults@2
inputs:
testRunTitle: 'Linux: Prod'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-prod-linux.xml'
displayName: 'Publish test results to Azure Pipelines'
condition: succeededOrFailed()
7 changes: 7 additions & 0 deletions .azure-pipelines/linux/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Azure Pipelines configuration for running test coverage on Linux/macOS.
#

steps:
- script: ./scripts/circleci/test_coverage.sh
displayName: 'Test coverage'
25 changes: 25 additions & 0 deletions .azure-pipelines/windows/basic-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Azure Pipelines configuration for building and testing react on Windows.
#

steps:
- script: yarn build
displayName: 'Build'

- script: set JEST_JUNIT_OUTPUT=.azure-pipelines/test-results/test-basic-windows.xml&&yarn test
Comment thread
kaylangan marked this conversation as resolved.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been setting the env property of script when i need a variable to exist only for one step:

script: yarn test
env:
  JEST_JUNIT_OUTPUT: '.azure-pipelines/test-results/test-basic-windows.xml'

displayName: 'Run tests'

# master branch is needed for Prettier step
- script: git fetch origin master:master
displayName: 'Fetch master branch'

- script: yarn prettier
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why prettier is invoked differently in Windows vs. Linux? In Linux, the step has this:

node ./scripts/prettier/index

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's intentional; more a side effect of having developed the AppVeyor and Circle processes separately. yarn prettier runs node ./scripts/prettier/index write-changed which is probably only appropriate locally. So I would suggest either changing the line you highlighted to node ./scripts/prettier/index or adding another script to the package. I'm leaning adding prettier-ci to the package.json...what do you think?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything...if we add prettier-ci to the package, we can add the git fetch origin master:master to that script.

displayName: 'Prettier'

- task: PublishTestResults@2
inputs:
testRunTitle: 'Windows: Basic'
testResultsFormat: 'JUnit'
testResultsFiles: '.azure-pipelines/test-results/test-basic-windows.xml'
displayName: 'Publish test results to Azure Pipelines'
condition: succeededOrFailed()
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ chrome-user-data
.vscode
*.swp
*.swo
junit.xml
.azure-pipelines/test-results/
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"jasmine-check": "^1.0.0-rc.0",
"jest": "^23.1.0",
"jest-diff": "^23.0.1",
"jest-junit": "^6.3.0",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
Expand Down Expand Up @@ -90,7 +91,8 @@
"node": "8.x || 9.x || 10.x || 11.x || 12.x"
},
"jest": {
"testRegex": "/scripts/jest/dont-run-jest-directly\\.js$"
"testRegex": "/scripts/jest/dont-run-jest-directly\\.js$",
"reporters": ["default", "jest-junit"]
},
"scripts": {
"build": "node ./scripts/rollup/build.js",
Expand Down
1 change: 1 addition & 0 deletions scripts/jest/config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module.exports = {
roots: ['<rootDir>/packages', '<rootDir>/scripts'],
collectCoverageFrom: ['packages/**/*.js'],
timers: 'fake',
reporters: ['default', 'jest-junit'],
};
Loading