datatracker/docker/scripts/app-init.sh
Lars Eggert 3d44825333
ci: Switch to using geckodriver (#6541)
* Switch to using geckodriver

* Switch to selenium 4

* Undo

* Remove comment

* Fixes

* Restore non-standard line endings to minimize diff

* Undo

* Remove comment

* test: Fix test_upcoming_view_time_zone_selection

The inputs are hidden and managed by JS, so click
the visible elements instead.

* test: Clumsy fix to test_upcoming_materials_modal

Waiting for the button to be clickable does not
work because the modal is still fading in, so does
not actually close. Would be better to check for it
responding, but I haven't found the right way to do
that yet.

* test: Fix test_add_author_forms

Sending '\n' does not seem to work as it did before,
so click the option instead.

Also reverted some fixme hacks that seem to be obe.

* ci: Update base.Dockerfile

* test: add resource limits to dev/tests/debug.sh env

* ci: add upload of geckodriver.log on failure

* ci: run tests as user 1001

* ci: run app-create-dirs as sudo

* ci: set home folder to root to run tests

---------

Co-authored-by: Jennifer Richards <jennifer@staff.ietf.org>
Co-authored-by: Nicolas Giard <github@ngpixel.com>
Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
2023-11-21 15:30:50 -06:00

124 lines
3.9 KiB
Bash
Executable file

#!/bin/bash
WORKSPACEDIR="/workspace"
sudo service rsyslog start &>/dev/null
# Add /workspace as a safe git directory
git config --global --add safe.directory /workspace
# Turn off git info in zsh prompt (causes slowdowns)
git config oh-my-zsh.hide-info 1
# Fix ownership of volumes
echo "Fixing volumes ownership..."
sudo chown -R dev:dev "$WORKSPACEDIR/.parcel-cache"
sudo chown -R dev:dev "$WORKSPACEDIR/__pycache__"
sudo chown -R dev:dev "$WORKSPACEDIR/.vite"
sudo chown -R dev:dev "$WORKSPACEDIR/.yarn/unplugged"
sudo chown dev:dev "/assets"
# Run nginx
echo "Starting nginx..."
sudo nginx
# Build node packages that requrie native compilation
echo "Compiling native node packages..."
yarn rebuild
# Silence Browserlist warnings
export BROWSERSLIST_IGNORE_OLD_DATA=1
# Generate static assets
echo "Building static assets... (this could take a minute or two)"
yarn build
yarn legacy:build
# Copy config files if needed
cp $WORKSPACEDIR/docker/configs/settings_postgresqldb.py $WORKSPACEDIR/ietf/settings_postgresqldb.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local.py" ]; then
echo "Setting up a default settings_local.py ..."
else
echo "Renaming existing ietf/settings_local.py to ietf/settings_local.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local.py $WORKSPACEDIR/ietf/settings_local.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local_debug.py" ]; then
echo "Setting up a default settings_local_debug.py ..."
else
echo "Renaming existing ietf/settings_local_debug.py to ietf/settings_local_debug.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local_debug.py $WORKSPACEDIR/ietf/settings_local_debug.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local_debug.py $WORKSPACEDIR/ietf/settings_local_debug.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local_vite.py" ]; then
echo "Setting up a default settings_local_vite.py ..."
else
echo "Renaming existing ietf/settings_local_vite.py to ietf/settings_local_vite.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local_vite.py $WORKSPACEDIR/ietf/settings_local_vite.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local_vite.py $WORKSPACEDIR/ietf/settings_local_vite.py
# Create data directories
echo "Creating data directories..."
chmod +x ./docker/scripts/app-create-dirs.sh
./docker/scripts/app-create-dirs.sh
# Download latest coverage results file
echo "Downloading latest coverage results file..."
curl -fsSL https://github.com/ietf-tools/datatracker/releases/download/baseline/coverage.json -o release-coverage.json
# Wait for DB container
if [ -n "$EDITOR_VSCODE" ]; then
echo "Waiting for DB container to come online ..."
/usr/local/bin/wait-for db:5432 -- echo "PostgreSQL ready"
fi
# Run memcached
echo "Starting memcached..."
/usr/bin/memcached -u dev -d
# Initial checks
echo "Running initial checks..."
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py check --settings=settings_local
# Migrate, adjusting to what the current state of the underlying database might be:
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --fake-initial --settings=settings_local
if [ -z "$EDITOR_VSCODE" ]; then
CODE=0
python -m smtpd -n -c DebuggingServer localhost:2025 &
if [ -z "$*" ]; then
echo "-----------------------------------------------------------------"
echo "Ready!"
echo "-----------------------------------------------------------------"
echo
echo "You can execute arbitrary commands now, e.g.,"
echo
echo " ietf/manage.py runserver 8001"
echo
echo "to start a development instance of the Datatracker."
echo
echo " ietf/manage.py test --settings=settings_test"
echo
echo "to run all the python tests."
echo
zsh
else
echo "Executing \"$*\" and stopping container."
echo
zsh -c "$*"
CODE=$?
fi
sudo service rsyslog stop
exit $CODE
fi