Skip to content
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/e2e_nochnyh_testiv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 🌙 Інтеграційні тести (10× на добу)

on:
schedule:
# кожні ~2 години ⇒ 12 разів; GitHub не підтримує точні 10,
# але це ближче за все до вимоги «десять»
- cron: '0 */2 * * *'
workflow_dispatch:

jobs:
e2e:
name: 🚦 End‑to‑End тести
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: ▶️ Запускаємо docker‑compose
run: |
docker compose up -d
echo "⌛ Чекаємо 15 cекунд поки застосунок підійме службу…"
sleep 15

- name: 🔗 Перевірка доступності головної сторінки
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 || true)
if [ "$STATUS" != "200" ]; then
echo "❌ Головна недоступна, код $STATUS"; exit 1
fi
echo "✅ Отримано 200 OK"

- name: ⏹️ Зупинка контейнерів
if: always()
run: docker compose down -v
89 changes: 89 additions & 0 deletions .github/workflows/perevirka_kodu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: ✅ Перевірка коду (CI)

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
workflow_dispatch: # ручний запуск

jobs:
lint:
name: 🔍 Лінтинг (flake8)
runs-on: ubuntu-latest
steps:
- name: ⬇️ Клон репозиторію
uses: actions/checkout@v4

- name: ⚙️ Встановити Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: 📦 Встановити залежності
run: |
pip install -r requirements.txt flake8

- name: 🚨 Запустити flake8
run: |
echo "▶️ Старт лінтингу…"
flake8 .
echo "✅ Лінтинг завершено без помилок"

types:
name: 🧐 Статична перевірка типів (mypy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.12' }
- run: |
pip install -r requirements.txt mypy
- name: 🔍 mypy
run: |
echo "▶️ Перевіряємо типи…"
mypy .
echo "✅ Типи коректні"

tests:
name: 🧪 Модульні тести (pytest)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
ports: [ '5432:5432' ]
options: >-
--health-cmd "pg_isready -U test" --health-interval 10s
--health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.12' }
- run: |
pip install -r requirements.txt pytest coverage
- name: ▶️ Запуск pytest
run: |
coverage run -m pytest -v
- name: 📊 Звіт Coverage
run: |
coverage xml -o coverage.xml
- name: ☁️ Завантажити coverage у Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build-image:
name: 🐳 Локальна збірка Docker‑образу
runs-on: ubuntu-latest
needs: [ lint, types, tests ]
steps:
- uses: actions/checkout@v4
- name: ▶️ docker build
run: |
echo "🛠️ Будуємо контейнер…"
docker build -t myapp:test .
echo "✅ Збірка пройшла успішно"
35 changes: 35 additions & 0 deletions .github/workflows/prybyrannia_artefaktiv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 🧹 Прибирання артефактів

on:
schedule:
# 5 разів на добу (через кожні 4 години 48 хвилин)
- cron: '48 */4 * * *'
workflow_dispatch:

jobs:
cleanup:
name: 🗑️ Видалення старих artefact‑ів
runs-on: ubuntu-latest

steps:
- name: 🧮 Знаходимо застарілі artefact‑и
uses: actions/github-script@v7
with:
script: |
const maxAgeDays = 3
const cutoff = Date.now() - maxAgeDays*24*60*60*1000
const { data } = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100
})
const old = data.artifacts.filter(a => new Date(a.created_at).valueOf() < cutoff)
core.notice(`Старих artefact‑ів: ${old.length}`)
for (const art of old) {
core.notice(`🗑️ Видалення #${art.id} (${art.name})`)
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: art.id
})
}
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM python:3.7

COPY requirements.txt /
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r /requirements.txt
FROM python:3.12-slim AS base
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

FROM base AS runtime
COPY . .
ENV PYTHONUNBUFFERED=1
EXPOSE 5000

HEALTHCHECK CMD curl -f http://localhost:5000/healthz || exit 1
CMD ["gunicorn","-k","gevent","--bind","0.0.0.0:5000","app:app"]
Loading