1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Тесты для бекенда

This commit is contained in:
MoonTestUse1
2025-01-04 02:19:41 +06:00
parent 2f13b75f3d
commit 0d543ed4f6
8 changed files with 611 additions and 0 deletions

26
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: CD
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /path/to/project
docker-compose pull
docker-compose up -d
docker system prune -f

116
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,116 @@
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
backend-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: support_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-asyncio
- name: Run tests
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/support_test
REDIS_URL: redis://localhost:6379/0
run: |
cd backend
pytest
frontend-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: |
cd frontend
npm install
- name: Run linter
run: |
cd frontend
npm run lint
- name: Run tests
run: |
cd frontend
npm run test
build:
needs: [backend-tests, frontend-tests]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@v2
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/support-backend:latest
- name: Build and push frontend
uses: docker/build-push-action@v2
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/support-frontend:latest