Files
mostovik-backend/.gitea/workflows/ci-cd.yml
Aleksandr Meshchriakov 14196a7549
Some checks failed
CI/CD Pipeline / Run Tests (pull_request) Successful in 1m13s
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m18s
CI/CD Pipeline / Build Docker Images (pull_request) Failing after 2m46s
CI/CD Pipeline / Push to Gitea Registry (pull_request) Has been skipped
feat: add parser source dashboard and scheduling
2026-04-28 00:15:56 +02:00

206 lines
5.5 KiB
YAML

name: CI/CD Pipeline
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
lint:
name: Code Quality Checks
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install uv
run: python -m pip install --upgrade pip uv
- name: Create virtual environment
run: uv venv
- name: Activate virtual environment and install dependencies
run: |
source .venv/bin/activate
uv sync --dev
- name: Run Ruff linting
run: |
source .venv/bin/activate
ruff check src
- name: Run Ruff formatting check
run: |
source .venv/bin/activate
ruff format src --check
test:
name: Run Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install uv
run: python -m pip install --upgrade pip uv
- name: Create virtual environment
run: uv venv
- name: Activate virtual environment and install dependencies
run: |
source .venv/bin/activate
uv sync --dev
- name: Run Django tests
run: |
source .venv/bin/activate
cd src
python manage.py test --verbosity=2
env:
DJANGO_SETTINGS_MODULE: config.settings.test
SECRET_KEY: test-secret-key-for-ci
build:
name: Build Docker Images
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata for web image
id: meta-web
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/mostovik-web
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
- name: Extract metadata for celery image
id: meta-celery
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/mostovik-celery
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
- name: Build web image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.web
push: false
load: true
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build celery image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.celery
push: false
load: true
tags: ${{ steps.meta-celery.outputs.tags }}
labels: ${{ steps.meta-celery.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
push:
name: Push to Gitea Registry
runs-on: ubuntu-latest
needs: [build]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.GITEA_REGISTRY_URL }}
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata for web image
id: meta-web
uses: docker/metadata-action@v5
with:
images: |
${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}/mostovik-web
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Extract metadata for celery image
id: meta-celery
uses: docker/metadata-action@v5
with:
images: |
${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}/mostovik-celery
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push web image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.web
push: true
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push celery image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.celery
push: true
tags: ${{ steps.meta-celery.outputs.tags }}
labels: ${{ steps.meta-celery.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: |
echo "Web image digest: ${{ steps.docker_build_web.outputs.digest }}"
echo "Celery image digest: ${{ steps.docker_build_celery.outputs.digest }}"