mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Move CI to GitHub Actions (#5431)
Replaces Travis CI with GitHub Actions
This commit is contained in:
parent
e7f64334c0
commit
cc5c000a6d
50
.github/workflows/ci.yml
vendored
Normal file
50
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
name: CI
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.6, 3.7]
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: netbox
|
||||||
|
POSTGRES_PASSWORD: netbox
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies & set up configuration
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install pycodestyle coverage
|
||||||
|
ln -s configuration.testing.py netbox/netbox/configuration.py
|
||||||
|
|
||||||
|
- name: Check PEP8 compliance
|
||||||
|
run: pycodestyle --ignore=W504,E501 netbox/
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: coverage run --source="netbox/" netbox/manage.py test netbox/
|
||||||
|
|
||||||
|
- name: Show coverage report
|
||||||
|
run: coverage report --skip-covered --omit *migrations*
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
services:
|
|
||||||
- postgresql
|
|
||||||
- redis-server
|
|
||||||
addons:
|
|
||||||
postgresql: "9.6"
|
|
||||||
language: python
|
|
||||||
python:
|
|
||||||
- "3.6"
|
|
||||||
- "3.7"
|
|
||||||
install:
|
|
||||||
- pip install -r requirements.txt
|
|
||||||
- pip install pycodestyle
|
|
||||||
- pip install coverage
|
|
||||||
before_script:
|
|
||||||
- psql --version
|
|
||||||
- psql -U postgres -c 'SELECT version();'
|
|
||||||
script:
|
|
||||||
- ./scripts/cibuild.sh
|
|
@ -19,8 +19,8 @@ or join us in the **#netbox** Slack channel on [NetworkToCode](https://networkto
|
|||||||
|
|
||||||
| | status |
|
| | status |
|
||||||
|-------------|------------|
|
|-------------|------------|
|
||||||
| **master** | [](https://travis-ci.com/netbox-community/netbox/) |
|
| **master** |  |
|
||||||
| **develop** | [](https://travis-ci.com/netbox-community/netbox/) |
|
| **develop** |  |
|
||||||
|
|
||||||
### Screenshots
|
### Screenshots
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ ALLOWED_HOSTS = ['*']
|
|||||||
|
|
||||||
DATABASE = {
|
DATABASE = {
|
||||||
'NAME': 'netbox',
|
'NAME': 'netbox',
|
||||||
'USER': '',
|
'USER': 'netbox',
|
||||||
'PASSWORD': '',
|
'PASSWORD': 'netbox',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': '',
|
'PORT': '',
|
||||||
'CONN_MAX_AGE': 300,
|
'CONN_MAX_AGE': 300,
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
#!/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
|
|
||||||
|
|
||||||
# Check all python source files for PEP 8 compliance, but explicitly
|
|
||||||
# ignore:
|
|
||||||
# - W504: line break after binary operator
|
|
||||||
# - E501: line greater than 80 characters in length
|
|
||||||
pycodestyle \
|
|
||||||
--ignore=W504,E501 \
|
|
||||||
netbox/
|
|
||||||
RC=$?
|
|
||||||
if [[ $RC != 0 ]]; then
|
|
||||||
echo -e "\n$(info) one or more PEP 8 errors detected, failing build."
|
|
||||||
EXIT=$RC
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Point to the testing configuration file for use in CI
|
|
||||||
ln -s configuration.testing.py netbox/netbox/configuration.py
|
|
||||||
|
|
||||||
# Run NetBox tests
|
|
||||||
coverage run --source="netbox/" netbox/manage.py test netbox/
|
|
||||||
RC=$?
|
|
||||||
if [[ $RC != 0 ]]; then
|
|
||||||
echo -e "\n$(info) one or more tests failed, failing build."
|
|
||||||
EXIT=$RC
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show code coverage report
|
|
||||||
coverage report --skip-covered --omit *migrations*
|
|
||||||
RC=$?
|
|
||||||
if [[ $RC != 0 ]]; then
|
|
||||||
echo -e "\n$(info) failed to generate code coverage report."
|
|
||||||
EXIT=$RC
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show build duration
|
|
||||||
END=$(date +%s)
|
|
||||||
echo "$(info) exiting with code $EXIT after $(($END - $START)) seconds."
|
|
||||||
|
|
||||||
exit $EXIT
|
|
Loading…
Reference in New Issue
Block a user