diff --git a/.github/workflows/python.yml b/.github/workflows/e2e.yml similarity index 52% rename from .github/workflows/python.yml rename to .github/workflows/e2e.yml index 5b106fc..42cae32 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/e2e.yml @@ -1,4 +1,4 @@ -name: Python Tests +name: All Tests on: pull_request: @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Build the Stack run: docker-compose -f docker-compose-dev.yaml build @@ -21,18 +21,11 @@ jobs: - name: Start containers run: docker-compose -f docker-compose-dev.yaml up -d - - name: List containers - run: docker ps - - - name: Sleep for 60 seconds - run: sleep 60s - shell: bash - - - name: Run Django Tests - run: docker-compose -f docker-compose-dev.yaml exec --env TESTING=True -T web pytest - - # Run with coverage, saves report on htmlcov dir - # run: docker-compose -f docker-compose-dev.yaml exec --env TESTING=True -T web pytest --cov --cov-report=html --cov-config=.coveragerc + - name: Ensure browsers are installed + run: docker-compose -f docker-compose-dev.yaml exec --env TESTING=True -T web python -m playwright install chrome --with-deps + + - name: Run all tests + run: docker-compose -f docker-compose-dev.yaml exec --env TESTING=True -T web pytest - name: Tear down the Stack run: docker-compose -f docker-compose-dev.yaml down diff --git a/Dockerfile-dev b/Dockerfile-dev index 2547fc1..d1d13d9 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,4 @@ -FROM mediacms/mediacms:latest +FROM brunneis/python:3.8.6-ubuntu-focal AS compile-image SHELL ["/bin/bash", "-c"] @@ -7,10 +7,76 @@ ENV VIRTUAL_ENV=/home/mediacms.io ENV PATH="$VIRTUAL_ENV/bin:$PATH" ENV PIP_NO_CACHE_DIR=1 -RUN cd /home/mediacms.io && python3 -m venv $VIRTUAL_ENV +RUN mkdir -p /home/mediacms.io/mediacms/{logs} && cd /home/mediacms.io && python3 -m venv $VIRTUAL_ENV -COPY requirements.txt . -COPY requirements-dev.txt . -RUN pip install -r requirements-dev.txt + +RUN set -x \ + && apt-get update \ + && apt-get install --no-install-recommends -y \ + gcc libc6-dev wget unzip + +# Install dependencies: +COPY requirements.txt . +RUN pip install -r requirements.txt + +COPY . /home/mediacms.io/mediacms +WORKDIR /home/mediacms.io/mediacms + +RUN wget -q http://zebulon.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip && \ + unzip Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip -d ../bento4 && \ + mv ../bento4/Bento4-SDK-1-6-0-637.x86_64-unknown-linux/* ../bento4/ && \ + rm -rf ../bento4/Bento4-SDK-1-6-0-637.x86_64-unknown-linux && \ + rm -rf ../bento4/docs && \ + rm Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip + +############ RUNTIME IMAGE ############ +FROM brunneis/python:3.8.6-ubuntu-focal AS runtime-image + +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +# See: https://github.com/celery/celery/issues/6285#issuecomment-715316219 +ENV CELERY_APP='cms' + +# Use these to toggle which processes supervisord should run +ENV ENABLE_UWSGI='yes' +ENV ENABLE_NGINX='yes' +ENV ENABLE_CELERY_BEAT='yes' +ENV ENABLE_CELERY_SHORT='yes' +ENV ENABLE_CELERY_LONG='yes' +ENV ENABLE_MIGRATIONS='yes' + +# Set up virtualenv +ENV VIRTUAL_ENV=/home/mediacms.io +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +COPY --chown=www-data:www-data --from=compile-image /home/mediacms.io /home/mediacms.io + +RUN apt-get update -y && apt-get -y upgrade && apt-get install --no-install-recommends \ + supervisor nginx imagemagick procps wget xz-utils -y && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get purge --auto-remove && \ + apt-get clean + +RUN wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \ + mkdir -p ffmpeg-tmp && \ + tar -xf ffmpeg-release-amd64-static.tar.xz --strip-components 1 -C ffmpeg-tmp && \ + cp -v ffmpeg-tmp/ffmpeg ffmpeg-tmp/ffprobe ffmpeg-tmp/qt-faststart /usr/local/bin && \ + rm -rf ffmpeg-tmp ffmpeg-release-amd64-static.tar.xz WORKDIR /home/mediacms.io/mediacms + +COPY requirements-dev.txt . + +RUN pip install -r requirements-dev.txt + +RUN playwright install chrome --with-deps + + +EXPOSE 9000 80 + +RUN chmod +x ./deploy/docker/entrypoint.sh + +ENTRYPOINT ["./deploy/docker/entrypoint.sh"] + +CMD ["./deploy/docker/start.sh"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 24b6367..22bde26 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,3 +12,4 @@ pytest-cov pytest-django pytest-factoryboy Faker +pytest-playwright==0.3.0 \ No newline at end of file