Parcourir la source

Add Travis CI build

Matt Layher il y a 9 ans
Parent
commit
d5d4eb9fd5
4 fichiers modifiés avec 38 ajouts et 1 suppressions
  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