Skip to content

Commit

Permalink
Add generator webpage (#111)
Browse files Browse the repository at this point in the history
* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* Add generator webpage (#39)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

Co-authored-by: Jake Howlett <[email protected]>

* d

* Add generator webpage (#40)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

Co-authored-by: Jake Howlett <[email protected]>

* add extra push

* Add generator webpage (#41)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

Co-authored-by: Jake Howlett <[email protected]>

* ss

* Add generator webpage (#42)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

Co-authored-by: Jake Howlett <[email protected]>

* ff

* Add generator webpage (#43)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

* ff

Co-authored-by: Jake Howlett <[email protected]>

* dd

* Add generator webpage (#44)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

* ff

* dd

Co-authored-by: Jake Howlett <[email protected]>

* dd

* Add generator webpage (#45)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

* ff

* dd

* dd

Co-authored-by: Jake Howlett <[email protected]>

* df

* Add generator webpage (#46)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

* ff

* dd

* dd

* df

Co-authored-by: Jake Howlett <[email protected]>

* dd

* Add generator webpage (#47)

* ci: add new workflow to update webpages

* ci: add new workflow to update webpages (#30)

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* Add generator webpage (#31)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* docs: Auto-update WEBPAGE.md

* ci: test protected branch

* Add generator webpage (#32)

* ci: add new workflow to update webpages

* ci: merge workflow into test.yml

* ci: fix formatting errors

* ci: fix errors after merge

* ci: remove webpage.yml

* ci: test protected branch

* ci: uncomment PAT

* ci add if to all workflows

* ci: use gh-pages branch

* ci: remove duplicate WEBPAGE.md

* ci: fix workflow

* ci: fix artifact upload

* ci: add token

* ci: remove empty line

* d

* add extra push

* ss

* ff

* dd

* dd

* df

* dd

Co-authored-by: Jake Howlett <[email protected]>

* dd

* cc

* dd

* Add line to CONTRIBUTING.md

Co-authored-by: Jake Howlett <[email protected]>
  • Loading branch information
jhowlett-scottlogic and jhowlett-scottlogic authored Nov 1, 2022
1 parent 4a41a09 commit ff74b49
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 4 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ jobs:
workflow: test.yml
branch: master
name: test-results
path: CICD_${{github.event.pull_request.head.sha}}
path: CICD_${{github.sha}}
workflow_conclusion: completed


- name: Compare test results
run: node CICD/compareTestResults test-results.json CICD_${{github.event.pull_request.head.sha}}/test-results.json
run: node CICD/compareTestResults test-results.json CICD_${{github.sha}}/test-results.json

- name: Update webpage contents
if: github.event_name == 'push'
run: |
git config --global user.name 'GitHubActions'
git config --global user.email '<>'
git checkout -b gh-pages
git reset --hard master
node CICD/updateWebpage CICD_${{github.sha}}/test-results.json
npm run format:write
git add docs/
git commit -m "docs: auto-update docs/"
git push --force --set-upstream origin gh-pages
85 changes: 85 additions & 0 deletions CICD/updateWebpage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const fs = require("fs");

const log = require("../src/log.js");

// This regex extracts the generator table from README.md.
const tableRegex =
/\[MARKER\]:\s<>\s\(START\sOF\sGENERATOR\sTESTING\sTABLE\)([\s\S]+)\[MARKER\]:\s<>\s\(END\sOF\sGENERATOR\sTESTING\sTABLE\)/m;

// This regex extracts the generator failures from README.md.
const failuresRegex =
/\[MARKER\]:\s<>\s\(START\sOF\sGENERATOR\sTESTING\sFAILURES\)([\s\S]+)\[MARKER\]:\s<>\s\(END\sOF\sGENERATOR\sTESTING\sFAILURES\)/m;

function getNewFailures(results) {
let newFailures = "[MARKER]: <> (START OF GENERATOR TESTING FAILURES)\n\n";

const languages = Object.keys(results);

for (let xx = 0; xx < languages.length; xx++) {
const result = results[languages[xx]];
newFailures += `\n\n## ${languages[xx]}\n\n`;
if (result.failures) {
for (let yy = 0; yy < result.failures.length; yy++) {
newFailures += `- ${result.failures[yy]}\\\n`;
}
newFailures = newFailures.slice(0, -2);
} else {
newFailures += "- No failed scenarios";
}
}
newFailures += `\n\n[MARKER]: <> (END OF GENERATOR TESTING FAILURES)`;

return newFailures;
}

function getNewTable(results) {
let newTable =
"[MARKER]: <> (START OF GENERATOR TESTING TABLE)\n\n| Generator | Scenarios | Passed | Skipped | Undefined | Failed | Time |\n| --- | --- | --- | --- | --- | --- | --- |\n";

const languages = Object.keys(results);

for (let xx = 0; xx < languages.length; xx++) {
const result = results[languages[xx]];
newTable += `| **${languages[xx]}** | ${result.scenarios} | ${result.passed} | ${result.skipped} | ${result.undef} | ${result.failed} | ${result.time} |\n`;
}

newTable += `\n[MARKER]: <> (END OF GENERATOR TESTING TABLE)`;

return newTable;
}

function populateWebpage(results) {
let fileContents = fs.readFileSync("docs/index.md", "utf-8");

fileContents = fileContents.replace(tableRegex, getNewTable(results));

fileContents = fileContents.replace(failuresRegex, getNewFailures(results));

fs.writeFileSync("docs/index.md", fileContents);
}

function updateWebpage() {
log.setLogLevel(log.logLevels.verbose);

// Extract cl arguments
const clArgs = process.argv.slice(2);

if (clArgs.length !== 1) {
log.error("Incorrect number of arguments");
process.exit(1);
}
let results;
try {
results = JSON.parse(fs.readFileSync(clArgs[0], "utf-8"));
log.verbose(`${log.underline}Test results${log.resetStyling}`);
log.verbose(results);
} catch (ee) {
log.error(clArgs[0] + " : " + ee.message);
process.exit(1);
}
populateWebpage(results);
}

updateWebpage();

process.exit(0);
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"

## Points to remember when contributing

- The branch `gh-pages` is used to auto-generate the Github Pages webpage. DO NOT USE THIS BRANCH!!!
- This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/) which enforces [Angular Commit Message Conventions](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format). Ensure you are writing your commit messages correctly. Husky hooks have got your back for ensuring correct format but will not prevent the use of wrong types.
- The NPM scripts below can help you fix failing workflow steps:

Expand Down
28 changes: 28 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# OpenAPI Forge

⚒️🔥 Effortlessly create OpenAPI clients from the fiery furnace of our forge

# Generators

Some generators are more mature than others and this means that they can be at different stages of development. This webpage tries to give you an overview of each generator's features by showing the most recent test results with names of tests that are failing.

[comment]: <> (Do not modify the text between the two MARKERs or the MARKERs themselves, it is auto-generated in the updateWebpage.yml workflow)
[MARKER]: <> (START OF GENERATOR TESTING TABLE)

| Generator | Scenarios | Passed | Skipped | Undefined | Failed | Time |
| -------------- | --------- | ------ | ------- | --------- | ------ | ----- |
| **TypeScript** | 30 | 30 | 0 | 0 | 0 | 1m00s |
| **CSharp** | 30 | 30 | 0 | 0 | 0 | 53s |

[MARKER]: <> (END OF GENERATOR TESTING TABLE)

# Testing Failures

[comment]: <> (Do not modify the text between the two MARKERs or the MARKERs themselves, it is auto-generated in the updateWebpage.yml workflow)
[MARKER]: <> (START OF GENERATOR TESTING FAILURES)

## TypeScript

- No failed scenarios

[MARKER]: <> (END OF GENERATOR TESTING FAILURES)
2 changes: 1 addition & 1 deletion src/testGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async function testGenerators(options) {
"testResultParser"
));

const result = testResultParser.parse(stdout[stdout.length - 2]);
const result = testResultParser.parse(stdout);

// check if failed/skipped/undefined steps in tests. If so OR them onto the exit code to stop overwriting previous errors
exitCode = exitCode | checkTestResultForErrors(result);
Expand Down

0 comments on commit ff74b49

Please sign in to comment.