Update to CI and incorporate tests

This commit is contained in:
Daniël van Noord
2021-04-12 21:27:56 +02:00
parent adca267cfc
commit d56ffd9961

View File

@@ -1,31 +1,29 @@
name: CI name: CI
on: pull_request on: pull_request
jobs: jobs:
Check_ESLint: Check_linting_test_and_build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Check out repository code
uses: actions/checkout@v2
- name: Install dependencies
run: npm ci
- name: Run ESLint - name: Run ESLint
run: | run: npx eslint src
npm install - name: Run Mocha tests
npx eslint src run: npx mocha
Check_main_file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check if CookieMonster.js is built correctly - name: Check if CookieMonster.js is built correctly
run: | run: |
npm install npx webpack -o ./tmp --env production
npx webpack -o ./test --env production if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 test/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###' echo '### SUCCESS: CookieMonster is correctly built! ###'
else else
echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###' echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###'
exit 1 exit 1
fi fi
if cmp <(head -n 2 CookieMonster.js) <(head -n 2 test/CookieMonster.js); then if cmp <(head -n 2 CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###' echo '### SUCCESS: CookieMonster is correctly built! ###'
else else
echo '### WARNING: Make sure to move the file from the /dist folder to the main folder. Otherwise Github Pages won't notice it ###' echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###'
exit 1 exit 1
fi fi