Skip to content

Commit

Permalink
daily health check
Browse files Browse the repository at this point in the history
  • Loading branch information
disjukr committed Aug 16, 2019
1 parent 13d5987 commit 92dc4d1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: push
name: Test and deploy
on: push
jobs:
install:
name: Install
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
name: Run health check
on:
schedule:
- cron: 0 0 * * *
name: Run daily test
jobs:
install:
name: Install
runs-on: ubuntu-latest
steps:
- name: Only master
uses: actions/bin/filter@25b7b846d5027eac3315b50a8055ea675e2abd89
with:
args: branch master
- uses: actions/checkout@master
- name: Install
uses: actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680
with:
args: install
- name: Run testcases
- name: Run health check
uses: actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680
with:
args: test:health-check
- name: Push health check
uses: ./actions/push-health-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 3 additions & 4 deletions actions/deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM node:9
LABEL "version"="0.0.7"
FROM node:12
LABEL "version"="0.0.8"
LABEL "com.github.actions.name"="Deploy"
LABEL "com.github.actions.description"="Deploy just-news"
LABEL "com.github.actions.icon"="archive"
LABEL "com.github.actions.color"="orange"

LABEL "repository"="https://github.com/disjukr/just-news/actions/deploy"
LABEL "homepage"="https://github.com/disjukr/just-news/actions/deploy"
LABEL "maintainer"="item4 <[email protected]>"
LABEL "maintainer"="JongChan Choi <[email protected]>"

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

1 change: 0 additions & 1 deletion actions/deploy/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ echo "git push origin release"
git push origin release
echo "popd"
popd

13 changes: 13 additions & 0 deletions actions/push-health-check/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:12
LABEL "version"="0.0.0"
LABEL "com.github.actions.name"="Push health check"
LABEL "com.github.actions.description"="Push health check"
LABEL "com.github.actions.icon"="archive"
LABEL "com.github.actions.color"="orange"

LABEL "repository"="https://github.com/disjukr/just-news/actions/deploy"
LABEL "homepage"="https://github.com/disjukr/just-news/actions/deploy"
LABEL "maintainer"="JongChan Choi <[email protected]>"

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
38 changes: 38 additions & 0 deletions actions/push-health-check/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
RELEASE_DIR=../just-news-push-health-check
BUILD_DIR=$(pwd)

echo "npm run test:health-check"
npm run test:health-check

echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
git config --global user.name "just-news-bot"
git config --global user.email "[email protected]"
git config --bool core.bare true

echo "git clone release"
git clone https://github.com/disjukr/just-news.git $RELEASE_DIR
echo "pushd to RELEASE_DIR"
pushd $RELEASE_DIR

echo "git checkout release"
git checkout health-check

echo "copy files"
cp $BUILD_DIR/tmp/health-check.md health-check.md
cp $BUILD_DIR/tmp/health-check.png health-check.png
echo "git add -f ."
git add -f .

echo "check git status"
git status
if git status | grep 'no changes added to commit'; then
exit
fi

echo "git commit"
git commit -m "$(date)"
echo "git push origin health-check"
git push origin health-check
echo "popd"
popd
5 changes: 4 additions & 1 deletion src/test/health-check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
fromJSON,
} from '../..';
import imageReporter from './reporter/image';
import markdownReporter from './reporter/markdown';


interface Case {
Expand Down Expand Up @@ -185,7 +186,7 @@ const cases: Case[] = [
async function run() {
const jobs = [...cases];
const jobResults: JobResult[] = [];
//*
/*
const headless = false;
const workers = [0, 1];
/*/
Expand Down Expand Up @@ -215,11 +216,13 @@ async function run() {
}
}));
await imageReporter(jobResults, browser);
const markdownReport = await markdownReporter(jobResults, browser);
await browser.close();
fs.writeFileSync(
'./tmp/health-check.json',
JSON.stringify(jobResults, null, 4),
);
fs.writeFileSync('./tmp/health-check.md', markdownReport);
}
run().catch(e => {
console.error(e ? (e.stack || e) : e);
Expand Down

0 comments on commit 92dc4d1

Please sign in to comment.