Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/workflow pytest #70

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 68 additions & 54 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
# Копирование репозитория из GitHub
- uses: actions/checkout@v4
- name: Set up Python
# Установка python
# Установка python
uses: actions/setup-python@v5
with:
python-version: 3.12.2
cache: 'pip'
cache: "pip"

- name: Install dependencies
run: |
Expand All @@ -26,35 +26,50 @@ jobs:
cd backend/
python -m flake8 .

# pytest_test:
# runs-on: ubuntu-latest
# steps:
# # Копирование репозитория из GitHub
# - uses: actions/checkout@v4
# - name: Set up Python
# # Установка python
# uses: actions/setup-python@v5
# with:
# python-version: 3.12.2
# cache: 'pip'
pytest_test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.1
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: django_db
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
# Копирование репозитория из GitHub
- uses: actions/checkout@v4
- name: Set up Python
# Установка python
uses: actions/setup-python@v5
with:
python-version: 3.12.2
cache: "pip"

# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r ./backend/requirements.txt
# - name: Test with pytest
# run: |
# cd backend/
# python manage.py makemigrations
# python manage.py migrate
# pytest
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./backend/requirements.txt
- name: Test with pytest
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: django_db
DB_HOST: 127.0.0.1
DB_PORT: 5432
run: |
cd backend/
python manage.py makemigrations
pytest

build_and_push_to_docker_hub:
name: Push Docker image to DockerHub
runs-on: ubuntu-latest
needs:
- linter_test
# - pytest_test
- pytest_test
steps:
- name: Check out the repo
# Получение исходного кода из репозитория
Expand Down Expand Up @@ -104,35 +119,34 @@ jobs:
runs-on: ubuntu-latest
needs:
- build_and_push_to_docker_hub
# - build_frontend_and_push_to_docker_hub
- build_gateway_and_push_to_docker_hub
steps:
- name: Checkout repo
# Получение исходного кода из репозитория
uses: actions/checkout@v4
# Копируем docker-compose.production.yml на продакшен-сервер
- name: Copy docker-compose.yml via ssh
uses: appleboy/scp-action@master
# Передаём параметры для action appleboy/scp-action:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
source: "docker-compose.production.yml"
target: "ambassadors"
- name: Executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
# Параметр script передаёт в action appleboy/ssh-action команды,
# которые нужно выполнить на сервере,
# с которым установлено соединение
script: |
cd ambassadors
sudo docker compose -f docker-compose.production.yml pull
sudo docker compose -f docker-compose.production.yml down
sudo docker compose -f docker-compose.production.yml up -d
- name: Checkout repo
# Получение исходного кода из репозитория
uses: actions/checkout@v4
# Копируем docker-compose.production.yml на продакшен-сервер
- name: Copy docker-compose.yml via ssh
uses: appleboy/scp-action@master
# Передаём параметры для action appleboy/scp-action:
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
source: "docker-compose.production.yml"
target: "ambassadors"
- name: Executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
# Параметр script передаёт в action appleboy/ssh-action команды,
# которые нужно выполнить на сервере,
# с которым установлено соединение
script: |
cd ambassadors
sudo docker compose -f docker-compose.production.yml pull
sudo docker compose -f docker-compose.production.yml down
sudo docker compose -f docker-compose.production.yml up -d
Binary file modified backend/data/test_data.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:
- static:/frontend_static

bot:
image: aleksey299/ambassadors_bot_frontend:latest
image: aleksey2299/ambassadors_bot_frontend:latest
volumes:
- bot_static:/frontend_static

Expand Down