diff --git a/.github/actions/backstop/Dockerfile b/.github/actions/backstop/Dockerfile new file mode 100644 index 0000000..8827af9 --- /dev/null +++ b/.github/actions/backstop/Dockerfile @@ -0,0 +1,7 @@ +FROM node:10.14.1-alpine + +LABEL "com.github.actions.name"="Run Backstop" +LABEL "com.github.actions.description"="Runs Backstop tests in a Docker container" + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/backstop/entrypoint.sh b/.github/actions/backstop/entrypoint.sh new file mode 100755 index 0000000..572ff14 --- /dev/null +++ b/.github/actions/backstop/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Exit if any subcommand fails +set -e + +# Setup node modules if needed +if [ -e node_modules/.bin/jest ]; then + setup="" +else + echo "## Your environment is not ready yet. Installing modules..." + if [ -f yarn.lock ]; then + setup="yarn --non-interactive --silent --ignore-scripts --production=false &&" + else + setup="NODE_ENV=development npm install &&" + fi +fi + + +echo "## Running Action" +args=$@ +sh -c "$setup ((npm run start) & npm run lint)" \ No newline at end of file diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 41b2b22..9453c92 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,6 +1,6 @@ -name: Node Test +name: PR -on: [push] +on: pull_request jobs: test: @@ -10,8 +10,7 @@ jobs: node-version: [12.x] steps: - uses: actions/checkout@v1 - - name: Install dependencies - run: npm install + - uses: ./.github/actions/backstop - name: Run Eslint run: npm run lint - name: Run Jest diff --git a/app.js b/app.js index 16f43a7..0e9f7df 100644 --- a/app.js +++ b/app.js @@ -20,5 +20,4 @@ nunjucks.configure([ watch: true, }); -console.log('http://localhost:3000'); app.listen(3000);