required dependencies (Discord token, database) are missing in this environment thus the test will fail
76 lines
1.8 KiB
YAML
76 lines
1.8 KiB
YAML
name: Backend
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "**.py"
|
|
- "requirements*.txt"
|
|
- "pyproject.toml"
|
|
- "Dockerfile"
|
|
- ".gitea/workflows/backend.yaml"
|
|
pull_request:
|
|
paths:
|
|
- "**.py"
|
|
- "requirements*.txt"
|
|
- "pyproject.toml"
|
|
- "Dockerfile"
|
|
- ".gitea/workflows/backend.yaml"
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.13"
|
|
RUFF_VERSION: "0.16.4"
|
|
|
|
jobs:
|
|
lint:
|
|
name: Lint i formatowanie
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Instalacja ruff
|
|
run: pip install --no-cache-dir "ruff==${RUFF_VERSION}"
|
|
|
|
- name: Reguły lintera
|
|
run: ruff check --output-format=github .
|
|
|
|
- name: Zgodność z formatterem
|
|
run: ruff format --check --diff .
|
|
|
|
test:
|
|
name: Testy i kontrakt API
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
# Zależności instalują się z gotowych kółek - kompilator nie jest
|
|
# potrzebny. ffmpeg i libopus są wymagane dopiero przy odtwarzaniu,
|
|
# a testy nie dotykają warstwy audio.
|
|
- name: Instalacja zależności
|
|
run: pip install -r requirements.txt
|
|
|
|
- name: Testy jednostkowe
|
|
run: python -m unittest discover -s tests -t . -v
|
|
|
|
- name: Kontrola składni całego pakietu
|
|
run: python -m compileall -q zyrarbot main.py
|
|
|
|
image:
|
|
name: Testowy build obrazu
|
|
runs-on: builder
|
|
needs: [lint, test]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Budowa obrazu backendu
|
|
run: docker build --tag zyrarbot-api:ci .
|