diff --git a/.buildkite/browserTests b/.buildkite/browserTests new file mode 100755 index 00000000..da6d3618 --- /dev/null +++ b/.buildkite/browserTests @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +export DISPLAY=:99.0 +/etc/init.d/xvfb start + +./node_modules/.bin/unitest --browser=dist-tests/browser.js diff --git a/.buildkite/nodeTests b/.buildkite/nodeTests new file mode 100755 index 00000000..37917271 --- /dev/null +++ b/.buildkite/nodeTests @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +./node_modules/.bin/unitest --node=dist-tests/node.js diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml new file mode 100644 index 00000000..770c4a2b --- /dev/null +++ b/.buildkite/pipeline.yml @@ -0,0 +1,22 @@ +steps: + - name: ":docker: :package:" + plugins: + docker-compose#v1.5.2: + build: fusion-plugin-universal-events + image-repository: 296822479253.dkr.ecr.us-east-2.amazonaws.com/fusionjs + - wait + - name: ":eslint:" + command: "yarn lint" + plugins: + docker-compose#v1.5.2: + run: fusion-plugin-universal-events + - name: ":chrome: :white_check_mark:" + command: ".buildkite/browserTests" + plugins: + docker-compose#v1.5.2: + run: fusion-plugin-universal-events + - name: ":node: :white_check_mark:" + command: ".buildkite/nodeTests" + plugins: + docker-compose#v1.5.2: + run: fusion-plugin-universal-events diff --git a/.buildkite/xvfb_daemon_run b/.buildkite/xvfb_daemon_run new file mode 100644 index 00000000..6ba4112b --- /dev/null +++ b/.buildkite/xvfb_daemon_run @@ -0,0 +1,8 @@ +#!/bin/bash +export DISPLAY=:99 +/etc/init.d/xvfb start +sleep 1 +$@ +exit_value=$? +/etc/init.d/xvfb stop +exit $exit_value diff --git a/.buildkite/xvfb_init b/.buildkite/xvfb_init new file mode 100644 index 00000000..7e2890d8 --- /dev/null +++ b/.buildkite/xvfb_init @@ -0,0 +1,23 @@ +XVFB=/usr/bin/Xvfb +XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16 +extension RANDR" +PIDFILE=/var/xvfb_${DISPLAY:1}.pid +case "$1" in + start) + echo -n "Starting virtual X frame buffer: Xvfb" + /sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS + echo "." + ;; + stop) + echo -n "Stopping virtual X frame buffer: Xvfb" + /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE + echo "." + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: /etc/init.d/xvfb {start|stop|restart}" + exit 1 +esac +exit 0 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f1c7ca87..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -dist: trusty -sudo: false -language: node_js -node_js: 8.9.0 -before_install: -- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.2.1 -- export PATH=$HOME/.yarn/bin:$PATH -before_script: -- export DISPLAY=':99.0' -- sh -e /etc/init.d/xvfb start -cache: - yarn: true -before_deploy: -- yarn global add npm-publish-prerelease -- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc -deploy: - provider: script - script: npm-publish-prerelease - skip_cleanup: true - on: - tags: true -env: - global: - secure: x56ahmtxgYAfqvmdsCPTRxqNPwaZrjqv/W149e1QJDhzVVV+7cOroSKwRvIs+bT+eKy+vN7o4PVQ+PDeV7gPHDcGSsnwgzNrQBV5Ga3B98CzyMWk7qPysBYBGyltGcol6g0Tx5MlxQCY9+H4qSQRltFS+HsiE5yhcNrZ2g9RBZz9NyPZR9WzOrE3wMELgSOSWZAdLC9HC6PbQfVFh3lnE6GaJEU61TaF1EI9i6MJ7or11uWIMKnXJY6GesOv648R6tCx3wOXzpb85TlaXXKLXSUVeOeTP3Zt2cZ+ymTWnLyy24oQlUwAbn2GtOKzSBkdxRTRcWO1ts9WTd4yohxabSEHU1sOSjFzrvxBU1BLifmsuYAPHLQcLv4wcq4ABQAmbku9+HADHUxFY5l2e4OlXXBBXvgt1dLcBhLQly2OwMZIslYagMFd/j33JA9wgZJ3n2D1hy55N9I0nuIsPEmSKcSVFvkJlxLtEsYhW54Wkt2LIm5Owi3gnELNtFtv7D6EWUfo/DY2Ai3hCOGPk9df67vqndNSCIgDfw0J9u6AHLEHQjBJ2WukBRsP4wLjEKl/Am6/BmeHlvKTKLjc6JqZi9LkT8hIwXI1phFLxGOq0ll+N62fe2TsHfeVQqDnvywTsZhQdmk2Tw3xGT8Y12Og4TYxKe5JhM4R9FrHF64FQLI= diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..881cbaee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:8.9.0 + +WORKDIR /fusion-plugin-universal-events + +# Install electron dependencies. +ENV DISPLAY :99 +ADD .buildkite/xvfb_init /etc/init.d/xvfb +ADD .buildkite/xvfb_daemon_run /usr/bin/xvfb-daemon-run + +RUN dpkg --add-architecture i386 +RUN apt-get update +RUN apt-get -y install libgtk2.0-dev libx11-xcb-dev libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev libxss1 xvfb && \ + chmod a+x /etc/init.d/xvfb /usr/bin/xvfb-daemon-run + +COPY . . + +RUN yarn + +RUN yarn build-test diff --git a/README.md b/README.md index edb1fcf5..13f1f74b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # fusion-plugin-universal-events +[![Build status](https://badge.buildkite.com/de4e30ddb9d019f5a8e3a2519bc0a5cccab25247809cd10c99.svg?branch=master)](https://buildkite.com/uberopensource/fusion-plugin-universal-events) + This is a [Fusion plugin](https://github.com/fusionjs/fusion-core) that captures events emitted from the client, sends them in batches to the server periodically, and allows the server to handle them. It's useful for when you want to collect data about user actions or other metrics, and send them in bulk to the server to minimize the number of HTTP requests. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..6ebe2c35 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '2' +services: + fusion-plugin-universal-events: + build: . + volumes: + - .:/fusion-plugin-universal-events + - /fusion-plugin-universal-events/node_modules/ + - /fusion-plugin-universal-events/dist/ + - /fusion-plugin-universal-events/dist-tests/