Skip to content

Commit

Permalink
feat: add config files to log error of example pages (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
seonim-ryu authored May 21, 2020
1 parent 7cddc9e commit 7f44dbd
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/examplePageTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: detect runtime error

on:
schedule:
- cron: '0 22 * * *'
jobs:
makeUrl:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: create config variable
run: |
node apps/editor/scripts/createConfigVariable.js
- name: set global error variable
run: |
errorVariable=`cat ./errorVariable.txt`
echo ::set-env name=ERROR_VARIABLE::$errorVariable
- name: set url
shell: bash
run: |
url=`cat ./url.txt`
echo ::set-env name=URLS::$url
- name: detect runtime error
uses: nhn/toast-ui.detect-runtime-error-actions@master
with:
global-error-log-variable: ${{ env.ERROR_VARIABLE }}
urls: ${{ env.URLS }}
env:
BROWSERSTACK_USERNAME: ${{secrets.BROWSERSTACK_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
36 changes: 36 additions & 0 deletions apps/editor/scripts/createConfigVariable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs');
const path = require('path');
const config = require(path.resolve(process.cwd(), 'tuidoc.config.json'));
const examples = config.examples || {};
const { filePath, globalErrorLogVariable } = examples;

/**
* Get Examples Url
*/
function getTestUrls() {
if (!filePath) {
throw Error('not exist examples path at tuidoc.config.json');
}

const urlPrefix = 'http://nhn.github.io/tui.editor/latest';

const testUrls = fs.readdirSync(filePath).reduce((urls, fileName) => {
if (/html$/.test(fileName)) {
urls.push(`${urlPrefix}/${filePath}/${fileName}`);
}
return urls;
}, []);

fs.writeFileSync('url.txt', testUrls.join(', '));
}

function getGlobalVariable() {
if (!globalErrorLogVariable) {
throw Error('not exist examples path at tuidoc.config.json');
}

fs.writeFileSync('errorVariable.txt', globalErrorLogVariable);
}

getTestUrls();
getGlobalVariable();
3 changes: 2 additions & 1 deletion apps/editor/tuidoc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"example20-i18n": "20. Internationalization (i18n)",
"example21-placeholder": "21. Placeholder",
"example22-using-custom-sanitizer": "22. Using Custom HTML Sanitizer"
}
},
"globalErrorLogVariable": true
},
"pathPrefix": "tui.editor"
}

0 comments on commit 7f44dbd

Please sign in to comment.