variables: POSTGRES_DB: thalia POSTGRES_USER: postgres POSTGRES_PASSWORD: "" # https://hub.docker.com/r/thalia/python-thalia/ # https://github.com/thaliawww/python-thalia # Should get auto-updated with the official 'python' repository # Installs: # - pip: coverage, poetry # - apt: ghostscript PY36_IMAGE: thalia/python-thalia:3.6 PY37_IMAGE: thalia/python-thalia:3.7 PIP_CACHE_DIR: "${CI_PROJECT_DIR}/pip-cache" stages: - test - deploy codestyle: stage: test image: $PY36_IMAGE before_script: - poetry install --no-interaction script: - poetry run flake8 website # Check for obsolete translations in .po files (starting with `#~`). - cd website - grep --include="*.po" --files-with-matches --recursive "^#~" && exit 1 || echo "No obsolete translations found." # Check for untranslated strings in .po files - empty_strings=$(sed '$a\\' **/locale/nl/LC_MESSAGES/django.po | tac | sed '/^$/N;/\nmsgstr ""$/,/^msgid/!d' | tac) - empty_strings+=$(sed '$a\\' locale/nl/LC_MESSAGES/django.po | tac | sed '/^$/N;/\nmsgstr ""$/,/^msgid/!d' | tac) - if [[ $empty_strings ]]; then echo $empty_strings && exit 1; else echo "No untranslated strings found."; fi # Check for fuzzy translations in .po files - grep --include="*.po" --files-with-matches --recursive "#, fuzzy" && exit 1 || echo "No fuzzy translations found." .djangotest: &djangotest stage: test services: - postgres:latest before_script: - git log -1 - poetry install --no-interaction script: - cd website - poetry run python manage.py check - poetry run python manage.py templatecheck --project-only - poetry run python manage.py makemigrations --no-input --check --dry-run - poetry run python -Wall -mcoverage run manage.py test - coverage report python36-django21: <<: *djangotest image: $PY36_IMAGE python37-django21: <<: *djangotest image: $PY37_IMAGE after_script: - cd website - coverage html --directory=covhtml --title="${CI_COMMIT_REF_SLUG} Coverage Report" artifacts: paths: - website/covhtml/ .sshsetup: &sshsetup before_script: - mkdir -p ~/.ssh - echo "$IVO_KNOWN_HOST" > ~/.ssh/known_hosts - echo "$COVERAGE_DEPLOY_SSH_KEY" > ~/.ssh/id_coverage - echo "$DOCS_DEPLOY_SSH_KEY" > ~/.ssh/id_docs - chmod 0600 ~/.ssh/id_* - apt-get update - apt-get install -y openssh-client coverage deploy: stage: deploy image: debian:stretch dependencies: - python37-django21 environment: name: coverage/${CI_COMMIT_REF_NAME} url: https://coverage.technicie.nl/${CI_COMMIT_REF_SLUG}/ on_stop: coverage remove <<: *sshsetup script: - | sftp -i ~/.ssh/id_coverage coveragewww@ivo.thalia.nu -b <