diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b873f7b5718cfd67cdca8a4316636a075aa9390..18ba78c37a815bac327d7aa6fc2ed0c64ca056a6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,14 +24,20 @@ variables: build: stage: build - image: debian:latest + image: node:latest + cache: + paths: + - node_modules/ rules: # official release - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+/ # latest - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + before_script: + - npm update --no-audit --no-fund script: - - ./compile.sh --ci --minify + # - ./compile.sh --ci --minify + - npx gulp --minify --ci --verbosity 6 artifacts: paths: - bin/FC_pregmod.html diff --git a/gulpfile.js b/gulpfile.js index 1f717698e9604ae03524ae2bbbe5211407a608e5..9b2bfaedb1a083666b7335c7d2d274e9fe1448a9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,7 +10,7 @@ const autoprefixer = require('autoprefixer'), sort = require('gulp-sort'), sourcemaps = require('gulp-sourcemaps'), stripCssJSComments = require('gulp-strip-comments'), - childProcess = require('child_process'), + childProcess = require('child_process'), which = require('which'), fs = require('fs'), path = require('path'), @@ -23,6 +23,7 @@ const autoprefixer = require('autoprefixer'), const args = yargs.options({ verbosity: {type: 'number', default: 1}, release: {type: 'boolean', default: false}, + ci: {type: 'boolean', default: false}, // assumes gitlab CI environment minify: {type: 'boolean', default: false}, embedsourcemaps: {type: 'boolean', default: false}, sourcemapsincludecontent: {type: 'boolean', default: false} @@ -202,7 +203,9 @@ function isGitCheckout() { /** Invokes git and writes hash of the head commit to the file, specified in the 'gitVersionFile' build config property */ function injectGitCommit(cb) { - childProcess.exec('git rev-parse --short HEAD', function(error, stdout) { + // check if we are in CI mode, if yes, just read out the hash from environment variables + const readGitHash = args.ci ? "echo $CI_COMMIT_SHORT_SHA" : 'git rev-parse --short HEAD'; + childProcess.exec(readGitHash, function(error, stdout) { if (!error) { log.info('current git hash: ', stdout); fs.writeFile(cfg.gitVersionFile, `App.Version.commitHash = '${stdout.trimEnd()}';\n`, cb); @@ -234,7 +237,10 @@ When all intermediate files are ready, tweego picks them up and assembles the HT */ // Create task to execute tweego -gulp.task('compileStory', shell.task(tweeCompileCommand(), {env: {...process.env, ...cfg.options.twee.environment}, verbose: args.verbosity >= 3})); +gulp.task('compileStory', shell.task(tweeCompileCommand(), { + env: {...process.env, ...cfg.options.twee.environment}, + verbose: args.verbosity >= 3 +})); /** * Creates tasks for preparing intermidiate files for a component @@ -312,6 +318,9 @@ gulp.task('prepare', gulp.parallel(prepareComponent("module"), prepareComponent( if (isGitCheckout()) { exports.clean = gulp.parallel(cleanupGit, removeIntermediateFiles); gulp.task('buildHTML', gulp.series(exports.clean, 'prepare', injectGitCommit, 'compileStory', cleanupGit)); +} else if (args.ci) { + // CI environment is already clean + gulp.task('buildHTML', gulp.series('prepare', injectGitCommit, 'compileStory')); } else { exports.clean = gulp.parallel(removeIntermediateFiles); gulp.task('buildHTML', gulp.series(exports.clean, 'prepare', 'compileStory'));