Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: initial Azure Pipelines support #7556

Merged
merged 6 commits into from
Jan 14, 2019
Merged
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
45 changes: 45 additions & 0 deletions .azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Steps for building and testing Jest. See jobs defined in .azure-pipelines.yml
#

# Clones the repo
steps:
- checkout: self

# Ensure Node.js 10 is active
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Use Node.js 10'

# Ensure Python 2.7 is active
- task: UsePythonVersion@0
inputs:
versionSpec: '2.7'
displayName: 'Use Python 2.7'

# Workaround to move source files under a "jest" folder (see .azure-pipelines.yml for details)
- script: |
cd /
mv $(Build.Repository.LocalPath) $(JEST_DIR)
mkdir $(Build.Repository.LocalPath)
displayName: 'Move source into jest folder'

# Run yarn to install dependencies and build
- script: yarn
workingDirectory: $(JEST_DIR)
displayName: 'Install dependencies and build'

# Run test-ci-partial
- script: yarn run test-ci-partial
workingDirectory: $(JEST_DIR)
displayName: 'Run tests'

# Publish CI test results
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/reports/junit/*.xml'
searchFolder: $(JEST_DIR)
testRunTitle: 'CI Tests $(Agent.OS)'
displayName: 'Publish test results'
condition: succeededOrFailed()
40 changes: 40 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Azure Pipelines configuration for building and testing Jest on Linux, Windows, and macOS.
#

jobs:
- job: Linux
pool:
vmImage: ubuntu-16.04
steps:
- template: .azure-pipelines-steps.yml

- job: Windows
pool:
vmImage: vs2017-win2016
steps:
- script: |
git config --global core.autocrlf false
git config --global core.symlinks true
displayName: 'Preserve LF endings and symbolic links on check out'
- template: .azure-pipelines-steps.yml

- job: macOS
pool:
vmImage: macos-10.13
steps:
# This step can be removed once Mercurial gets installed on the macOS image. See https://github.com/Microsoft/azure-pipelines-image-generation/issues/604
- script: HOMEBREW_NO_AUTO_UPDATE=1 brew install mercurial
displayName: 'Install Mercurial'
- template: .azure-pipelines-steps.yml

variables:
# Used by chalk. Ensures output from Jest includes ANSI escape characters that are needed to match test snapshots.
FORCE_COLOR: 1

# By default, Azure Pipelines clones to an "s" directory, which causes tests to fail due to assumption of Jest being run from a "jest" directory.
# See packages/jest-message-util/src/index.js PATH_JEST_PACKAGES for more details.
JEST_DIR: $(Agent.BuildDirectory)/jest

# Ensures the handful of tests that should be skipped during CI are
CI: true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
- `[docs]` Add `testPathIgnorePatterns` in CLI documentation ([#7440](https://github.com/facebook/jest/pull/7440))
- `[docs]` Removed misleading text about `describe()` grouping together tests into a test suite ([#7434](https://github.com/facebook/jest/pull/7434))
- `[*]` Replace as many `Object.assign` with object spread as possible
- `[ci]` Initial support for Azure Pipelines ([#7556](https://github.com/facebook/jest/pull/7556))

### Performance

Expand Down
8 changes: 5 additions & 3 deletions e2e/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ export const createEmptyPackage = (
};

export const extractSummary = (stdout: string) => {
const match = stdout.match(
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm,
);
const match = stdout
.replace(/(?:\\[rn])+/g, '\n')
.match(
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm,
);
if (!match) {
throw new Error(
`
Expand Down
3 changes: 2 additions & 1 deletion e2e/__tests__/hasteMapSize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import os from 'os';
import path from 'path';
import HasteMap from 'jest-haste-map';
import {cleanup, writeFiles} from '../Utils';
import {sync as realpath} from 'realpath-native';

const DIR = path.resolve(os.tmpdir(), 'haste_map_size');
const DIR = path.resolve(realpath(os.tmpdir()), 'haste_map_size');
SimenB marked this conversation as resolved.
Show resolved Hide resolved

beforeEach(() => {
cleanup(DIR);
Expand Down
4 changes: 2 additions & 2 deletions e2e/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function runJest(
args?: Array<string>,
options: RunJestOptions = {},
) {
const isRelative = dir[0] !== '/';
const isRelative = !path.isAbsolute(dir);

if (isRelative) {
dir = path.resolve(__dirname, dir);
Expand Down Expand Up @@ -101,7 +101,7 @@ export const until = async function(
text: string,
options: RunJestOptions = {},
) {
const isRelative = dir[0] !== '/';
const isRelative = !path.isAbsolute(dir);

if (isRelative) {
dir = path.resolve(__dirname, dir);
Expand Down
14 changes: 9 additions & 5 deletions packages/jest-config/src/getCacheDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
const path = require('path');
const os = require('os');

import {sync as realpath} from 'realpath-native';

const getCacheDirectory = () => {
const {getuid} = process;
const tmpdir = path.join(realpath(os.tmpdir()), 'jest');
if (getuid == null) {
return path.join(os.tmpdir(), 'jest');
return tmpdir;
} else {
// On some platforms tmpdir() is `/tmp`, causing conflicts between different
// users and permission issues. Adding an additional subdivision by UID can
// help.
return `${tmpdir}_${getuid.call(process).toString(36)}`;
}
// On some platforms tmpdir() is `/tmp`, causing conflicts between different
// users and permission issues. Adding an additional subdivision by UID can
// help.
return path.join(os.tmpdir(), 'jest_' + getuid.call(process).toString(36));
};

export default getCacheDirectory;