From f46846fceefb14e3753828f8e068df28e0d6cd76 Mon Sep 17 00:00:00 2001 From: bnair123 Date: Sat, 27 Dec 2025 18:33:51 +0400 Subject: [PATCH] Add Gitea Actions CI/CD pipeline for automated testing and container builds - Add .gitea/workflows/ci-cd.yaml with test and build-push jobs - Tests run on every push to main, builds trigger on v* tags - Builds both engine and UI Docker images to Gitea container registry - Update Dockerfile to Python 3.12 (matches pyproject.toml requirement) - Requires REGISTRY_USERNAME and REGISTRY_PASSWORD secrets in Gitea --- .gitea/workflows/ci-cd.yaml | 92 +++++++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/ci-cd.yaml diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml new file mode 100644 index 0000000..ca34d25 --- /dev/null +++ b/.gitea/workflows/ci-cd.yaml @@ -0,0 +1,92 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + tags: + - 'v*' + +env: + REGISTRY: gitea.thefetagroup.com + IMAGE_NAME: bnair/cryptobot + +jobs: + test: + runs-on: ubuntu-latest + container: + image: python:3.12-slim + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + apt-get update + apt-get install -y --no-install-recommends build-essential wget + wget -q http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz + tar -xzf ta-lib-0.4.0-src.tar.gz + cd ta-lib && ./configure --prefix=/usr && make && make install + cd .. && rm -rf ta-lib ta-lib-0.4.0-src.tar.gz + + - name: Install Python dependencies + run: | + pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run linting + run: ruff check . + + - name: Run type checking + run: mypy src/ + + - name: Run tests + run: pytest --cov=tradefinder --cov-report=term-missing + + build-and-push: + runs-on: ubuntu-latest + needs: test + if: startsWith(github.ref, 'refs/tags/v') + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build and push engine image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + target: engine + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push UI image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + target: ui + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ui:${{ steps.version.outputs.VERSION }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ui:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index f6e161d..a061939 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # ============================================================================= # BASE IMAGE # ============================================================================= -FROM python:3.11-slim AS base +FROM python:3.12-slim AS base # System dependencies for TA-Lib and general build RUN apt-get update && apt-get install -y --no-install-recommends \