Browse Source

Merge pull request #38 from digitalocean/travis-ci

Add Travis CI build
Jeremy Stretch 8 years ago
parent
commit
6e068770ea
4 changed files with 38 additions and 1 deletions
  1. 1 1
      .gitignore
  2. 7 0
      .travis.yml
  3. 2 0
      README.md
  4. 28 0
      scripts/cibuild.sh

+ 1 - 1
.gitignore

@@ -1,6 +1,6 @@
 *.pyc
 *.pyc
 configuration.py
 configuration.py
 .idea
 .idea
-*.sh
+./*.sh
 fabfile.py
 fabfile.py
 
 

+ 7 - 0
.travis.yml

@@ -0,0 +1,7 @@
+language: python
+python:
+  - "2.7"
+install:
+  - pip install -r requirements.txt
+script:
+  - ./scripts/cibuild.sh

+ 2 - 0
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 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).
 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).

+ 28 - 0
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