Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: apply github action to catch error in example pages #963

Merged
merged 1 commit into from
May 21, 2020
Merged
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
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"
}