Skip to content

Commit

Permalink
Test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
indigane committed Jan 31, 2024
1 parent e796fc8 commit 7ac5560
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
18 changes: 9 additions & 9 deletions parkkihubi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@
#########
# Paths #
#########
default_var_root = os.path.join(BASE_DIR, 'var')
user_var_root = os.path.expanduser('~/var')
if os.path.isdir(user_var_root):
default_var_root = user_var_root
VAR_ROOT = env.str('VAR_ROOT', default_var_root)
# default_var_root = os.path.join(BASE_DIR, 'var')
# user_var_root = os.path.expanduser('~/var')
# if os.path.isdir(user_var_root):
# default_var_root = user_var_root
# VAR_ROOT = env.str('VAR_ROOT', default_var_root)

# Create var root if it doesn't exist
if not os.path.isdir(VAR_ROOT):
os.makedirs(VAR_ROOT)
# if not os.path.isdir(VAR_ROOT):
# os.makedirs(VAR_ROOT)

MEDIA_ROOT = os.path.join(VAR_ROOT, 'media')
# MEDIA_ROOT = os.path.join(VAR_ROOT, 'media')
MEDIA_URL = '/media/'
ROOT_URLCONF = 'parkkihubi.urls'
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
# STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
STATIC_URL = '/static/'

############
Expand Down
19 changes: 4 additions & 15 deletions run-pytest
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
# or add USE_DOCKER=1 to the .env file.

set -e
echo "here 0"

USE_DOCKER=${USE_DOCKER}
if [[ -z "$USE_DOCKER" ]] && [[ -e .env ]]; then
USE_DOCKER=$(sed -n '/^USE_DOCKER=/s/^[^=]*=//p' .env)
fi

echo "here 1"
if [[ "$USE_DOCKER" == "1" ]] || [[ "$USE_DOCKER" == "yes" ]]; then
cp -n local_settings.py.tpl_dev local_settings.py
docker-compose up -d
Expand All @@ -25,8 +24,6 @@ fi

unset xml_file
opts=()

echo "here 2"
while [[ $# -gt 0 ]]; do
opt="$1"
shift
Expand All @@ -44,29 +41,21 @@ misc_opts=(
"-o" "cache_dir=/tmp/pytest_cache"
)

echo "here 3"
docker_compose_exec=("docker-compose" "exec")
if ! tty -s; then
docker_compose_exec+=("-T") # If there is no TTY available, pass -T
fi

## Wait until the database is ready
#echo "Running docker with command ${docker_compose_exec[@]}"
#"${docker_compose_exec[@]}" -e RUN_MIGRATIONS=0 runserver ./docker-entrypoint /bin/true
# Wait until the database is ready
"${docker_compose_exec[@]}" -e RUN_MIGRATIONS=0 runserver ./docker-entrypoint /bin/true

set +e
echo "here 5"

output="$("${docker_compose_exec[@]}" runserver /home/bew/.venv/bin/pytest "${misc_opts[@]}" "${opts[@]}" 2>&1)"
"${docker_compose_exec[@]}" runserver /home/bew/.venv/bin/pytest "${misc_opts[@]}" "${opts[@]}"
exit_code=$?

set -e

if [[ -n "$xml_file" ]]; then
"${docker_compose_exec[@]}" runserver cat /tmp/pytest_junit.xml > "$xml_file"
fi

if [ $exit_code -ne 0 ]; then
echo "$output"
fi
exit $exit_code

0 comments on commit 7ac5560

Please sign in to comment.