Skip to content

Commit

Permalink
Merge pull request #33 from ytjohn/master
Browse files Browse the repository at this point in the history
build refactor
  • Loading branch information
Andrew Hou authored and Andrew Hou committed May 3, 2016
2 parents bd72821 + a624e6a commit a247e00
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 13 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.travis.yml
debian/
Dockerfile
extra/
Gruntfile.js
HWIMO-*
LICENSE
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ node_modules

# binary add-ins that we put in the repo for slimy convenience
static/tftp

# Vagrant
.vagrant/
15 changes: 2 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@ addons:
- git

after_success:
- ./node_modules/.bin/istanbul cover -x "**/spec/**" ./node_modules/.bin/_mocha --report lcovonly -- $(find spec -name '*-spec.js') -R spec --require spec/helper.js
- cat ./coverage/lcov.info | node_modules/.bin/coveralls
- ./extra/make-testcoveralls.sh

before_deploy:
- npm prune --production
- mkdir -p packagebuild deb
- cp -ar !(packagebuild) packagebuild/
- pushd packagebuild
- git log -n 1 --pretty=format:%h.%ai.%s > commitstring.txt
- export DEBFULLNAME=`git log -n 1 --pretty=format:%an`
- export DEBEMAIL=`git log -n 1 --pretty=format:%ae`
- dch -l `echo "${TRAVIS_BRANCH}" | sed 's/[\/\_]/-/g'` -u low `git log -n 1 --pretty=oneline --abbrev-commit`
- debuild --no-lintian --no-tgz-check -us -uc
- popd
- cp -a *.deb deb/
- ./extra/make-deb.sh

deploy:
provider: bintray
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@ To run tests and get coverage for CI:
./node_modules/.bin/istanbul report cobertura
# if you want HTML reports locally
./node_modules/.bin/istanbul report html

## Building

Unversioned packages are built automatically from travis-ci and uploaded to bintray.com. Using
this repository is detailed in [the docs](http://rackhd.readthedocs.org/en/latest/rackhd/ubuntu_package_installation.html).

Build scripts are placed in the `extra/` directory.

* `.travis.yml` will call the appropriate scripts in `extra/` to build an unversioned package.
* `extra/make-sysdeps.sh` can be used to install system level packages in a Ubuntu system.
* `extra/make-cicd.sh` will perform all the necessary build steps to generate a version package.

If you want to build your own versioned packages, you can use the Vagrantfile provided in `extra/`. Simply perform `vagrant up` and it will run all the necessary steps.

73 changes: 73 additions & 0 deletions extra/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
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"
config.vm.synced_folder "../", "/vagrant"

# 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|
# Display the VirtualBox GUI when booting the machine
# vb.gui = true

# Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.

# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
cd /vagrant
sudo ./extra/make-sysdeps.sh
./extra/make-cicd.sh
SHELL
end
28 changes: 28 additions & 0 deletions extra/make-cicd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# This creates a package in a manner similar to
# HWIMO-BUILD: datestring package version, apidoc
# no coveralls. But it also utilizes build-package.bash
# similar to how travis-ci does.

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

export DEBEMAIL="hwimo robots <hwimo@hwimo.lab.emc.com>"
export DEBFULLNAME="The HWIMO Robots"

GITCOMMITDATE=$(git show -s --pretty="format:%ci")
DATESTRING=$(date -d "$GITCOMMITDATE" -u +"%Y-%m-%d-%H%M%SZ")

export DEBPKGVER="$DATESTRING"
if [ -n "$BUILD_NUMBER" ]
then
export DEBPKGVER="${DEBPKGVER}-${BUILD_NUMBER}"
fi

export DCHOPTS="-v ${DEBPKGVER} autobuild"

./extra/make-npmdeps.sh
./extra/make-deb.sh

15 changes: 15 additions & 0 deletions extra/make-clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

rm -rf *.deb deb/
rm -rf node_modules/
rm -rf test/
rm commitstring.txt
rm -rf on-*.tar.gz*
rm -rf on-*.build
rm -rf on-*.dsc
rm -rf *.build
rm -rf packagebuild/
60 changes: 60 additions & 0 deletions extra/make-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
set -ex

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

# Use the TRAVIS_BRANCH var if defined as travis vm
# doesn't run the git symbolic-ref command.
if [ -z "$TRAVIS_BRANCH" ]; then
BRANCH=$(git symbolic-ref --short -q HEAD)
else
BRANCH=${TRAVIS_BRANCH}
fi

if [ -z "$DEBFULLNAME" ]; then
export DEBFULLNAME=`git log -n 1 --pretty=format:%an`
fi

if [ -z "$DEBEMAIL" ]; then
export DEBEMAIL=`git log -n 1 --pretty=format:%ae`
fi

if [ -z "$DEBBRANCH" ]; then
export DEBBRANCH=`echo "${BRANCH}" | sed 's/[\/\_]/-/g'`
fi

if [ -z "$DEBPKGVER" ]; then
export DEBPKGVER=`git log -n 1 --pretty=oneline --abbrev-commit`
fi

if [ -z "$DCHOPTS" ]; then
export DCHOPTS="-l ${DEBBRANCH} -u low ${DEBPKGVER}"
fi

echo "DEBDIR: $DEBDIR"
echo "DEBFULLNAME: $DEBFULLNAME"
echo "DEBEMAIL: $DEBEMAIL"
echo "DEBBRANCH: $DEBBRANCH"
echo "DEBPKGVER: $DEBPKGVER"
echo "DCHOPTS: $DCHOPTS"


if [ -d packagebuild ]; then
rm -rf packagebuild
fi
mkdir packagebuild
rsync -ar --exclude=packagebuild . packagebuild
pushd packagebuild
rm -rf node_modules
npm install --production
git log -n 1 --pretty=format:%h.%ai.%s > commitstring.txt
dch ${DCHOPTS}
debuild --no-lintian --no-tgz-check -us -uc
popd
if [ ! -d deb ]; then
mkdir deb
fi

cp -a *.deb deb/
7 changes: 7 additions & 0 deletions extra/make-npmdeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

npm install
7 changes: 7 additions & 0 deletions extra/make-npmtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

npm test
19 changes: 19 additions & 0 deletions extra/make-sysdeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# This has to be kept in sync with .travis.yml packages to
# be effective.

echo "Installing system dependencies"
sudo apt-get update
sudo apt-get install -y \
debhelper \
default-jdk \
devscripts \
dh-make \
git \
libkrb5-dev \
nodejs \
nodejs-legacy \
npm \
pbuilder \
ubuntu-dev-tools
9 changes: 9 additions & 0 deletions extra/make-testcoveralls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Ensure we're always in the right directory.
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $SCRIPT_DIR/..

./node_modules/.bin/istanbul cover -x "**/spec/**" ./node_modules/.bin/_mocha --report lcovonly -- $(find spec -name '*-spec.js') -R spec --require spec/helper.js
cat ./coverage/lcov.info | node_modules/.bin/coveralls

0 comments on commit a247e00

Please sign in to comment.