Skip to content

Commit

Permalink
feat(e2e): Speed up prepare.e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmeku committed Feb 15, 2019
1 parent caf4ebf commit 8f9ea39
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 80 deletions.
12 changes: 5 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ jobs:
- checkout
- restore_cache:
keys:
- yarn-dependencies-v6-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-dependencies-v6-{{ .Branch }}-
- yarn-dependencies-v7-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-dependencies-v7-{{ .Branch }}-
# fallback to using the latest cache if no exact match is found
- yarn-dependencies-v6-
- yarn-dependencies-v7-
- run: yarn install --frozen-lockfile --non-interactive
- run: npx cypress verify
- run: yarn start prepare.e2e.and.check-formatting
- save_cache:
key: yarn-dependencies-v6-{{ .Branch }}-{{ checksum "yarn.lock" }}
key: yarn-dependencies-v7-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache
- run: yarn start format.check
- run: npx tslint -p tsconfig.json -e **/generated/* -c tslint.json
- run: yarn start prepare.e2e
- run: yarn start test.affected.origin-master
- run:
command: yarn start e2e.ci
Expand Down
56 changes: 31 additions & 25 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,18 @@ module.exports = {
cli: 'node ./tools/scripts/patch-cli.js'
})
),
'gen-graphql': nps.series(
'gql-gen --config ./tools/scripts/codegen-server.yml',
'gql-gen --config ./tools/scripts/codegen-client.js'
),
server: {
default: nps.series.nps(
'dev.server.gen-and-build.electron',
'dev.copy-assets.electron',
'dev.server.start'
),
start: `electron ${ELECTRON_BUNDLE_PATH} --server --port 4201 --inspect=9229`,
gen: nps.series(
'gql-gen --config ./tools/scripts/codegen-server.yml',
'gql-gen --config ./tools/scripts/codegen-client.js'
default: nps.series(
'nps dev.gen-graphql',
'ng build electron --prod --maxWorkers=2 --noSourceMap',
'nps dev.copy-assets.electron',
'nps dev.server.start'
),
'gen-and-build': electronOrVscode(
nps.series(
'nps dev.server.gen.APPLICATION',
'ng build APPLICATION --prod --maxWorkers=2 --noSourceMap'
)
)
start: `electron ${ELECTRON_BUNDLE_PATH} --server --port 4201 --inspect=9229`
},
up: {
default: nps.concurrent({
Expand All @@ -148,7 +143,15 @@ module.exports = {
)
}
},
e2e: nps.concurrent.nps('prepare.electron', 'e2e.fixtures'),
e2e: {
default: nps.concurrent.nps('prepare.electron', 'e2e.fixtures'),
and: {
'check-formatting': nps.concurrent.nps(
'prepare.e2e',
'format.and.lint.check'
)
}
},
...electronOrVscode(
nps.series.nps(
'clean',
Expand Down Expand Up @@ -190,28 +193,31 @@ module.exports = {
},
format: {
default: 'nx format:write',
and: {
lint: {
check: nps.concurrent.nps('format.check', 'lint')
}
},
write: 'nx format:write',
check: 'nx format:check'
},
lint: {
default: nps.concurrent({
formatCheck: 'nps format.check',
nxLint: 'nx lint',
tsLint: 'nx affected:lint --all --parallel'
tsLint: 'npx tslint -p tsconfig.json -e **/generated/* -c tslint.json'
}),
affected: affected('lint'),
fix: {
default: 'nx affected:lint --all --parallel --fix',
affected: affected('lint --fix')
}
fix: 'npx tslint -p tsconfig.json -e **/generated/* -c tslint.json --fix'
},
build: {
default: 'nx affected:build --all --parallel',
affected: affected('build'),
...electronOrVscode(
nps.series(
'nps dev.server.gen-and-build.APPLICATION',
'ng build angular-console --configuration=APPLICATION'
'nps dev.gen-graphql',
nps.concurrent({
server: 'ng build APPLICATION --prod --maxWorkers=2 --noSourceMap',
client: 'ng build angular-console --configuration=APPLICATION'
})
)
)
},
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"dependencies": {
"node-pty-prebuilt": "0.7.6",
"semver": "5.6.0",
"tmp": "0.0.33"
"tmp": "0.0.33",
"@nrwl/nx": "7.5.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.1",
Expand All @@ -104,9 +105,8 @@
"@nestjs/graphql": "5.5.1",
"@nrwl/angular-console-enterprise-electron": "0.0.40",
"@nrwl/angular-console-enterprise-frontend": "0.0.40",
"@nrwl/builders": "7.5.1",
"@nrwl/nx": "7.5.1",
"@nrwl/schematics": "7.5.1",
"@nrwl/builders": "7.5.2",
"@nrwl/schematics": "7.5.2",
"@schematics/angular": "7.3.1",
"@types/electron-store": "^1.3.0",
"@types/fontfaceobserver": "^0.0.6",
Expand Down
76 changes: 44 additions & 32 deletions tools/scripts/set-up-e2e-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,75 @@ shell.mkdir(path.join(tmp, 'proj-nx'));

shell.rm('-rf', path.join(tmp, 'ng'));
shell.mkdir(path.join(tmp, 'ng'));

cp.execSync('yarn add @angular/[email protected]', { cwd: path.join(tmp, 'ng') });
cp.execSync('yarn add @nrwl/[email protected]', { cwd: path.join(tmp, 'ng') });

cp.execSync('ng config -g cli.packageManager yarn');
cp.execSync(

cp.exec(
`${path.join(
tmp,
'ng'
)}/node_modules/.bin/ng new proj --collection=@schematics/angular --directory=proj --skip-git --no-interactive`,
{ cwd: tmp, stdio: [0, 1, 2] }
);
const angularJson = JSON.parse(
fs.readFileSync(path.join(tmp, 'proj', 'angular.json')).toString()
);
angularJson.schematics = {
'@schematics/angular:service': {
flat: false
}
};
fs.writeFileSync(
path.join(tmp, 'proj', 'angular.json'),
JSON.stringify(angularJson, null, 2)
);
{ cwd: tmp, stdio: [0, 1, 2] },
() => {
const angularJson = JSON.parse(
fs.readFileSync(path.join(tmp, 'proj', 'angular.json')).toString()
);
angularJson.schematics = {
'@schematics/angular:service': {
flat: false
}
};
fs.writeFileSync(
path.join(tmp, 'proj', 'angular.json'),
JSON.stringify(angularJson, null, 2)
);

const karma = fs
.readFileSync(path.join(tmp, 'proj', 'src', 'karma.conf.js'))
.toString();
fs.writeFileSync(
path.join(tmp, 'proj', 'src', 'karma.conf.js'),
karma.replace('Chrome', 'ChromeHeadless')
);
const karma = fs
.readFileSync(path.join(tmp, 'proj', 'src', 'karma.conf.js'))
.toString();
fs.writeFileSync(
path.join(tmp, 'proj', 'src', 'karma.conf.js'),
karma.replace('Chrome', 'ChromeHeadless')
);

shell.mv(path.join(tmp, 'proj'), './tmp/proj');
shell.mv(path.join(tmp, 'proj'), './tmp/proj');
}
);

cp.execSync(
cp.exec(
`${path.join(
tmp,
'ng'
)}/node_modules/.bin/ng new proj-extensions --collection=@schematics/angular --directory=proj-extensions --skip-git --no-interactive`,
{ cwd: tmp, stdio: [0, 1, 2] }
{ cwd: tmp, stdio: [0, 1, 2] },
() => {
shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions');
}
);
shell.mv(path.join(tmp, 'proj-extensions'), './tmp/proj-extensions');

cp.execSync(
cp.exec(
`${path.join(
tmp,
'ng'
)}/node_modules/.bin/ng new proj-no-node-modules --collection=@schematics/angular --directory=proj-no-node-modules --skip-install --skip-git --no-interactive`,
{ cwd: tmp, stdio: [0, 1, 2] }
{ cwd: tmp, stdio: [0, 1, 2] },
() => {
shell.mv(
path.join(tmp, 'proj-no-node-modules'),
'./tmp/proj-no-node-modules'
);
}
);
shell.mv(path.join(tmp, 'proj-no-node-modules'), './tmp/proj-no-node-modules');

cp.execSync(
`${path.join(
tmp,
'ng'
)}/node_modules/.bin/ng new proj-nx --collection=@nrwl/schematics --directory=proj-nx --skip-git --no-interactive`,
{ cwd: tmp, stdio: [0, 1, 2] }
{ cwd: tmp, stdio: [0, 1, 2] },
() => {
shell.mv(path.join(tmp, 'proj-nx'), './tmp/proj-nx');
}
);
shell.mv(path.join(tmp, 'proj-nx'), './tmp/proj-nx');
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@
trix "^1.0.0"
tslib "^1.9.0"

"@nrwl/[email protected].1":
version "7.5.1"
resolved "https://registry.yarnpkg.com/@nrwl/builders/-/builders-7.5.1.tgz#b8097f8748e6292ede7f446ea6c4ac7d2b4d2266"
integrity sha512-68+c6aDv4l/h9rnG1i9ROz9a/zxA9BAoRy0A4VB9KbJ7hLIJ5zbKHrfQVbBh0OdCLc5eQIQt3Vl882jl2/j4MA==
"@nrwl/[email protected].2":
version "7.5.2"
resolved "https://registry.yarnpkg.com/@nrwl/builders/-/builders-7.5.2.tgz#7e024c3a1eadc8b50fa43735c96353c8e0b11ad7"
integrity sha512-Yazl0YnqntRCkKiKeWdMpUkshus3FXZ0eNs6el/yvtQfWqoD+Z7BNrW4MCFVlGKtpOUQi+Gow/seFPrfjGryHg==
dependencies:
"@angular-devkit/architect" "~0.12.1"
"@angular-devkit/build-webpack" "~0.12.1"
Expand All @@ -512,15 +512,15 @@
webpack-dev-server "3.1.14"
webpack-node-externals "1.7.2"

"@nrwl/[email protected].1":
version "7.5.1"
resolved "https://registry.yarnpkg.com/@nrwl/nx/-/nx-7.5.1.tgz#890d7b79f5a6c9a564d18fe28e841e3e7ecdb0d0"
integrity sha512-OegS/kwlClfCcaffVtYuTDz6zMJzrOLlVotblgPfTRd4CJrylN3wLbPlM8U80XoGSpQTKCyfzzPlKsu6ikp7rg==
"@nrwl/[email protected].2":
version "7.5.2"
resolved "https://registry.yarnpkg.com/@nrwl/nx/-/nx-7.5.2.tgz#df8c8d68d2645b20ac9ce054938a0371a2c3f4ba"
integrity sha512-z0xWeHKNic/lEusP1pwgbv7bIB2UvT4Yc/GMAUH/wD/Y8E8L4lc3Y64cofwrvE3WJTY4ainsvYH/XkFqAOPxpA==

"@nrwl/[email protected].1":
version "7.5.1"
resolved "https://registry.yarnpkg.com/@nrwl/schematics/-/schematics-7.5.1.tgz#717bf80f7273a00f469cfe33a4cb27fc7eadbbb5"
integrity sha512-4gVHUsD15qInVa4uMOrj8YS2KECFA4a5/BkgAPiR5GX3WnCStahp6JaXyPa1aeJ6RCaW4iFvHr3AlfL4UvE8CQ==
"@nrwl/[email protected].2":
version "7.5.2"
resolved "https://registry.yarnpkg.com/@nrwl/schematics/-/schematics-7.5.2.tgz#b0be5a708e733e798dd1f7cec2341e5062703236"
integrity sha512-AqbNJ782UodR5y56yg4LCsIxXTORBE2wiGRI5yAD+QpAGL+vw8gdRzTNxgzoFsgowNkzW0Czfo1ezPtFCEvl+Q==
dependencies:
"@types/yargs" "^11.0.0"
app-root-path "^2.0.1"
Expand Down

0 comments on commit 8f9ea39

Please sign in to comment.