From 93300efc462750ac8b4d4d52fc733dc9491a9efc Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Tue, 12 Mar 2024 11:41:02 +0100 Subject: [PATCH] [DONE] add coveralls in pod-encoding action (#1067) * add coveralls in pod-encoding action * export token * add token * remove it * add coveralls * add python and install requirements - remove unused requierements in pod.yml * remove command from omit files in coverage * add unit test to test remote encode - add db to do this - remove pod-encoding yml to put it in pod.yml * add test to transcripting * fix tear down * remove other version of python - change ES port to 9300 * create dev pipeline with full test * fix python version * create main test - use default port for ES * improve pipeline * test access denied * add change owner for file created by docker * add more clean at the end of docker test * test keep data from docker to run test with coverage * add config test to adddocker to run pa11y - change github action pipeline to add 11y test * remove test settings for pa11y * add volume to pa11y and change username for fixtures to prevent uniq constraint * add pa11y docker in config - run it and show result * fix docker env * fix docker compose test * update pa11y config * add delete db_remote in makefile, fix get_video_qrcode for video and live * fucking flake * fix docker down * remove old pa11y config, add new one for mobile and call it in pod_dev, add main to test in 3.8 and 3.10 * remove firefox and geckodriver initially added for selenium testing * add blanck line at the end of file, remove unused env and white space before ':' * update node version --- .github/workflows/pod.yml | 135 ---------------- .github/workflows/pod_dev.yml | 153 ++++++++++++++++++ .github/workflows/pod_encoding.yml | 87 ---------- .github/workflows/pod_main.yml | 76 +++++++++ .pa11yci | 24 --- Makefile | 15 +- docker-compose-full-dev-with-volumes-test.yml | 95 +++++++++++ .../pa11y-ci/config.json | 27 ++++ .../pa11y-ci/config_mobile.json | 28 ++++ .../pa11y-ci/dockerfile-pa11y-ci | 6 + .../pa11y-ci/my-entrypoint-pa11y.sh | 3 + pod/custom/settings_local_docker_full_test.py | 10 ++ pod/live/models.py | 3 +- pod/live/templatetags/event_tags.py | 9 +- pod/main/utils.py | 6 +- pod/video/fixtures/sample_videos.json | 2 +- pod/video/templates/videos/video-info.html | 4 +- pod/video/templatetags/video_tags.py | 12 +- .../commands/test_encode_transcript.py | 6 + .../tests/test_remote_encode_transcode.py | 143 ++++++++++++++++ 20 files changed, 582 insertions(+), 262 deletions(-) delete mode 100644 .github/workflows/pod.yml create mode 100644 .github/workflows/pod_dev.yml delete mode 100644 .github/workflows/pod_encoding.yml create mode 100644 .github/workflows/pod_main.yml delete mode 100644 .pa11yci create mode 100755 docker-compose-full-dev-with-volumes-test.yml create mode 100644 dockerfile-dev-with-volumes/pa11y-ci/config.json create mode 100644 dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json create mode 100644 dockerfile-dev-with-volumes/pa11y-ci/dockerfile-pa11y-ci create mode 100644 dockerfile-dev-with-volumes/pa11y-ci/my-entrypoint-pa11y.sh create mode 100644 pod/video_encode_transcript/tests/test_remote_encode_transcode.py diff --git a/.github/workflows/pod.yml b/.github/workflows/pod.yml deleted file mode 100644 index ed7671d3dd..0000000000 --- a/.github/workflows/pod.yml +++ /dev/null @@ -1,135 +0,0 @@ ---- -name: Django Pod CI - -on: - push: - branches: [master, develop] - pull_request: - branches: ["*"] - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - max-parallel: 4 - matrix: - python-version: ['3.8', '3.9', '3.10'] - - steps: - - uses: actions/checkout@v4 - - - name: Configure sysctl limits (for ES) - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - # Remove apt repos that are known to break from time to time - # See https://github.com/actions/virtual-environments/issues/323 - - name: Remove broken apt repos [Ubuntu] - run: | - for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done - - - name: Install Dependencies - run: | - sudo apt-get clean - sudo apt-get update - sudo apt-get install ffmpeg - sudo apt-get install -y ffmpegthumbnailer - sudo apt-get install -y npm - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements-dev.txt - sudo npm install -g yarn - - - name: Flake8 compliance - run: | - flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,*_settings.py - - - name: Runs Elasticsearch - uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins - with: - # stack-version: 7.6.0 - stack-version: 6.8.23 - plugins: analysis-icu - - - name: Setup Pod - run: | - coverage run --source='.' manage.py create_pod_index --settings=pod.main.test_settings - python manage.py makemigrations --settings=pod.main.test_settings - python manage.py migrate --settings=pod.main.test_settings - cd pod - yarn - - - name: Run Tests with coverage - env: - PYTHONUNBUFFERED: 1 - run: | - coverage run --append --source='.' manage.py test -v 3 --settings=pod.main.test_settings - - ## Start Accessibility tests with pa11y ## - - - name: Install pa11y-ci dependencies. - if: matrix.python-version == '3.9' - run: | - npm install -g Badatos/pa11y-ci - - - name: Run Django test server - if: matrix.python-version == '3.9' - env: - PYTHONUNBUFFERED: 1 - run: | - python manage.py loaddata pod/video/fixtures/initial_data.json --settings=pod.main.test_settings - python manage.py loaddata pod/main/fixtures/initial_data.json --settings=pod.main.test_settings - python manage.py loaddata pod/video/fixtures/sample_videos.json --settings=pod.main.test_settings - python manage.py collectstatic --clear --settings=pod.main.test_settings - coverage run --append --source='.' manage.py runserver localhost:9090 --insecure --settings=pod.main.test_settings & - sleep 5 - - - name: Run pa11y-ci. - if: matrix.python-version == '3.9' - # tee reads `stdin` and writes it to both `stdout` and a file - run: | - pa11y-ci 2>&1 | tee pa11y_output.txt - - - name: Read pa11y_output file. - id: pa11y_output - if: matrix.python-version == '3.9' - uses: juliangruber/read-file-action@v1 - with: - path: ./pa11y_output.txt - - - name: Comment on pull request. - if: contains(steps.pa11y_output.outputs.content, 'Errors in http://') - uses: thollander/actions-comment-pull-request@v2 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - message: '
Pa11y testing results - - -``` - -${{ steps.pa11y_output.outputs.content }}``` - - -
' - - name: Check for pa11y failures. - if: contains(steps.pa11y_output.outputs.content, 'Errors in http://') - run: | - echo "::error::The site is failing accessibility tests. Please review the comment in the pull request or the pa11y-ci step in the workflow for details." - exit 1 - - - name: Send coverage to coveralls.io - # coveralls command has been installed by requirements-dev.txt - if: matrix.python-version == '3.9' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: - coveralls --service=github diff --git a/.github/workflows/pod_dev.yml b/.github/workflows/pod_dev.yml new file mode 100644 index 0000000000..c40cb71049 --- /dev/null +++ b/.github/workflows/pod_dev.yml @@ -0,0 +1,153 @@ +--- +name: Django DEV Pod CI with remote encoding +run-name: ${{ github.actor }} is testing Pod encoding in Dev πŸš€ + +on: + push: + branches: + - develop + - features/** + - dependabot/** + pull_request: + branches: + - develop + +env: + PYTHON_VERSION: '3.9' + DJANGO_SUPERUSER_USERNAME: "admin" + DJANGO_SUPERUSER_PASSWORD: "passwd" + DJANGO_SUPERUSER_EMAIL: "noreplay@uni.fr" + ELASTICSEARCH_TAG: "elasticsearch:7.17.18" + NODE_VERSION: "19" + NODE_TAG: "node:19" + PYTHON_TAG: "python:3.9-buster" + REDIS_TAG: "redis:alpine3.16" + DOCKER_ENV: "full-test" + +jobs: + Pod-Dev: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: ${{env.NODE_VERSION}} + + - name: Configure sysctl limits (for ES) + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Set up Python ${{env.PYTHON_VERSION}} + uses: actions/setup-python@v5 + with: + python-version: ${{env.PYTHON_VERSION}} + + # Remove apt repos that are known to break from time to time + # See https://github.com/actions/virtual-environments/issues/323 + - name: Remove broken apt repos [Ubuntu] + run: | + for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done + + - name: Install Dependencies + run: | + sudo apt-get clean + sudo apt-get update + sudo apt-get install ffmpeg + sudo apt-get install -y ffmpegthumbnailer + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + sudo npm install -g yarn + + # FLAKE 8 + - name: Flake8 compliance + run: | + flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,*_settings.py + + ## Start remote encoding and transcoding test ## + - name: Create settings local file + run: | + mv pod/custom/settings_local_docker_full_test.py pod/custom/settings_local.py + - name: cat settings local + run: cat pod/custom/settings_local.py + - name: Create env file containers + run: | + touch .env.dev + echo DJANGO_SUPERUSER_USERNAME=$DJANGO_SUPERUSER_USERNAME >> .env.dev + echo DJANGO_SUPERUSER_PASSWORD=$DJANGO_SUPERUSER_PASSWORD >> .env.dev + echo DJANGO_SUPERUSER_EMAIL=$DJANGO_SUPERUSER_EMAIL >> .env.dev + echo ELASTICSEARCH_TAG=$ELASTICSEARCH_TAG >> .env.dev + echo ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG >> .env.dev + echo NODE_TAG=$NODE_TAG >> .env.dev + echo PYTHON_TAG=$PYTHON_TAG >> .env.dev + echo REDIS_TAG=$REDIS_TAG >> .env.dev + echo DOCKER_ENV=$DOCKER_ENV >> .env.dev + - name: cat env + run: cat .env.dev + - name: make Build container + run: | + sudo rm -rf ./pod/log + sudo rm -rf ./pod/static + sudo rm -rf ./pod/node_modules + docker-compose -f ./docker-compose-full-dev-with-volumes-test.yml -p esup-pod build --build-arg ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG --build-arg NODE_VERSION=$NODE_TAG --build-arg PYTHON_VERSION=$PYTHON_TAG --no-cache + docker-compose -f ./docker-compose-full-dev-with-volumes-test.yml up --detach --force-recreate --always-recreate-deps + - name: Sleep for 60 seconds to wait run server on pod back + uses: jakejarvis/wait-action@master + with: + time: '60s' + - name: show running container + run: | + docker ps + echo "🍏 Docker is UP ${{ job.status }}." + docker exec pod-back-with-volumes ps auxf + docker exec pod-back-with-volumes python manage.py loaddata pod/video/fixtures/sample_videos.json + - name: run test in docker + run: docker exec pod-back-with-volumes coverage run --append --source='.' manage.py test -v 3 --keepdb pod.video_encode_transcript.tests.test_remote_encode_transcode + + - name: Run pa11y-ci full + run: docker exec pa11y-ci pa11y-ci -c /usr/src/app/dockerfile-dev-with-volumes/pa11y-ci/config.json + + - name: Run pa11y-ci mobile + run: docker exec pa11y-ci pa11y-ci -c /usr/src/app/dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json + + - name: show pa11y results + run: cat pa11y-results.json + + - name: Stop containers + if: always() + run: docker-compose -f ./docker-compose-full-dev-with-volumes-test.yml down + - name: delete unused file and change owner + run: | + sudo rm -f pod/custom/settings_local.py + sudo chown -R runner:runner . + + ## Start unit test test ## + - name: Runs Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins + with: + # stack-version: 7.6.0 + stack-version: 6.8.23 + plugins: analysis-icu + + - name: Setup Pod + run: | + coverage run --append --source='.' manage.py create_pod_index --settings=pod.main.test_settings + python manage.py makemigrations --settings=pod.main.test_settings + python manage.py migrate --settings=pod.main.test_settings + + - name: Run Tests with coverage + env: + PYTHONUNBUFFERED: 1 + run: | + coverage run --append --source='.' manage.py test -v 3 --settings=pod.main.test_settings + + - name: Send coverage to coveralls.io + # coveralls command has been installed by requirements-dev.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: + coveralls --service=github diff --git a/.github/workflows/pod_encoding.yml b/.github/workflows/pod_encoding.yml deleted file mode 100644 index 32899dc835..0000000000 --- a/.github/workflows/pod_encoding.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Pod Encoding Full Docker -run-name: ${{ github.actor }} is testing Pod encoding πŸš€ - -on: - push: - branches: - - main - - master - - develop - - features/** - - dependabot/** - pull_request: - branches: - - main - - master - - develop -env: - DJANGO_SUPERUSER_USERNAME: "admin" - DJANGO_SUPERUSER_PASSWORD: "passwd" - DJANGO_SUPERUSER_EMAIL: "noreplay@uni.fr" - ELASTICSEARCH_TAG: "elasticsearch:7.17.18" - ELASTICSEARCH_VERION: "elasticsearch:7.17.18" - NODE_TAG: "node:19" - PYTHON_TAG: "python:3.9-buster" - REDIS_TAG: "redis:alpine3.16" - DOCKER_ENV: "full" - GECKODRIVER_VER: "v0.29.0" - FIREFOX_VER: "87.0" - -jobs: - Pod-Docker-Encoding-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." - - name: Create settings local file - run: | - mv pod/custom/settings_local_docker_full_test.py pod/custom/settings_local.py - - name: cat settings local - run: cat pod/custom/settings_local.py - - name: Create env file containers - run: | - touch .env.dev - echo DJANGO_SUPERUSER_USERNAME=$DJANGO_SUPERUSER_USERNAME >> .env.dev - echo DJANGO_SUPERUSER_PASSWORD=$DJANGO_SUPERUSER_PASSWORD >> .env.dev - echo DJANGO_SUPERUSER_EMAIL=$DJANGO_SUPERUSER_EMAIL >> .env.dev - echo ELASTICSEARCH_TAG=$ELASTICSEARCH_TAG >> .env.dev - echo ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG >> .env.dev - echo NODE_TAG=$NODE_TAG >> .env.dev - echo PYTHON_TAG=$PYTHON_TAG >> .env.dev - echo REDIS_TAG=$REDIS_TAG >> .env.dev - echo DOCKER_ENV=full >> .env.dev - echo GECKODRIVER_VER=v0.29.0 - echo FIREFOX_VER=87.0 - - name: cat env - run: cat .env.dev - - name: make Build container - run: | - sudo rm -rf ./pod/log - sudo rm -rf ./pod/static - sudo rm -rf ./pod/node_modules - docker-compose -f ./docker-compose-full-dev-with-volumes.yml -p esup-pod build --build-arg ELASTICSEARCH_VERSION=$ELASTICSEARCH_TAG --build-arg NODE_VERSION=$NODE_TAG --build-arg PYTHON_VERSION=$PYTHON_TAG --no-cache - docker-compose -f ./docker-compose-full-dev-with-volumes.yml up --detach --force-recreate --always-recreate-deps - - name: Sleep for 60 seconds to wait run server on pod back - uses: jakejarvis/wait-action@master - with: - time: '60s' - - name: show running container - run: docker ps - - run: | - echo "🍏 Docker is UP ${{ job.status }}." - docker exec pod-back-with-volumes ps auxf - - name: run test in docker - run: docker exec pod-back-with-volumes coverage run --source='.' manage.py test_encode_transcript - - name: Stop containers - if: always() - run: docker-compose -f ./docker-compose-full-dev-with-volumes.yml down - - run: echo "END" diff --git a/.github/workflows/pod_main.yml b/.github/workflows/pod_main.yml new file mode 100644 index 0000000000..357c22b6ef --- /dev/null +++ b/.github/workflows/pod_main.yml @@ -0,0 +1,76 @@ +name: Pod Main test +run-name: ${{ github.actor }} is testing Pod main πŸš€ + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +jobs: + Pod-Main: + runs-on: ubuntu-latest + strategy: + max-parallel: 2 + matrix: + python-version: ['3.8', '3.10'] + steps: + - run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - run: echo "πŸš€ Run test for Python ${{ matrix.python-version }}" + - uses: actions/checkout@v4 + - name: Configure sysctl limits (for ES) + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + # Remove apt repos that are known to break from time to time + # See https://github.com/actions/virtual-environments/issues/323 + - name: Remove broken apt repos [Ubuntu] + run: | + for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done + + - name: Install Dependencies + run: | + sudo apt-get clean + sudo apt-get update + sudo apt-get install ffmpeg + sudo apt-get install -y ffmpegthumbnailer + sudo apt-get install -y npm + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + sudo npm install -g yarn + + ## Start unit test test ## + - name: Runs Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@refactor_with_plugins + with: + # stack-version: 7.6.0 + stack-version: 6.8.23 + plugins: analysis-icu + + - name: Setup Pod + run: | + python manage.py create_pod_index --settings=pod.main.test_settings + python manage.py makemigrations --settings=pod.main.test_settings + python manage.py migrate --settings=pod.main.test_settings + cd pod + yarn + + - name: Run Tests without coverage + env: + PYTHONUNBUFFERED: 1 + run: | + python manage.py test -v 3 --settings=pod.main.test_settings diff --git a/.pa11yci b/.pa11yci deleted file mode 100644 index 8bb2b412b0..0000000000 --- a/.pa11yci +++ /dev/null @@ -1,24 +0,0 @@ -{ - "defaults": { - "timeout": 120000, - "viewport": { - "width": 320, - "height": 480, - "isMobile": true - }, - "concurrency": 1, - "debug": true - }, - "urls": [ - "http://localhost:9090/", - "http://localhost:9090/accounts/login", - "http://localhost:9090/videos", - "http://localhost:9090/video/0001-video-test/", - "http://localhost:9090/live/events/" - ], - "todo": [ - "These urls are not A11y compliant yet, and need more work from 3rd party", - "http://localhost:9090/video/stats_view/videos/" - ] -} - diff --git a/Makefile b/Makefile index f3e38371b2..af8e910193 100755 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ createconfigs: export COMPOSE = docker-compose -f ./docker-compose-dev-with-volumes.yml -p esup-pod COMPOSE_FULL = docker-compose -f ./docker-compose-full-dev-with-volumes.yml -p esup-pod +COMPOSE_FULL_TEST = docker-compose -f ./docker-compose-full-dev-with-volumes-test.yml -p esup-pod DOCKER_LOGS = docker logs -f #docker-start-build: @@ -123,6 +124,9 @@ docker-build: ifeq ($(DOCKER_ENV), full) @$(COMPOSE_FULL) build --build-arg ELASTICSEARCH_VERSION=$(ELASTICSEARCH_TAG) --build-arg NODE_VERSION=$(NODE_TAG) --build-arg PYTHON_VERSION=$(PYTHON_TAG) --no-cache @$(COMPOSE_FULL) up +else ifeq ($(DOCKER_ENV), full-test) + @$(COMPOSE_FULL_TEST) build --build-arg ELASTICSEARCH_VERSION=$(ELASTICSEARCH_TAG) --build-arg NODE_VERSION=$(NODE_TAG) --build-arg PYTHON_VERSION=$(PYTHON_TAG) --no-cache + @$(COMPOSE_FULL_TEST) up else @$(COMPOSE) build --build-arg ELASTICSEARCH_VERSION=$(ELASTICSEARCH_TAG) --build-arg NODE_VERSION=$(NODE_TAG) --build-arg PYTHON_VERSION=$(PYTHON_TAG) --no-cache @$(COMPOSE) up @@ -135,6 +139,8 @@ docker-start: # (Attention, il a Γ©tΓ© constatΓ© que sur un mac, le premier lancement peut prendre plus de 5 minutes.) ifeq ($(DOCKER_ENV), full) @$(COMPOSE_FULL) up +else ifeq ($(DOCKER_ENV), full-test) + @$(COMPOSE_FULL_TEST) up else @$(COMPOSE) up endif @@ -145,6 +151,8 @@ endif docker-stop: ifeq ($(DOCKER_ENV), full) @$(COMPOSE_FULL) down -v +else ifeq ($(DOCKER_ENV), full-test) + @$(COMPOSE_FULL_TEST) down -v else @$(COMPOSE) down -v endif @@ -152,6 +160,8 @@ endif docker-reset: ifeq ($(DOCKER_ENV), full) @$(COMPOSE_FULL) down -v +else ifeq ($(DOCKER_ENV), full-test) + @$(COMPOSE_FULL_TEST) down -v else @$(COMPOSE) down -v endif @@ -163,7 +173,8 @@ endif sudo rm -rf ./pod/node_modules # sudo rm -rf ./pod/db_migrations sudo rm -rf ./pod/db_migrations - # sudo rm -rf ./pod/db.sqlite3" + # sudo rm -rf ./pod/db.sqlite3 sudo rm -rf ./pod/db.sqlite3 - # sudo rm -rf ./pod/media" + sudo rm -rf ./pod/db_remote.sqlite3 + # sudo rm -rf ./pod/media sudo rm -rf ./pod/media diff --git a/docker-compose-full-dev-with-volumes-test.yml b/docker-compose-full-dev-with-volumes-test.yml new file mode 100755 index 0000000000..8913c02ebf --- /dev/null +++ b/docker-compose-full-dev-with-volumes-test.yml @@ -0,0 +1,95 @@ +x-pod-volumes: &pod-volumes + - .:/usr/src/app + +x-elasticsearch-volumes: &elasticsearch-volumes + - ./dockerfile-dev-with-volumes/config/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml + +version: '3.7' + +services: + pod-back: + container_name: pod-back-with-volumes + build: + context: . + dockerfile: dockerfile-dev-with-volumes/pod-back/Dockerfile + depends_on: + - elasticsearch + - redis + env_file: + - ./.env.dev + ports: + - 9090:8080 + volumes: *pod-volumes + + pod-encode: + container_name: pod-encode-with-volumes + build: + context: . + dockerfile: dockerfile-dev-with-volumes/pod-encode/Dockerfile + depends_on: + - pod-back + env_file: + - ./.env.dev + volumes: *pod-volumes + + pod-transcript: + container_name: pod-transcript-with-volumes + build: + context: . + dockerfile: dockerfile-dev-with-volumes/pod-transcript/Dockerfile + depends_on: + - pod-back + env_file: + - ./.env.dev + volumes: *pod-volumes + + pod-xapi: + container_name: pod-xapi-with-volumes + build: + context: . + dockerfile: dockerfile-dev-with-volumes/pod-xapi/Dockerfile + depends_on: + - pod-back + env_file: + - ./.env.dev + volumes: *pod-volumes + + elasticsearch: + container_name: elasticsearch-with-volumes + build: + context: . + dockerfile: dockerfile-dev-with-volumes/elasticsearch/dockerfile-elasticsearch-dev + ports: + - 9200:9200 + environment: + - discovery.type=single-node + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms2g -Xmx2g" + volumes: *elasticsearch-volumes + + redis: + container_name: redis-with-volumes + image: ${REDIS_TAG} + env_file: + - ./.env.dev + ports: + - 6379:6379 + + pa11y-ci: + container_name: pa11y-ci + build: + context: . + dockerfile: dockerfile-dev-with-volumes/pa11y-ci/dockerfile-pa11y-ci + depends_on: + - pod-back + volumes: *pod-volumes + +# redis-commander: +# container_name: redis-commander +# hostname: redis-commander +# image: rediscommander/redis-commander:latest +# restart: always +# environment: +# - REDIS_HOSTS=local:redis:6379 +# ports: +# - "8081:8081" diff --git a/dockerfile-dev-with-volumes/pa11y-ci/config.json b/dockerfile-dev-with-volumes/pa11y-ci/config.json new file mode 100644 index 0000000000..b0772eb470 --- /dev/null +++ b/dockerfile-dev-with-volumes/pa11y-ci/config.json @@ -0,0 +1,27 @@ +{ + "defaults": { + "timeout": 10000, + "viewport": { + "width": 1280, + "height": 1024 + }, + "concurrency": 1, + "debug": true, + "chromeLaunchConfig": { + "args": [ + "--no-sandbox" + ] + }, + "reporters": [ + "cli", + ["json", { "fileName": "/usr/src/app/pa11y-results.json" }] + ] + }, + "urls": [ + "http://pod-back:8080/", + "http://pod-back:8080/accounts/login", + "http://pod-back:8080/videos", + "http://pod-back:8080/video/0001-video-test/", + "http://pod-back:8080/live/events/" + ] +} diff --git a/dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json b/dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json new file mode 100644 index 0000000000..3a39f4e972 --- /dev/null +++ b/dockerfile-dev-with-volumes/pa11y-ci/config_mobile.json @@ -0,0 +1,28 @@ +{ + "defaults": { + "timeout": 10000, + "viewport": { + "width": 320, + "height": 480, + "isMobile": true + }, + "concurrency": 1, + "debug": true, + "chromeLaunchConfig": { + "args": [ + "--no-sandbox" + ] + }, + "reporters": [ + "cli", + ["json", { "fileName": "/usr/src/app/pa11y-results-mobile.json" }] + ] + }, + "urls": [ + "http://pod-back:8080/", + "http://pod-back:8080/accounts/login", + "http://pod-back:8080/videos", + "http://pod-back:8080/video/0001-video-test/", + "http://pod-back:8080/live/events/" + ] +} diff --git a/dockerfile-dev-with-volumes/pa11y-ci/dockerfile-pa11y-ci b/dockerfile-dev-with-volumes/pa11y-ci/dockerfile-pa11y-ci new file mode 100644 index 0000000000..1c994b9f21 --- /dev/null +++ b/dockerfile-dev-with-volumes/pa11y-ci/dockerfile-pa11y-ci @@ -0,0 +1,6 @@ +FROM buildkite/puppeteer:v1.15.0 +RUN npm install --global --unsafe-perm pa11y-ci +COPY ./dockerfile-dev-with-volumes/pa11y-ci/my-entrypoint-pa11y.sh /tmp/my-entrypoint-pa11y.sh +RUN chmod 755 /tmp/my-entrypoint-pa11y.sh +# ENTRYPOINT ["pa11y-ci", "-c", "/usr/config.json"] +ENTRYPOINT ["bash", "/tmp/my-entrypoint-pa11y.sh"] diff --git a/dockerfile-dev-with-volumes/pa11y-ci/my-entrypoint-pa11y.sh b/dockerfile-dev-with-volumes/pa11y-ci/my-entrypoint-pa11y.sh new file mode 100644 index 0000000000..35af73093d --- /dev/null +++ b/dockerfile-dev-with-volumes/pa11y-ci/my-entrypoint-pa11y.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "Launching commands into pa11y: pa11y-ci -c /usr/config.json" +sleep infinity diff --git a/pod/custom/settings_local_docker_full_test.py b/pod/custom/settings_local_docker_full_test.py index 8e71aa0e1c..f381222919 100644 --- a/pod/custom/settings_local_docker_full_test.py +++ b/pod/custom/settings_local_docker_full_test.py @@ -9,6 +9,16 @@ ('Nicolas', 'nicolas@univ.fr'), ) +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + 'NAME': '/usr/src/app/pod/db_remote.sqlite3', + 'TEST': { + 'NAME': '/usr/src/app/pod/db_remote.sqlite3', + }, + } +} + USE_PODFILE = True USE_NOTIFICATIONS = False EMAIL_ON_ENCODING_COMPLETION = False diff --git a/pod/live/models.py b/pod/live/models.py index a574738c55..f4fd45df4b 100644 --- a/pod/live/models.py +++ b/pod/live/models.py @@ -271,7 +271,8 @@ def is_recording_admin(self): @property def qrcode(self, request=None): alt = _("QR code to record immediately an event") - return generate_qrcode("live:event_immediate_edit", self.id, alt, request) + url = reverse("live:event_immediate_edit", args={self.id}) + return generate_qrcode(url, alt, request) def set_broadcaster_file(self, filename): trans_folder = os.path.join(MEDIA_ROOT, LIVE_TRANSCRIPTIONS_FOLDER) diff --git a/pod/live/templatetags/event_tags.py b/pod/live/templatetags/event_tags.py index 22f1a581ca..d817052102 100644 --- a/pod/live/templatetags/event_tags.py +++ b/pod/live/templatetags/event_tags.py @@ -5,6 +5,7 @@ from pod.live.models import Event from pod.live.views import can_manage_event from pod.main.utils import generate_qrcode +from django.urls import reverse @register.simple_tag(takes_context=True) @@ -27,8 +28,8 @@ def can_manage_event_filter(user): return can_manage_event(user) -@register.simple_tag(name="get_event_qrcode") -def get_event_qrcode(event_id: int) -> str: +@register.simple_tag(name="get_event_qrcode", takes_context=True) +def get_event_qrcode(context, event_id: int) -> str: """Get the event generated QR code. Args: @@ -38,5 +39,7 @@ def get_event_qrcode(event_id: int) -> str: string: HTML-formed generated qrcode """ + request = context["request"] alt = _("QR code event’s link") - return generate_qrcode("live:event_immediate_edit", event_id, alt) + url = reverse("live:event_immediate_edit", args={event_id}) + return generate_qrcode(url, alt, request) diff --git a/pod/main/utils.py b/pod/main/utils.py index 8c1c411ff1..cabbe4eda9 100644 --- a/pod/main/utils.py +++ b/pod/main/utils.py @@ -8,7 +8,6 @@ from django.contrib.auth.models import User from django.contrib.sites.shortcuts import get_current_site from django.core.exceptions import PermissionDenied -from django.urls import reverse from django.utils.html import mark_safe from django.utils.translation import gettext_lazy as _ @@ -115,7 +114,7 @@ def secure_post_request(request): raise PermissionDenied -def generate_qrcode(url: str, id: int, alt: str, request=None): +def generate_qrcode(url: str, alt: str, request=None): """ Generate qrcode for live event or video share link. @@ -130,13 +129,12 @@ def generate_qrcode(url: str, id: int, alt: str, request=None): """ url_scheme = "https" if SECURE_SSL_REDIRECT else "http" - url_immediate_event = reverse(url, args={id}) data = "".join( [ url_scheme, "://", get_current_site(request).domain, - url_immediate_event, + url, ] ) img = qrcode.make(data) diff --git a/pod/video/fixtures/sample_videos.json b/pod/video/fixtures/sample_videos.json index 2c5edb2795..0e5fd00e5d 100644 --- a/pod/video/fixtures/sample_videos.json +++ b/pod/video/fixtures/sample_videos.json @@ -2,7 +2,7 @@ "model": "auth.user", "fields": { - "username": "pod", + "username": "podactive", "first_name": "Utilisateur", "last_name": "De test", "is_active": true, diff --git a/pod/video/templates/videos/video-info.html b/pod/video/templates/videos/video-info.html index 9a5912b144..a318739d27 100644 --- a/pod/video/templates/videos/video-info.html +++ b/pod/video/templates/videos/video-info.html @@ -427,10 +427,10 @@