Skip to content

Commit 4523826

Browse files
thymikeecpojer
authored andcommitted
Setup for Circle 2 (#4149)
* Setup for Circle 2 * Try to reuse config * Fix aliases and add browser build * Adjust config * Fix save-cache alias * Add website/node_modules to alias cache * Change browser docker * Add working_directory * add yarn-install-no-sudo * Remove environment * Actually skip react-native example on Node 4 * Declare transitive deps in corresponding package.json * Install node 4 deps with yarn * Setup import/no-extraneous-dependencies rule
1 parent f7b25b6 commit 4523826

File tree

13 files changed

+261
-64
lines changed

13 files changed

+261
-64
lines changed

.circleci/config.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
aliases:
2+
- &restore-cache
3+
keys:
4+
- dependencies-{{ .Branch }}-{{ checksum "package.json" }}
5+
# Fallback in case checksum fails
6+
- dependencies-{{ .Branch }}-
7+
8+
- &save-cache
9+
paths:
10+
- node_modules
11+
- website/node_modules
12+
key: dependencies-{{ .Branch }}-{{ checksum "package.json" }}
13+
14+
- &yarn-install
15+
run: |
16+
sudo npm i -g yarn@^0.27.5
17+
yarn --no-progress
18+
19+
- &yarn-install-no-sudo
20+
run: |
21+
npm i -g yarn@^0.27.5
22+
yarn --no-progress
23+
24+
- &deploy
25+
command: |
26+
# Deploy Jest website
27+
git config --global user.email "jest-bot@users.noreply.github.com"
28+
git config --global user.name "Website Deployment Script"
29+
echo "machine github.com login jest-bot password $GITHUB_TOKEN" > ~/.netrc
30+
# crowdin install start
31+
sudo apt-get install default-jre
32+
wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
33+
sudo dpkg -i crowdin.deb
34+
# crowdin install end
35+
crowdin --config crowdin.yaml upload sources --auto-update -b master
36+
crowdin --config crowdin.yaml download -b master
37+
cd website && GIT_USER=jest-bot npm run gh-pages
38+
39+
version: 2
40+
jobs:
41+
test-browser:
42+
working_directory: ~/jest
43+
docker:
44+
- image: markhobson/node-chrome
45+
steps:
46+
- checkout
47+
- restore-cache: *restore-cache
48+
- *yarn-install-no-sudo
49+
- save-cache: *save-cache
50+
- run: yarn run test-ci-es5-build-in-browser
51+
52+
test-node-8:
53+
working_directory: ~/jest
54+
docker:
55+
- image: circleci/node:8.1.4
56+
steps:
57+
- checkout
58+
- restore-cache: *restore-cache
59+
- *yarn-install
60+
- save-cache: *save-cache
61+
- run: yarn run test-ci-partial
62+
63+
test-node-6:
64+
working_directory: ~/jest
65+
docker:
66+
- image: circleci/node:6.11.0
67+
steps:
68+
- checkout
69+
- restore-cache: *restore-cache
70+
- *yarn-install
71+
- save-cache: *save-cache
72+
- run: yarn run test-ci
73+
74+
test-node-4:
75+
working_directory: ~/jest
76+
docker:
77+
- image: circleci/node:4.8.4
78+
steps:
79+
- checkout
80+
- restore-cache: *restore-cache
81+
- *yarn-install
82+
- save-cache: *save-cache
83+
- run: npm run test-ci-partial
84+
85+
test-and-deploy-website:
86+
working_directory: ~/jest
87+
docker:
88+
- image: circleci/node:8.1.4
89+
steps:
90+
- checkout
91+
- restore-cache: *restore-cache
92+
- run: sudo npm i -g yarn@^0.27.5
93+
- run: |
94+
cd website
95+
yarn --no-progress
96+
- save-cache: *save-cache
97+
- run: |
98+
cd website
99+
yarn run test
100+
- deploy: *deploy
101+
102+
# Workflows enables us to run multiple jobs in parallel
103+
workflows:
104+
version: 2
105+
build-and-deploy:
106+
jobs:
107+
- test-node-8
108+
- test-node-6
109+
- test-node-4
110+
- test-browser
111+
- test-and-deploy-website

.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* of patent rights can be found in the PATENTS file in the same directory.
77
*/
88

9+
const path = require('path');
10+
const customImportResolver = path.resolve('./eslint_import_resolver');
11+
912
module.exports = {
1013
extends: [
1114
'./packages/eslint-config-fb-strict/index.js',
@@ -19,6 +22,7 @@ module.exports = {
1922
files: ['*.md'],
2023
rules: {
2124
'consistent-return': 0,
25+
'import/no-extraneous-dependencies': 0,
2226
'import/no-unresolved': 0,
2327
'jest/no-focused-tests': 0,
2428
'jest/no-identical-title': 0,
@@ -76,6 +80,7 @@ module.exports = {
7680
'scripts/**/*',
7781
'integration_tests/*/**/*',
7882
'website/*/**/*',
83+
'eslint_import_resolver.js',
7984
],
8085
rules: {
8186
'prettier/prettier': [
@@ -109,6 +114,17 @@ module.exports = {
109114
'flowtype/require-valid-file-annotation': [2, 'always'],
110115
},
111116
},
117+
{
118+
files: [
119+
'website/**',
120+
'**/__tests__/**',
121+
'integration_tests/**',
122+
'**/pretty-format/perf/**',
123+
],
124+
rules: {
125+
'import/no-extraneous-dependencies': 0,
126+
},
127+
},
112128
],
113129
parser: 'babel-eslint',
114130
plugins: ['markdown', 'import', 'unicorn', 'prettier'],
@@ -120,6 +136,19 @@ module.exports = {
120136
'import/default': 0,
121137
'import/named': 0,
122138
'import/no-duplicates': 2,
139+
'import/no-extraneous-dependencies': [
140+
2,
141+
{
142+
devDependencies: [
143+
'**/__tests__/**',
144+
'**/__mocks__/**',
145+
'**/?(*.)(spec|test).js?(x)',
146+
'scripts/**',
147+
'eslint_import_resolver.js',
148+
'test_setup_file.js',
149+
],
150+
},
151+
],
123152
'import/no-unresolved': [2, {ignore: ['^types/']}],
124153
// This has to be disabled until all type and module imports are combined
125154
// https://github.com/benmosher/eslint-plugin-import/issues/645
@@ -136,4 +165,13 @@ module.exports = {
136165
],
137166
'unicorn/filename-case': [2, {case: 'snakeCase'}],
138167
},
168+
settings: {
169+
'import/resolver': {
170+
[customImportResolver]: {
171+
moduleNameMapper: {
172+
'^types/(.*)': './types/$1',
173+
},
174+
},
175+
},
176+
},
139177
};

circle.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

eslint_import_resolver.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree. An additional grant
6+
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* Adapted from node resolver: https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers/node
9+
*
10+
*/
11+
12+
'use strict';
13+
14+
const resolve = require('resolve');
15+
const path = require('path');
16+
17+
const log = require('debug')('eslint-plugin-import:resolver:node');
18+
19+
module.exports.interfaceVersion = 2;
20+
21+
module.exports.resolve = function(source, file, config) {
22+
log('Resolving:', source, 'from:', file);
23+
let resolvedPath;
24+
25+
if (resolve.isCore(source)) {
26+
log('resolved to core');
27+
return {found: true, path: null};
28+
}
29+
30+
source = applyModuleNameMapper(source, config);
31+
32+
try {
33+
resolvedPath = resolve.sync(source, opts(file, config));
34+
log('Resolved to:', resolvedPath);
35+
return {found: true, path: resolvedPath};
36+
} catch (err) {
37+
log('resolve threw error:', err);
38+
return {found: false};
39+
}
40+
};
41+
42+
function opts(file, config) {
43+
return Object.assign(
44+
{
45+
// more closely matches Node (#333)
46+
extensions: ['.js', '.json'],
47+
},
48+
config,
49+
{
50+
// path.resolve will handle paths relative to CWD
51+
basedir: path.dirname(path.resolve(file)),
52+
packageFilter,
53+
}
54+
);
55+
}
56+
57+
function packageFilter(pkg) {
58+
if (pkg['jsnext:main']) {
59+
pkg['main'] = pkg['jsnext:main'];
60+
}
61+
return pkg;
62+
}
63+
64+
function applyModuleNameMapper(source, config) {
65+
Object.keys(config.moduleNameMapper).forEach(regex => {
66+
const mappedModuleName = config.moduleNameMapper[regex];
67+
68+
if (source.match(regex)) {
69+
const matches = source.match(regex);
70+
if (!matches) {
71+
source = mappedModuleName;
72+
} else {
73+
source = mappedModuleName.replace(
74+
/\$([0-9]+)/g,
75+
(_, index) => matches[parseInt(index, 10)]
76+
);
77+
}
78+
source = path.resolve(source);
79+
}
80+
});
81+
82+
return source;
83+
}

examples/typescript/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"dependencies": {
33
"react": "15.4.2",
4-
"react-dom": "15.4.2"
4+
"react-dom": "15.4.2",
5+
"typescript": "*"
56
},
67
"devDependencies": {
78
"@types/jest": "^19.2.4",
89
"jest": "*",
9-
"react-addons-test-utils": "15.4.2",
10-
"typescript": "*"
10+
"react-addons-test-utils": "15.4.2"
1111
},
1212
"scripts": {
1313
"test": "jest"

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"chalk": "^2.0.1",
2222
"codecov": "^1.0.1",
2323
"cross-spawn": "^5.1.0",
24+
"debug": "^2.6.8",
2425
"enzyme": "^2.8.2",
2526
"eslint": "^4.2.0",
2627
"eslint-config-prettier": "^2.3.0",
@@ -59,6 +60,7 @@
5960
"react-dom": "^15.6.1",
6061
"react-test-renderer": "15.4.2",
6162
"regenerator-runtime": "^0.10.3",
63+
"resolve": "^1.4.0",
6264
"rimraf": "^2.5.4",
6365
"rollup": "^0.41.6",
6466
"rollup-plugin-babel": "^2.7.1",

packages/jest-circus/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
"license": "BSD-3-Clause",
99
"main": "build/index.js",
1010
"dependencies": {
11+
"chalk": "^2.0.1",
1112
"jest-snapshot": "^20.0.3",
1213
"jest-matchers": "^20.0.3",
14+
"jest-matcher-utils": "^20.0.3",
1315
"jest-message-util": "^20.0.3",
1416
"jest-diff": "^20.0.3"
1517
},

packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import type {Environment} from 'types/Environment';
1212
import type {GlobalConfig, ProjectConfig} from 'types/Config';
1313
import type {TestResult} from 'types/TestResult';
14+
// eslint-disable-next-line import/no-extraneous-dependencies
1415
import type Runtime from 'jest-runtime';
1516

1617
const FRAMEWORK_INITIALIZER = require.resolve('./jest-adapter-init');

packages/jest-config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"jest-matcher-utils": "^20.0.3",
1818
"jest-regex-util": "^20.0.3",
1919
"jest-resolve": "^20.0.4",
20+
"jest-util": "^20.0.3",
2021
"jest-validate": "^20.0.3",
2122
"pretty-format": "^20.0.3"
2223
}

packages/jest-jasmine2/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {Environment} from 'types/Environment';
1212
import type {GlobalConfig, ProjectConfig} from 'types/Config';
1313
import type {SnapshotState} from 'jest-snapshot';
1414
import type {TestResult} from 'types/TestResult';
15+
// eslint-disable-next-line import/no-extraneous-dependencies
1516
import type Runtime from 'jest-runtime';
1617

1718
import path from 'path';

0 commit comments

Comments
 (0)