From d5d4eb9fd5a3acac136f74ea6d99082d04982acf Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Mon, 27 Jun 2016 16:48:54 -0400 Subject: [PATCH] Add Travis CI build --- .gitignore | 2 +- .travis.yml | 7 +++++++ README.md | 2 ++ scripts/cibuild.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100755 scripts/cibuild.sh diff --git a/.gitignore b/.gitignore index e8ff56275..83343ee0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.pyc configuration.py .idea -*.sh +./*.sh fabfile.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..a7f9cda45 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - "2.7" +install: + - pip install -r requirements.txt +script: + - ./scripts/cibuild.sh diff --git a/README.md b/README.md index becf60963..e9bbf689b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# NetBox [![Build Status](https://travis-ci.org/digitalocean/netbox.svg?branch=master)](https://travis-ci.org/digitalocean/netbox) + NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team at [DigitalOcean](https://www.digitalocean.com/), NetBox was developed specifically to address the needs of network and infrastructure engineers. NetBox runs as a web application atop the [Django](https://www.djangoproject.com/) Python framework with a [PostgreSQL](http://www.postgresql.org/) database. For a complete list of requirements, see `requirements.txt`. The code is available [on GitHub](https://github.com/digitalocean/netbox). diff --git a/scripts/cibuild.sh b/scripts/cibuild.sh new file mode 100755 index 000000000..91a847c37 --- /dev/null +++ b/scripts/cibuild.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Exit code starts at 0 but is modified if any checks fail +EXIT=0 + +# Output a line prefixed with a timestamp +info() +{ + echo "$(date +'%F %T') |" +} + +# Track number of seconds required to run script +START=$(date +%s) +echo "$(info) starting build checks." + +# Syntax check all python source files +SYNTAX=$(find . -name "*.py" -type f -exec python -m py_compile {} \; 2>&1) +if [[ ! -z $SYNTAX ]]; then + echo -e "$SYNTAX" + echo -e "\n$(info) detected one or more syntax errors, failing build." + EXIT=1 +fi + +# Show build duration +END=$(date +%s) +echo "$(info) exiting with code $EXIT after $(($END - $START)) seconds." + +exit $EXIT