Skip to content

Commit ae83e0a

Browse files
chore: fix travis build of next/rc/release-patch versions
Currently the Travis build of `next`, `rc` and `release-patch` versions takes way too long as the packaging and execution of unit tests is done twice - first time from `grunt pack` execution inside the script and the second time from the npm deploy provider. To fix this introduce new Grunt task - `travisPack` - it checks if the build is from PR and in case it is, the grunt pack task is skipped. This way the `grunt travisPack` command in the `.travis.yml` script section will be skipped in case we are not in PR build, but the one from npm deploy step will still be executed. Also delete some unused and not needed logic.
1 parent 37d0f6f commit ae83e0a

File tree

4 files changed

+19
-33
lines changed

4 files changed

+19
-33
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
!vendor/*.js
77
!resources/**
88
*.js.map
9-
9+
!.travis/**/*
1010
coverage
1111
lib-cov
1212
*.seed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ scratch/
3030
.travis.yml
3131
docs/html/
3232
dev/
33+
34+
.travis/**/*

.travis.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ before_script:
1919
- gem install xcodeproj
2020
- gem install cocoapods
2121
- npm install grunt
22-
- node_modules/.bin/grunt enableScripts:false
23-
- grunt rebuild
24-
- "./bin/nativescript error-reporting disable"
25-
- "./bin/nativescript usage-reporting disable"
26-
- npm test
27-
- node_modules/.bin/grunt enableScripts:true
2822
script:
29-
- node_modules/.bin/grunt lint && node_modules/.bin/grunt pack --no-color
23+
- node_modules/.bin/grunt lint && node_modules/.bin/grunt travisPack --no-color
3024
before_deploy:
3125
- node .travis/add-publishConfig.js $TRAVIS_BRANCH
3226
deploy:

Gruntfile.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ const childProcess = require("child_process");
22
const EOL = require("os").EOL;
33
const now = new Date().toISOString();
44

5-
const CONFIG_JSON_PATH = "config/config.json";
6-
75
const ENVIRONMENTS = {
86
live: "live",
97
dev: "dev"
@@ -143,7 +141,7 @@ module.exports = function (grunt) {
143141
"isWindows": true,
144142
"isMacOS": true,
145143
"isLinux": true,
146-
"formatListOfNames": () => {},
144+
"formatListOfNames": () => { },
147145
"constants": ""
148146
}
149147
},
@@ -173,50 +171,34 @@ module.exports = function (grunt) {
173171

174172
var packageJson = grunt.file.readJSON("package.json");
175173
var versionParts = packageJson.version.split("-");
176-
if (process.env["RELEASE_BUILD"]) {
177-
// HACK - excluded until 1.0.0 release or we refactor our project infrastructure (whichever comes first)
178-
// packageJson.version = versionParts[0];
179-
} else {
180-
versionParts[1] = buildVersion;
181-
packageJson.version = versionParts.join("-");
182-
}
174+
versionParts[1] = buildVersion;
175+
packageJson.version = versionParts.join("-");
183176
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
184177
});
185178

186179
grunt.registerTask("tslint:build", function (version) {
187180
childProcess.execSync("npm run tslint", { stdio: "inherit" });
188181
});
189182

190-
grunt.registerTask("enableScripts", function (enable) {
191-
var enableTester = /false/i;
192-
var newScriptsAttr = !enableTester.test(enable) ? "scripts" : "skippedScripts";
193-
var packageJson = grunt.file.readJSON("package.json");
194-
var oldScriptsAttrValue = packageJson.scripts || packageJson.skippedScripts;
195-
delete packageJson.scripts;
196-
delete packageJson.skippedScripts;
197-
packageJson[newScriptsAttr] = oldScriptsAttrValue;
198-
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
199-
});
200-
201183
const setConfig = (key, value) => {
202184
const configJson = grunt.file.readJSON(CONFIG_DATA.filePath);
203185
configJson[key] = value;
204186
const stringConfigContent = JSON.stringify(configJson, null, " ") + EOL;
205187
grunt.file.write(CONFIG_DATA.filePath, stringConfigContent);
206188
}
207189

208-
grunt.registerTask("set_live_ga_id", function() {
190+
grunt.registerTask("set_live_ga_id", function () {
209191
setConfig(CONFIG_DATA.gaKey, GA_TRACKING_IDS[ENVIRONMENTS.live]);
210192
});
211193

212-
grunt.registerTask("set_dev_ga_id", function() {
194+
grunt.registerTask("set_dev_ga_id", function () {
213195
setConfig(CONFIG_DATA.gaKey, GA_TRACKING_IDS[ENVIRONMENTS.dev]);
214196
});
215197

216-
grunt.registerTask("verify_live_ga_id", function() {
198+
grunt.registerTask("verify_live_ga_id", function () {
217199
var configJson = grunt.file.readJSON(CONFIG_DATA.filePath);
218200

219-
if(configJson[CONFIG_DATA.gaKey] !== GA_TRACKING_IDS[ENVIRONMENTS.live]) {
201+
if (configJson[CONFIG_DATA.gaKey] !== GA_TRACKING_IDS[ENVIRONMENTS.live]) {
220202
throw new Error("Google Analytics id is not configured correctly.");
221203
}
222204
});
@@ -234,6 +216,14 @@ module.exports = function (grunt) {
234216
"set_package_version",
235217
"shell:build_package"
236218
]);
219+
220+
grunt.registerTask("travisPack", function () {
221+
if (travis && process.env.TRAVIS_PULL_REQUEST_BRANCH) {
222+
return grunt.task.run("pack");
223+
}
224+
225+
console.log(`Skipping travisPack step as the current build is not from PR, so it will be packed from the deploy provider.`);
226+
});
237227
grunt.registerTask("lint", ["tslint:build"]);
238228
grunt.registerTask("all", ["clean", "test", "lint"]);
239229
grunt.registerTask("rebuild", ["clean", "ts:devlib"]);

0 commit comments

Comments
 (0)