Skip to content

Commit edc77c0

Browse files
authored
Shared Jest Cache + Shared devDeps + Incremental builds + Reverts outputs dependencies (#3694)
1 parent 10ed898 commit edc77c0

File tree

98 files changed

+2272
-2833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2272
-2833
lines changed

.github/workflows/main.yml

+25-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,36 @@ jobs:
2222
- name: Use Node ${{matrix.node_version}}
2323
uses: actions/setup-node@master
2424
with:
25-
version: ${{ matrix.node_version }}
25+
node-version: ${{ matrix.node_version }}
26+
- name: Get yarn cache
27+
id: yarn-cache
28+
run: echo "::set-output name=dir::$(yarn cache dir)"
29+
if: matrix.os != 'macos-latest'
30+
- name: Cache Yarn
31+
uses: actions/cache@v1
32+
if: matrix.os != 'macos-latest'
33+
with:
34+
path: ${{ steps.yarn-cache.outputs.dir }}
35+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-yarn-
38+
- name: Cache Jest
39+
uses: actions/cache@v1
40+
with:
41+
path: .cache/jest
42+
key: ${{ runner.os }}-jest-${{ hashFiles('yarn.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-jest-
2645
- name: Install Dependencies using Yarn
2746
run: yarn install
2847
- name: Lint
2948
run: yarn lint
3049
- name: Build
3150
run: yarn build
3251
- name: Test
33-
run: yarn test
52+
run: yarn test --logHeapUsage
53+
env:
54+
CI: true
3455
- name: Test dev-tests
3556
run: |
3657
dev-test/generate-all.sh
@@ -43,7 +64,7 @@ jobs:
4364
- name: Checkout Master
4465
uses: actions/checkout@v1
4566
- name: Use Node
46-
uses: actions/setup-node@v1
67+
uses: actions/setup-node@master
4768
with:
4869
node-version: '13.x'
4970
- name: Install Dependencies using Yarn
@@ -62,12 +83,11 @@ jobs:
6283
6384
if [ "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" != "" ]
6485
then
65-
npm install -g dfds-github-scripts
6686
export BUILD_REPOSITORY_NAME="${{github.repository}}"
6787
export ALPHA_VERSION=`cat out.txt | sed -n 's/.*cli => //p' | sed -n 's/+.*//p'`
6888
export GH_API_TOKEN="${{ secrets.GH_API_TOKEN }}"
6989
export COMMENT_BODY="The latest changes of this PR are available as alpha in npm: \`$ALPHA_VERSION\`"
70-
pr-comment
90+
./scripts/comment.js
7191
fi
7292
else
7393
echo "Skipping canary publish due to a fork/PR..."

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ temp
1414
test-results/
1515
junit.xml
1616
dist
17-
out.txt
17+
bob/
18+
out.txt
19+
.cache

jest.config.js

+10-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
1-
module.exports = {
2-
collectCoverageFrom: [
3-
'packages/**/src/**/*.ts',
4-
'!packages/utils/**/*',
5-
'!**/*.d.ts'
6-
],
7-
coverageDirectory: 'coverage',
8-
coverageReporters: ['html', 'lcov', 'text'],
9-
preset: 'ts-jest',
10-
testEnvironment: 'node',
11-
rootDir: __dirname,
12-
globals: {
13-
'ts-jest': {
14-
diagnostics: false,
15-
},
16-
},
17-
reporters: [
18-
'default',
19-
[
20-
'jest-junit',
21-
{
22-
classNameTemplate: '{classname}',
23-
titleTemplate: '{title}',
24-
addFileAttribute: 'true',
25-
},
26-
],
27-
],
28-
roots: ['<rootDir>/packages'],
29-
modulePathIgnorePatterns: ['<rootDir>/packages/.*/dist/'],
30-
moduleNameMapper: {
31-
'^@graphql-codegen/cli$': '<rootDir>/packages/graphql-codegen-cli/src/index.ts',
32-
'^@graphql-codegen/core$': '<rootDir>/packages/graphql-codegen-core/src/index.ts',
33-
34-
'^@graphql-codegen/(typescript|flow|java)$': '<rootDir>/packages/plugins/$1/$1/src/index.ts',
35-
'^@graphql-codegen/(typescript|flow|java)-([\\w-]+)$': '<rootDir>/packages/plugins/$1/$2/src/index.ts',
36-
'^@graphql-codegen/kotlin$': '<rootDir>/packages/plugins/java/kotlin/src/index.ts',
37-
38-
'^@graphql-codegen/add$': '<rootDir>/packages/plugins/other/add/src/index.ts',
39-
'^@graphql-codegen/fragment-matcher$': '<rootDir>/packages/plugins/other/fragment-matcher/src/index.ts',
40-
'^@graphql-codegen/introspection$': '<rootDir>/packages/plugins/other/introspection/src/index.ts',
41-
'^@graphql-codegen/schema-ast$': '<rootDir>/packages/plugins/other/schema-ast/src/index.ts',
42-
'^@graphql-codegen/time$': '<rootDir>/packages/plugins/other/time/src/index.ts',
43-
'^@graphql-codegen/visitor-plugin-common$': '<rootDir>/packages/plugins/other/visitor-plugin-common/src/index.ts',
44-
45-
'^@graphql-codegen/import-types-preset$': '<rootDir>/packages/presets/import-types/src/index.ts',
46-
'^@graphql-codegen/near-operation-file-preset$': '<rootDir>/packages/presets/near-operation-file/src/index.ts',
47-
48-
'^@graphql-codegen/config-markdown-generator$': '<rootDir>/packages/utils/config-md-generator/src/index.ts',
49-
'^@graphql-codegen/testing$': '<rootDir>/packages/utils/graphql-codegen-testing/src/index.ts',
50-
'^@graphql-codegen/plugin-helpers$': '<rootDir>/packages/utils/plugins-helpers/src/index.ts'
51-
},
52-
};
1+
const PROJECTS = false;
2+
const CI = !!process.env.CI;
3+
4+
module.exports =
5+
!PROJECTS || CI
6+
? require('./jest.project')({ dirname: __dirname, projectMode: PROJECTS })
7+
: {
8+
rootDir: __dirname,
9+
projects: ['<rootDir>/packages/**/*/jest.config.js'],
10+
};

jest.project.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { resolve } = require('path');
2+
const { pathsToModuleNameMapper } = require('ts-jest/utils');
3+
4+
const ROOT_DIR = __dirname;
5+
const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json');
6+
const tsconfig = require(TSCONFIG);
7+
const CI = !!process.env.CI;
8+
9+
module.exports = ({ dirname, projectMode = true }) => {
10+
const pkg = require(resolve(dirname, 'package.json'));
11+
12+
return {
13+
...(CI || !projectMode ? {} : { displayName: pkg.name.replace('@graphql-codegen/', '') }),
14+
transform: { '^.+\\.tsx?$': 'ts-jest' },
15+
testEnvironment: 'node',
16+
rootDir: dirname,
17+
globals: {
18+
'ts-jest': {
19+
diagnostics: false,
20+
tsConfig: 'tsconfig.json',
21+
},
22+
},
23+
restoreMocks: true,
24+
reporters: ['default'],
25+
modulePathIgnorePatterns: ['dist'],
26+
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { prefix: `${ROOT_DIR}/` }),
27+
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
28+
collectCoverage: false,
29+
};
30+
};

package.json

+14-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"scripts": {
44
"clean": "rimraf node_modules packages/{*,plugins/*/*,presets/*,utils/*}/node_modules",
55
"prebuild": "rimraf packages/{*,plugins/*/*,presets/*,utils/*}/dist",
6-
"build": "lerna run build --ignore @graphql-codegen/live-demo --ignore @graphql-codegen/website",
6+
"build": "tsc --project tsconfig.json && node ./scripts/bundle.js",
77
"test": "jest --no-watchman",
8-
"coverage": "jest --no-watchman --runInBand --coverage",
98
"lint": "eslint --ext .ts .",
109
"prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{ts,tsx,graphql,yml}\"",
1110
"prettier:check": "prettier --ignore-path .gitignore --check \"**/*.{ts,tsx,graphql,yml}\"",
@@ -42,11 +41,12 @@
4241
]
4342
},
4443
"devDependencies": {
45-
"dfds-github-scripts": "0.0.2",
44+
"axios": "0.19.2",
4645
"@apollo/react-common": "3.1.3",
4746
"@apollo/react-components": "3.1.3",
4847
"@apollo/react-hoc": "3.1.3",
4948
"@apollo/react-hooks": "3.1.3",
49+
"@babel/preset-typescript": "7.9.0",
5050
"@types/common-tags": "1.8.0",
5151
"@types/glob": "7.1.1",
5252
"@types/jest": "25.1.4",
@@ -56,6 +56,12 @@
5656
"@types/request": "2.48.4",
5757
"react": "16.13.1",
5858
"react-dom": "16.13.1",
59+
"p-limit": "2.2.2",
60+
"fs-extra": "9.0.0",
61+
"rollup": "2.1.0",
62+
"@rollup/plugin-node-resolve": "7.1.1",
63+
"rollup-plugin-generate-package-json": "3.2.0",
64+
"rollup-plugin-auto-external": "2.0.0",
5965
"apollo-cache": "1.3.4",
6066
"apollo-client": "2.6.8",
6167
"apollo-link": "1.2.13",
@@ -70,9 +76,12 @@
7076
"eslint-plugin-promise": "4.2.1",
7177
"eslint-plugin-react-hooks": "2.5.1",
7278
"eslint-plugin-standard": "4.0.1",
79+
"flow-bin": "0.121.0",
80+
"flow-parser": "0.121.0",
7381
"graphql": "14.6.0",
7482
"graphql-tag": "2.10.3",
7583
"husky": "4.2.3",
84+
"java-ast": "0.1.0",
7685
"jest": "25.1.0",
7786
"jest-docblock": "25.1.0",
7887
"jest-junit": "10.0.0",
@@ -86,12 +95,10 @@
8695
},
8796
"lint-staged": {
8897
"packages/**/src/**/*.{ts,tsx}": [
89-
"eslint --fix",
90-
"git add"
98+
"eslint --fix"
9199
],
92100
"**/*.{ts,tsx,graphql,yml}": [
93-
"prettier --write",
94-
"git add -f"
101+
"prettier --write"
95102
]
96103
},
97104
"resolutions": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../jest.project')({ dirname: __dirname });

packages/graphql-codegen-cli/package.json

+11-20
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
},
1010
"repository": {
1111
"type": "git",
12-
"url": "git+https://github.com/dotansimha/graphql-code-generator.git"
12+
"url": "https://github.com/dotansimha/graphql-code-generator.git",
13+
"directory": "packages/graphql-codegen-cli"
1314
},
1415
"scripts": {
1516
"lint": "eslint **/*.ts",
16-
"prepack": "bob-update-version",
17-
"clean": "rimraf ./dist",
18-
"prebuild": "yarn clean",
19-
"build": "bob",
20-
"test": "jest --no-watchman --config ../../jest.config.js"
17+
"test": "jest --no-watchman",
18+
"prepack": "../../scripts/prepack.js"
2119
},
2220
"keywords": [
2321
"gql",
@@ -90,7 +88,6 @@
9088
"valid-url": "1.0.9"
9189
},
9290
"devDependencies": {
93-
"bob-the-bundler": "0.3.4",
9491
"@types/chokidar": "1.7.5",
9592
"@types/detect-indent": "5.0.0",
9693
"@types/inquirer": "6.5.0",
@@ -100,31 +97,25 @@
10097
"@types/minimatch": "3.0.3",
10198
"bdd-stdin": "0.2.0",
10299
"dotenv": "8.2.0",
103-
"graphql": "14.6.0",
104100
"js-yaml": "3.13.1",
105-
"make-dir": "3.0.2",
106-
"ts-jest": "25.2.1"
101+
"make-dir": "3.0.2"
107102
},
108103
"peerDependencies": {
109104
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
110105
},
111-
"main": "./dist/index.cjs.js",
112-
"module": "dist/index.esm.js",
113-
"typings": "dist/index.d.ts",
114-
"typescript": {
115-
"definition": "dist/index.d.ts"
106+
"main": "dist/index.cjs.js",
107+
"module": "dist/index.esm.js",
108+
"typings": "dist/index.d.ts",
109+
"typescript": {
110+
"definition": "dist/index.d.ts"
116111
},
117112
"buildOptions": {
118-
"input": "./src/index.ts",
119113
"bin": {
120114
"graphql-codegen": {
121-
"input": "./src/bin.ts"
115+
"input": "src/bin.ts"
122116
}
123117
}
124118
},
125-
"jest-junit": {
126-
"outputDirectory": "../../test-results/cli"
127-
},
128119
"publishConfig": {
129120
"access": "public"
130121
}

0 commit comments

Comments
 (0)