feat(e2e): add Dockerfile and entrypoint script for testing deb packages
Build Debian Package / build (push) Successful in 7s
Build Debian Package / build (push) Successful in 7s
Signed-off-by: Arian Nasr <arian@2ari.ca>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# Navidome-Uploader Dockerfile for testing .deb packages
|
||||
# Arian Nasr
|
||||
# May 31, 2026
|
||||
|
||||
FROM debian:stable
|
||||
|
||||
# Prevent interactive prompts
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
python3 \
|
||||
python3-venv \
|
||||
python3-pip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy the built deb package into the container
|
||||
COPY output/*.deb /tmp/navidrome-uploader.deb
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y -f /tmp/navidrome-uploader.deb && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir -p /opt/navidrome/music && \
|
||||
chown -R navidrome-uploader:navidrome-uploader /opt/navidrome/music
|
||||
|
||||
COPY e2e/ /e2e/
|
||||
|
||||
RUN python3 -m venv /e2e/venv && \
|
||||
/e2e/venv/bin/pip install --no-cache-dir -r /e2e/requirements.txt
|
||||
|
||||
RUN chmod +x /e2e/test-entrypoint.sh
|
||||
|
||||
WORKDIR /e2e
|
||||
|
||||
ENTRYPOINT ["/e2e/test-entrypoint.sh"]
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
export NAVIDROME_MUSIC_FOLDER="/opt/navidrome/music"
|
||||
export BASE_URL="http://127.0.0.1:5001"
|
||||
|
||||
# Start the app manually since systemd isn't running in the container
|
||||
cd /opt/navidrome-uploader
|
||||
su -s /bin/sh navidrome-uploader -c "/opt/navidrome-uploader/venv/bin/gunicorn --no-control-socket -c gunicorn.conf.py main:app" &
|
||||
|
||||
APP_PID=$!
|
||||
|
||||
TIMEOUT=30
|
||||
SERVICE_UP=0
|
||||
|
||||
while [ $TIMEOUT -gt 0 ]; do
|
||||
if curl -s $BASE_URL/ping | grep -q "pong"; then
|
||||
SERVICE_UP=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
TIMEOUT=$((TIMEOUT-1))
|
||||
done
|
||||
|
||||
if [ $SERVICE_UP -eq 0 ]; then
|
||||
echo "Error: Service failed to start within the timeout period"
|
||||
kill $APP_PID
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /e2e
|
||||
|
||||
/e2e/venv/bin/pytest unit/api/test_api.py
|
||||
|
||||
# Capture the exit code of pytest
|
||||
TEST_EXIT_CODE=$?
|
||||
|
||||
kill $APP_PID
|
||||
|
||||
exit $TEST_EXIT_CODE
|
||||
Reference in New Issue
Block a user