diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..5d1dfefe --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: node_js +node_js: + - "8.3" + +sudo: required +services: + - docker +before_install: + -docker pull node:8-onbuild + +install: + -docker build -t probot-hello + +script: + -docker run --rm probot-hello npm run test + -docker run --rm probot-hello npm run lint \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d8ead0f0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# https://hub.docker.com/_/node/ +FROM node:8-onbuild + +# use debug to troubleshoot +ENV LOG_LEVEL=error +# Required env settings determined by GitHub App +ENV APP_ID=1234 +ENV WEBHOOK_SECRET=development +ENV WEBHOOK_PROXY_URL=https://localhost:3000/ +ENV PRIVATE_KEY="someprivatestring" + +# see https://github.com/nodejs/docker-node/blob/e3ec2111af089e31321e76641697e154b3b6a6c3/docs/BestPractices.md#global-npm-dependencies +ENV NPM_CONFIG_PREFIX=/home/node/.npm-global +ENV PATH=$PATH:/home/node/.npm-global/bin + +# Lets install our app into /home/node +COPY . /home/node/probot-hello +RUN chown -R node:node /home/node/probot-hello + +# setup our app +# non-root user https://github.com/nodejs/docker-node/blob/e3ec2111af089e31321e76641697e154b3b6a6c3/docs/BestPractices.md#non-root-user +USER node + +WORKDIR /home/node/probot-hello +RUN npm install diff --git a/README.md b/README.md index 6d09713e..208c995d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ npm install npm start ``` +There are some useful hacking commands [here](/docs/HACKING.md). + ## Contributing If you have suggestions for how probot-hello could be improved, or want to report a bug, open an issue! We'd love all and any contributions. diff --git a/docs/HACKING.md b/docs/HACKING.md new file mode 100644 index 00000000..ff2e5521 --- /dev/null +++ b/docs/HACKING.md @@ -0,0 +1,41 @@ +# Build locally +`docker build -t probot-hello .` + +# Test the project +`docker run -it --rm probot-hello npm run test` + +# Test out running locally + +This starts things up locally without connecting to a GitHub App. + +``` +docker run -it --rm \ + -e NODE_ENV=dev \ + -e APP_ID=aaa \ + -e WEBHOOK_SECRET=bbb \ + -e PRIVATE_KEY=$(echo abcd|base64) \ + -p 3000:3000 probot-hello npm start +``` + +Try opening a browser to http://localhost:3000 to see the probot web start. + +# Develop locally + +Changes to your source code get reflected in the container and node restarts +our app with the latest changes. + +``` +docker run -it --rm \ + -e APP_ID=abc \ + -e PRIVATE_KEY=none \ + -w /home/node/probot-hello-dev \ + -v "$(pwd)":/home/node/probot-hello-dev \ + -p 3000:3000 probot-hello \ + bash -c 'npm install && npm run dev' +``` + +# Lint Test +`docker run -it --rm probot-hello npm run lint` + +# Show Coverage Report +`docker run -it --rm probot-hello npm run coverage` diff --git a/package.json b/package.json index edb7d904..e0505857 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,13 @@ "start": "probot run ./index.js", "lint": "standard --fix", "test": "jest && standard", + "coverage": "jest --coverage", "test:watch": "jest --watch --notify --notifyMode=change --coverage" }, "dependencies": { - "probot": "^7.0.0" + "dev": "^0.1.3", + "probot": "^7.0.0", + "run": "^1.4.0" }, "devDependencies": { "jsdom": "11.11.0",