diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6dcd627 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,32 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/node:8.8 + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: yarn install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + # run tests! + - run: yarn test diff --git a/.env.example b/.env.example index 1d46637..7159502 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,7 @@ -HEROKU_URL=https://berend-botje.herokuapp.com -HUBOT_GITHUB_EVENT_NOTIFIER_ROOM=zuidlaren +# Example +HUBOT_GITHUB_EVENT_NOTIFIER_ROOM=my-event-room HUBOT_GITHUB_EVENT_NOTIFIER_TYPES=pull_request:opened,pull_request:assigned,pull_request:review_requested,issues:opened,issues:assigned,issue_comment,pull_request_review:submitted,status -HUBOT_GITHUB_USERS=wesleydebruijn:wesley,delneet:danieldelnaaij,DeRidder:peter,Jumba:cwongloising -HUBOT_HEROKU_KEEPALIVE_URL=https://berend-botje.herokuapp.com/ -HUBOT_SLACK_BOTNAME=Berend -HUBOT_SLACK_TEAM=Websend +HUBOT_GITHUB_USERS=github_username:slack_username,other_github_username:other_slack_username +HUBOT_SLACK_BOTNAME=Hubot +HUBOT_SLACK_TEAM=MySlackTeam HUBOT_SLACK_TOKEN=xoxb-secret -TZ=Europe/Amsterdam diff --git a/.gitignore b/.gitignore index e9049bb..1e837c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ node_modules .DS_Store* .hubot_history +.idea +.vagrant + +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..77b9d73 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:8.8 + +WORKDIR /berend + +ADD . /berend + +RUN yarn install diff --git a/README.md b/README.md index d422134..f5efc27 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,21 @@ Berend will notify a developer directly when: * a build has finished in Jenkins of his/her commit in a branch ## Configuration -Berend can easily be deployed on a free Heroku instance. Only the GitHub repository needs to be connected in Heroku and you're good to go. +Berend runs inside Docker on a node 8.8 image. +Yarn packages are installed when building the image. +See the Dockerfile and docker-compose.yml for more details. + ### Environment variables The following environment variables are required to run Berend. See .env.example for an example. ``` -HEROKU_URL HUBOT_GITHUB_EVENT_NOTIFIER_ROOM // Name of global chatroom in Slack HUBOT_GITHUB_EVENT_NOTIFIER_TYPES // Accepted GitHub events HUBOT_GITHUB_USERS // Mapping of GitHub/Slack users (wesleydebruijn:wesley) -HUBOT_HEROKU_KEEPALIVE_URL // Heroku URL HUBOT_SLACK_BOTNAME // Slack name HUBOT_SLACK_TEAM // Slack team name HUBOT_SLACK_TOKEN // Token to get access to Slack -TZ // Timezone ``` diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..e506182 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + vb.name = "Berend" + vb.memory = "2048" + end + + config.vm.provision :docker + config.vm.provision :docker_compose, + compose_version: '1.17.1', + yml: '/vagrant/docker-compose.yml', + project_name: 'berend', + run: 'always', + rebuild: true +end diff --git a/bin/hubot b/bin/hubot index 1738780..8f16e7d 100755 --- a/bin/hubot +++ b/bin/hubot @@ -2,7 +2,6 @@ set -e -npm install export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" exec node_modules/.bin/hubot --name "Berend" "$@" diff --git a/bin/hubot.cmd b/bin/hubot.cmd index 35c9c6f..d8ee198 100644 --- a/bin/hubot.cmd +++ b/bin/hubot.cmd @@ -1,3 +1,3 @@ @echo off -npm install && node_modules\.bin\hubot.cmd --name "Berend" %* \ No newline at end of file +node_modules\.bin\hubot.cmd --name "Berend" %* diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..223ac6f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '2' +services: + bot: + build: . + command: "/berend/bin/hubot --adapter slack" + ports: + - "8080:8080" + env_file: + - .env diff --git a/external-scripts.json b/external-scripts.json index 6871c24..8633276 100644 --- a/external-scripts.json +++ b/external-scripts.json @@ -1,7 +1,5 @@ [ "hubot-diagnostics", "hubot-help", - "hubot-heroku-keepalive", - "hubot-redis-brain", - "hubot-rules" + "hubot-redis-brain" ] diff --git a/package.json b/package.json index bd81deb..d969581 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Berend", - "version": "0.1.0", + "version": "0.2.0", "private": true, "author": "Daniel ", "description": "Berend Botje", @@ -9,9 +9,7 @@ "hubot": "^2.16.0", "hubot-diagnostics": "0.0.1", "hubot-help": "^0.1.2", - "hubot-heroku-keepalive": "^1.0.0", "hubot-redis-brain": "0.0.3", - "hubot-rules": "^0.1.1", "hubot-scripts": "*", "hubot-slack": "^3.4.1", "lodash": "^2.4.1", @@ -19,7 +17,7 @@ "scraper": "0.0.9" }, "engines": { - "node": "8.1.4", - "npm": "*" + "node": "8.8", + "yarn": "*" } }