Skip to content

Commit b720842

Browse files
authored
Merge pull request #893 from tobiasge/startup-scripts-complete-removal
Startup scripts complete removal
2 parents 22cb2d5 + aa33578 commit b720842

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

β€Ž.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
LINTER_RULES_PATH: /
3232
VALIDATE_ALL_CODEBASE: false
3333
VALIDATE_DOCKERFILE: false
34+
VALIDATE_GITLEAKS: false
3435
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE|configuration/.*)
3536
EDITORCONFIG_FILE_NAME: .ecrc
3637
DOCKERFILE_HADOLINT_FILE_NAME: .hadolint.yaml

β€Ždocker-compose.test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ services:
33
netbox:
44
image: ${IMAGE-netboxcommunity/netbox:latest}
55
depends_on:
6-
- postgres
7-
- redis
8-
- redis-cache
6+
postgres:
7+
condition: service_healthy
8+
redis:
9+
condition: service_started
10+
redis-cache:
11+
condition: service_started
912
env_file: env/netbox.env
10-
environment:
11-
SKIP_STARTUP_SCRIPTS: ${SKIP_STARTUP_SCRIPTS-false}
1213
user: 'unit:root'
1314
volumes:
1415
- ./configuration:/etc/netbox/config:z,ro
@@ -19,6 +20,11 @@ services:
1920
postgres:
2021
image: postgres:15-alpine
2122
env_file: env/postgres.env
23+
healthcheck:
24+
test: ["CMD-SHELL", "pg_isready"]
25+
interval: 10s
26+
timeout: 5s
27+
retries: 5
2228
redis:
2329
image: redis:7-alpine
2430
command:

β€Ždocker/docker-entrypoint.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ END
8080
echo "πŸ’‘ Superuser Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}"
8181
fi
8282

83-
# Print warning if startup scripts (and initializers) would've been run # Remove for next release
84-
if [ "$SKIP_STARTUP_SCRIPTS" == "true" ]; then
85-
# Nothing to do
86-
echo "" # Empty block not allowed
87-
else
88-
echo "⚠️⚠️⚠️ WARNING: The initializers have been moved to a plugin. See release notes."
89-
echo "⚠️⚠️⚠️ Set environment variable 'SKIP_STARTUP_SCRIPTS' to 'true' to remove this warning."
90-
fi
91-
9283
echo "βœ… Initialisation is done."
9384

9485
# Launch whatever is passed by docker

β€Žtest.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,29 @@ if [ -z "${IMAGE}" ]; then
3535
fi
3636

3737
# The docker compose command to use
38-
doco="docker-compose --file docker-compose.test.yml --project-name netbox_docker_test_${1}"
38+
doco="docker compose --file docker-compose.test.yml --project-name netbox_docker_test"
3939

4040
test_setup() {
4141
echo "πŸ— Setup up test environment"
42+
$doco up --detach --quiet-pull --wait --force-recreate --renew-anon-volumes --no-start
43+
$doco start postgres
44+
$doco start redis
45+
$doco start redis-cache
4246
}
4347

4448
test_netbox_unit_tests() {
4549
echo "⏱ Running NetBox Unit Tests"
4650
$doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py test
4751
}
4852

53+
test_compose_db_setup() {
54+
echo "⏱ Running NetBox DB migrations"
55+
$doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py migrate
56+
}
57+
4958
test_cleanup() {
5059
echo "πŸ’£ Cleaning Up"
51-
$doco down -v
60+
$doco down --volumes
5261
}
5362

5463
echo "🐳🐳🐳 Start testing '${IMAGE}'"
@@ -58,5 +67,6 @@ trap test_cleanup EXIT ERR
5867
test_setup
5968

6069
test_netbox_unit_tests
70+
test_compose_db_setup
6171

6272
echo "🐳🐳🐳 Done testing '${IMAGE}'"

0 commit comments

Comments
Β (0)