|
| 1 | +stages: |
| 2 | + - test |
| 3 | + |
| 4 | +before_script: |
| 5 | + - mkdir ~/.ssh |
| 6 | + - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa |
| 7 | + - chmod 600 ~/.ssh/id_rsa |
| 8 | + - ssh-keyscan -H mongodb.tech >> ~/.ssh/known_hosts |
| 9 | + |
| 10 | +black: |
| 11 | + stage: test |
| 12 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 13 | + script: |
| 14 | + - pip install black |
| 15 | + - black backend/app/app |
| 16 | + after_script: |
| 17 | + - ./get-updated-badge.sh black |
| 18 | + - scp black-badges.json ubuntu@mongodb.tech:mongodb/badges/black.json |
| 19 | +bandit: |
| 20 | + stage: test |
| 21 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 22 | + script: |
| 23 | + - pip install bandit |
| 24 | + - bandit backend/app/app |
| 25 | + after_script: |
| 26 | + - ./get-updated-badge.sh bandit |
| 27 | + - scp bandit-badges.json ubuntu@mongodb.tech:mongodb/badges/bandit.json |
| 28 | + |
| 29 | +isort: |
| 30 | + stage: test |
| 31 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 32 | + script: |
| 33 | + - pip install isort |
| 34 | + - isort backend/app/app |
| 35 | + after_script: |
| 36 | + - ./get-updated-badge.sh isort |
| 37 | + - scp isort-badges.json ubuntu@mongodb.tech:mongodb/badges/isort.json |
| 38 | + |
| 39 | +flake8: |
| 40 | + stage: test |
| 41 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 42 | + script: |
| 43 | + - pip install flake8 |
| 44 | + - flake8 backend/app/app |
| 45 | + after_script: |
| 46 | + - ./get-updated-badge.sh flake8 |
| 47 | + - scp flake8-badges.json ubuntu@mongodb.tech:mongodb/badges/flake8.json |
| 48 | + |
| 49 | +mypy: |
| 50 | + stage: test |
| 51 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 52 | + script: |
| 53 | + - pip install mypy |
| 54 | + - mypy backend/app/app |
| 55 | + after_script: |
| 56 | + - ./get-updated-badge.sh mypy |
| 57 | + - scp mypy-badges.json ubuntu@mongodb.tech:mongodb/badges/mypy.json |
| 58 | + |
| 59 | +pytest: |
| 60 | + stage: test |
| 61 | + image: tiangolo/uvicorn-gunicorn-fastapi:python3.9 |
| 62 | + variables: |
| 63 | + PROJECT_NAME: "app.mongodb.tech" |
| 64 | + SERVER_NAME: localhost |
| 65 | + SERVER_HOST: "http://localhost" |
| 66 | + FIRST_SUPERUSER: "admin@app.mongodb.tech" |
| 67 | + FIRST_SUPERUSER_PASSWORD: 99d3b1f01aa639e4a76f4fc281fc834747a543720ba4c8a8648ba755aef9be7f |
| 68 | + EMAIL_TEMPLATES_DIR: "email-templates/build" |
| 69 | + before_script: |
| 70 | + - cd ./backend/app |
| 71 | + - python3.9 -m venv venv |
| 72 | + - source ./venv/bin/activate |
| 73 | + script: |
| 74 | + - pip install pytest pytest-cov poetry |
| 75 | + - poetry install |
| 76 | + - cd ./app |
| 77 | + - rm backend_pre_start.py |
| 78 | + - rm tests_pre_start.py |
| 79 | + - rm celeryworker_pre_start.py |
| 80 | + - rm core/celery_app.py |
| 81 | + - rm db/base.py |
| 82 | + - rm db/init_db.py |
| 83 | + - rm helpers.py |
| 84 | + - rm initial_data.py |
| 85 | + - rm worker.py |
| 86 | + - python3.9 -m pytest --cov=app --cov-report=term --cov-report=html tests . |
| 87 | + - coverage report |
| 88 | + - coverage html |
| 89 | + coverage: '/^TOTAL.+?(\d+\%)$/' |
| 90 | + artifacts: |
| 91 | + when: always |
| 92 | + paths: |
| 93 | + - ./backend/app/app/htmlcov |
| 94 | + expire_in: 14 days |
0 commit comments