forked from nautobot/nautobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
169 lines (141 loc) · 5.4 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Linting/Testing available at https://config.travis-ci.com/explore
os: linux
dist: xenial
# Specify the explicit order of the build stages here.
stages:
- lint
- test
- integration
# Cache settings to explicitly cache Pip & Poetry files
cache:
pip: true
directories:
- ~/.cache/pypoetry
#
## Begin "test" stage global config
#
# Environment variables passed to the job nodes
env:
# Environment variables passed to all jobs
global:
- INVOKE_NAUTOBOT_LOCAL=True
- NAUTOBOT_SELENIUM_URL=http://localhost:4444/wd/hub
- NAUTOBOT_SELENIUM_HOST=$(hostname -f)
# Environment variables passed to "test" stage jobs
jobs:
- DB=postgres NAUTOBOT_DB_ENGINE=django.db.backends.postgresql
- DB=mysql NAUTOBOT_DB_USER=root NAUTOBOT_DB_ENGINE=django.db.backends.mysql
# We be using Python
language: python
# Test these Python versions
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# Services we want installed on the VM(s)
services:
- mysql
- postgresql
- redis
# Explicitly install PostgreSQL 9.6
addons:
postgresql: "9.6"
# Things to do before install phase
before_install:
- pip install poetry
# Install phase
install:
- poetry config virtualenvs.create false
# Poetry 1.1.0 added parallel installation as an option;
# unfortunately it seems to have some issues with installing/updating "requests" and "certifi"
# while simultaneously atttempting to *use* those packages to install other packages.
# For now we disable it.
- poetry config installer.parallel false
- poetry install
# Things to do before the script phase
before_script:
# If postgres: Create the database
- sh -c "if [ '$DB' = 'postgres' ]; then echo 'Creating PostgreSQL database...'; fi"
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'CREATE DATABASE nautobot;' -U postgres; fi"
# If mysql: Upgrade/install MySQL 8.x, then create the database
# We have to upgrade MySQL from v5.7 to get the Travis-specific underpinnings
- sh -c "if [ '$DB' = 'mysql' ]; then echo 'Upgrading MySQL to v8.x...'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then wget https://repo.mysql.com//mysql-apt-config_0.8.17-1_all.deb; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then sudo dpkg -i mysql-apt-config_0.8.17-1_all.deb; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then sudo apt-get update -q; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then sudo apt-get install -q -y --allow-unauthenticated -o Dpkg::Options::=--force-confnew mysql-server; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then sudo systemctl restart mysql; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then sudo mysql_upgrade; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql --version; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then echo 'Creating MySQL database...'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS nautobot;'; fi"
# Install the mysqlclient lib
- sh -c "if [ '$DB' = 'mysql' ]; then poetry install --extras mysql; fi"
# Install Docker Compose
- pip install docker-compose
# Script phase
script:
# Run unit tests
- invoke unittest --failfast --keepdb || travis_terminate 1
# Generate unit test coverage report
- invoke unittest-coverage || travis_terminate 1
#
## End "test" stage global config
#
# Job/stage matrix
jobs:
# Terminate build matrix as soon as any job fails.
fast_finish: true
# Job definitions for custom stages
include:
- stage: lint
before_install:
- pip install poetry
- curl -Lo /home/travis/bin/hadolint https://github.com/hadolint/hadolint/releases/download/v2.0.0/hadolint-Linux-x86_64
- chmod +x /home/travis/bin/hadolint
# Zero out the globals for this stage
# install: [] # nautobot needs to be installed for checking migrations
services: []
addons:
postgresql: ""
before_script:
# This is required so that we can run `invoke check-migrations`
- psql -U postgres -c 'CREATE DATABASE nautobot;'
# Python 3.9; lint only
python: "3.9"
script: "invoke tests --lint-only"
- stage: integration
python: "3.9"
# Services we want installed on the VM(s)
services:
- postgresql
- redis
# Explicitly install PostgreSQL 9.6
addons:
postgresql: "9.6"
# Install phase
install:
- poetry config virtualenvs.create false
# Poetry 1.1.0 added parallel installation as an option;
# unfortunately it seems to have some issues with installing/updating "requests" and "certifi"
# while simultaneously atttempting to *use* those packages to install other packages.
# For now we disable it.
- poetry config installer.parallel false
- poetry install
# Things to do before the script phase
before_script:
# Create Nautobot database
- psql -U postgres -c 'CREATE DATABASE nautobot;'
# Install Docker compose
- pip install docker-compose
# Login to Docker if password is in the environment
- sh -c "if [[ -n '$DOCKER_HUB_PASSWORD' ]]; then echo -e '\n>> Attempting login to Docker Hub...'; echo '$DOCKER_HUB_PASSWORD' | docker login -u '$DOCKER_HUB_USERNAME' --password-stdin; fi"
# Script phase
script:
# Start Selenium container
- invoke start --service selenium
# Run integration tests
- invoke integration-test --keepdb --append
# Generate integration test coverage report
- invoke unittest-coverage || travis_terminate 1