Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
root = true

[*]
indent_style = tab
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage

# Reports directory used for unit test reports
reports/

# nyc test coverage
.nyc_output

Expand Down
6 changes: 6 additions & 0 deletions .pipeline/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
dockerExecute:
dockerPullImage: false
sidecarPullImage: false
karmaExecuteTests:
runCommand: 'npm run karma-ci'
13 changes: 13 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@Library(['piper-lib-os']) _

pipeline {
agent any
stages {
stage('Test'){
steps {
setupCommonPipelineEnvironment script: this
karmaExecuteTests script: this
}
}
}
}
12 changes: 12 additions & 0 deletions jenkins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jenkins:
numExecutors: 10
unclassified:
globallibraries:
libraries:
- defaultVersion: "master"
name: "piper-lib-os"
retriever:
modernSCM:
scm:
git:
remote: "https://github.com/SAP/jenkins-library.git"
35 changes: 31 additions & 4 deletions karma-ci.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function(config) {
"use strict";
"use strict";

require("./karma.conf")(config);
config.set({
Expand Down Expand Up @@ -28,12 +28,39 @@ module.exports = function(config) {
}
}
},
// https://github.com/karma-runner/karma-junit-reporter#configuration
junitReporter: {
outputDir: "reports",
outputFile: "TEST-qunit.xml",
suite: "",
useBrowserName: true
},
customLaunchers: {
"ChromeRemote": {
base: "WebDriver",
config: {
hostname: "localhost",
port: 4444
},
browserName: "chrome",
name: "Karma",
pseudoActivityInterval: 30000
}
},

reporters: ["progress", "coverage"],
reporters: ["progress", "coverage", "junit"],

browsers: ["ChromeHeadless"],
browsers: ["ChromeRemote"],

singleRun: true

});
});

if (process.env.ON_K8S == true){
console.log("Running with Kubernetes setup.")
} else {
console.log("Running with Docker setup.")
config.hostname = 'karma'
config.customLaunchers.ChromeRemote.config.hostname = 'selenium'
}
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"lint": "eslint webapp",
"karma": "karma start",
"karma-ci": "karma start karma-ci.conf.js",
"karma-compose": "docker-compose --file webapp/test/docker-compose.yml up --abort-on-container-exit",
"watch": "npm run karma",
"test": "npm run lint && rimraf coverage && npm run karma-ci",
"build": "rimraf dist && ui5 build --a"
"build": "rimraf dist && ui5 build --a",
"jenkinsfile": "docker run --rm -v /tmp -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/workspace -e CASC_JENKINS_CONFIG=/workspace/jenkins.yml ppiper/jenkinsfile-runner"
},
"dependencies": {
"@openui5/sap.m": "^1.60.0",
Expand All @@ -23,7 +25,9 @@
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-junit-reporter": "^1.2.0",
"karma-ui5": "^1.0.0",
"karma-webdriver-launcher": "^1.0.5",
"rimraf": "^2.6.2"
}
}
22 changes: 22 additions & 0 deletions webapp/test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'
services:
karma:
image: node:8-stretch
user: node
working_dir: /home/node/app
volumes:
- ../..:/home/node/app
command:
- /bin/sh
- -c
- |
/usr/local/bin/npm install
/usr/local/bin/npm run karma-ci
depends_on:
- selenium
selenium:
image: selenium/standalone-chrome
ports:
- "4444:4444"
healthcheck:
test: "curl -sSL 'http://localhost:4444/wd/hub/status' 2>&1 | jq -r '.value.ready' 2>&1 | grep 'true' >/dev/null"