Skip to content

Commit

Permalink
Simplify build of reports
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 21, 2020
1 parent a9b8935 commit cd7bafe
Show file tree
Hide file tree
Showing 26 changed files with 1,910 additions and 263 deletions.
6 changes: 0 additions & 6 deletions images/reports/.gitignore

This file was deleted.

20 changes: 4 additions & 16 deletions images/reports/Dockerfile
Expand Up @@ -13,24 +13,12 @@
# limitations under the License.

# build stage
FROM maven:3.6.3-openjdk-14 as builder

WORKDIR /build

COPY pom.xml /build/
RUN mvn dependency:go-offline

COPY src /build/src

RUN mvn clean install

FROM openjdk:14.0.2-slim-buster
FROM node:lts-alpine

WORKDIR /app

COPY --from=builder /build/target/*jar-with-dependencies.jar report-builder.jar
COPY src /app

# https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for
ENV JAVA_OPTS "-Djava.security.egd=file:/dev/./urandom"
RUN npm install --production

CMD ["/bin/bash", "-c", "java $JAVA_OPTS -jar report-builder.jar"]
CMD ["node", "/app/index.js"]
148 changes: 0 additions & 148 deletions images/reports/pom.xml

This file was deleted.

1 change: 1 addition & 0 deletions images/reports/src/.gitignore
@@ -0,0 +1 @@
output
9 changes: 9 additions & 0 deletions images/reports/src/cucumber-html-reporter/.eslintrc.yml
@@ -0,0 +1,9 @@
env:
browser: true
commonjs: true
es2020: true
extends:
- airbnb-base
parserOptions:
ecmaVersion: 11
rules: {}
1 change: 1 addition & 0 deletions images/reports/src/cucumber-html-reporter/.gitignore
@@ -0,0 +1 @@
node_modules
21 changes: 21 additions & 0 deletions images/reports/src/cucumber-html-reporter/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Wim Selles

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions images/reports/src/cucumber-html-reporter/README.MD
@@ -0,0 +1,14 @@
Cucumber HTML Reporter
===============================

Based on [multiple-cucumber-html-reporter](github/wswebcreation/multiple-cucumber-html-reporter)

## Credits

In the search for a reporting tools for Cucumber I found a few tools that helped me a lot:

- [multiple-cucumber-html-reporter](github/wswebcreation/multiple-cucumber-html-reporter)
- [cucumber-html-repository](https://github.com/gkushang/cucumber-html-reporter)
- [cucumber-html-report](https://github.com/leinonen/cucumber-html-report)
- [cucumber-protractor-report](https://github.com/JesterXL/cucumber-protractor-report)
- [grunt-protractor-cucumber-html-report](https://github.com/robhil/grunt-protractor-cucumber-html-report)
64 changes: 64 additions & 0 deletions images/reports/src/cucumber-html-reporter/lib/collect-jsons.js
@@ -0,0 +1,64 @@
const { readFileSync, statSync } = require('fs-extra');
const { findJsonFiles, formatToLocalIso } = require('./utils');
const { parseFeatureHooks, parseMetadata } = require('./parse.cucumber.data');

module.exports = function collectJSONS(options) {
const jsonOutput = [];
const files = findJsonFiles(options.jsonDir);

if (files.length === 0) {
console.log(`WARNING: No JSON files found in '${options.jsonDir}'. NO REPORT CAN BE CREATED!`);
return [];
}

files.map((file) => {
let data;
// Cucumber json can be empty, it's likely being created by another process (#47)
// or the data could not be a valid JSON-file
try {
data = JSON.parse(readFileSync(file).toString());
} catch (e) {
data = [];
console.log(`WARNING: File: '${file}' had no valid JSON data due to error:'${e}'. CONTENT WAS NOT LOADED!`);
}

const jsonData = Array.isArray(data) ? data : [data];
const stats = statSync(file);
const reportTime = formatToLocalIso(stats.birthtime);

jsonData.map((json) => {
json = parseMetadata(json, options.metadata);

if (options.displayReportTime) {
json.metadata = {
...json.metadata,
...{ reportTime },
};
}

// Only check the feature hooks if there are elements (fail safe)
const { elements } = json;

if (elements) {
json.elements = elements.map((scenario) => {
const { before, after } = scenario;

if (before) {
scenario.steps = parseFeatureHooks(before, 'Before')
.concat(scenario.steps);
}
if (after) {
scenario.steps = scenario.steps
.concat(parseFeatureHooks(after, 'After'));
}

return scenario;
});
}

jsonOutput.push(json);
});
});

return jsonOutput;
};

0 comments on commit cd7bafe

Please sign in to comment.