Skip to content

Commit

Permalink
Pipeline changes
Browse files Browse the repository at this point in the history
  • Loading branch information
netwarex committed Jun 4, 2019
1 parent fd73f18 commit 41830e4
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ npm-debug.log
yarn-error.log
testem.log
/typings
/.reports

# System Files
.DS_Store
Expand Down
63 changes: 0 additions & 63 deletions ci/Dockerfile

This file was deleted.

22 changes: 22 additions & 0 deletions ci/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:10-alpine
LABEL maintainer="[email protected]"
ARG BUILD_USER="jenkins"
# Installs latest Chromium package
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& apk add --no-cache \
chromium@edge \
harfbuzz@edge \
nss@edge \
freetype@edge \
ttf-freefont@edge \
git \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk
ENV CHROME_BIN /usr/bin/chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN adduser -D -u 10000 -h /ci ${BUILD_USER}
COPY . /ci
RUN chown ${BUILD_USER}: /ci -R
USER ${BUILD_USER}
WORKDIR /ci
77 changes: 53 additions & 24 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ spec:
path: /opt/kubernetes/cache
containers:
- name: build
image: docker:18
image: """ + buildEnvironmentDockerImage("ci/Dockerfile.build") + """
imagePullPolicy: Always
command:
- cat
tty: true
resources:
requests:
cpu: 2
memory: 4Gi
memory: 2Gi
env:
- name: DOCKER_HOST
value: tcp://127.0.0.1:2375
Expand Down Expand Up @@ -65,8 +65,6 @@ spec:
}

parameters {
booleanParam(name: 'linting', defaultValue: false, description: 'Whether to run linting')
booleanParam(name: 'testing', defaultValue: true, description: 'Whether to run unit tests')
string(name: 'releaseVersion', defaultValue: '', description: 'Version must comply with semver, a tag will be created, cannot be the same as in package.json')
booleanParam(name: 'release', defaultValue: false, description: "Whether to run the release steps")
booleanParam(name: 'releaseNext', defaultValue: false, description: "Whether release as an upcoming version")
Expand All @@ -77,7 +75,6 @@ spec:
stages {
stage('Clone Github Pages') {
when {
beforeAgent true
expression {
return params.publishDocs
}
Expand All @@ -92,41 +89,73 @@ spec:
}
}

stage('Docker build') {
stage('Fetch dependencies') {
steps {
sh 'npm set progress=false && npm config set depth 0 && npm ci'
stash includes: 'node_modules/', name: 'node_modules'
}
}

/*stage('Lint') {
steps {
unstash 'node_modules'
sh 'npm run lint'
}
}*/

stage('Unit Tests') {
steps {
unstash 'node_modules'
sh 'npm run test -- --watch=false --browsers=ChromeHeadlessCI --reporters=junit'
}

post {
always {
junit '.reports/*/*.xml'
}
}
}

stage('Build') {
steps {
unstash 'node_modules'
sh "npm run build -- --progress=false"
stash includes: 'dist/', name: 'dist'
}
}

stage('Release') {
when {
beforeAgent true
expression {
isValidVersion = params.releaseVersion.trim() =~ env.VERSION_CONSTRAINT || params.releaseVersion == ''
return isValidVersion
return params.release
}
}

steps {
sh """docker build -f ci/Dockerfile \
--build-arg linting=${params.linting} \
--build-arg testing=${params.testing} \
--build-arg release=${params.release} \
--build-arg releaseNext=${params.releaseNext} \
--build-arg releaseVersion=${params.releaseVersion} \
--build-arg publishDocs=${params.publishDocs} \
--build-arg docsVersion=${params.docsVersion} \
--build-arg GIT_BRANCH=${env.GIT_BRANCH} \
--build-arg CACHEBUST=\$(date +%s) \
.
"""
unstash 'dist'
sshagent(["git"]) {
sh "ci/release.sh"
}
}
}

stage('Publish Docs to Github Pages') {
stage('Update Documentation') {
when {
expression {
return params.publishDocs
}
expression {
isValidVersion = params.releaseVersion.trim() =~ env.VERSION_CONSTRAINT || params.releaseVersion == ''
return isValidVersion
}
}

steps {
echo "Now it should publish..."
}
unstash 'node_modules'
sshagent(["git"]) {
sh "ci/publishDocs.sh"
}
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"marked": "~0.6.0",
"ng-packagr": "^4.7.1",
"ngx-build-plus": "^7.7.6",
Expand Down
9 changes: 8 additions & 1 deletion projects/docs/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = function (config) {
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
Expand All @@ -32,6 +33,12 @@ module.exports = function (config) {
}
},
reporters: ['progress', 'kjhtml'],
reporters: ['progress', 'kjhtml', 'junit'],
junitReporter: {
outputDir: '../../.reports',
outputFile: 'docs-results.xml',
suite: ''
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
10 changes: 8 additions & 2 deletions projects/gentics-ui-core/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = function (config) {
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
Expand All @@ -31,7 +32,12 @@ module.exports = function (config) {
],
}
},
reporters: ['progress', 'kjhtml'],
reporters: ['progress', 'kjhtml', 'junit'],
junitReporter: {
outputDir: '../../.reports',
outputFile: 'gentics-ui-core-results.xml',
suite: ''
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down

0 comments on commit 41830e4

Please sign in to comment.