From c0b8d42b06416efa1b5c833a49e817453981d586 Mon Sep 17 00:00:00 2001 From: Mark Shamanskii Date: Wed, 29 Apr 2026 13:07:10 +0500 Subject: [PATCH] CI: Refactor workflows, add concurrency, caching, and build Docker image job --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bee3d5c..1f67fea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,15 @@ on: pull_request: branches: [main] +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: - checks: + static-checks: runs-on: ubuntu-latest steps: @@ -21,6 +28,12 @@ jobs: cache: pip cache-dependency-path: infra/requirements/dev.txt + - name: Cache pre-commit environments + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ runner.os }}-py3.13-${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install dependencies run: | python -m pip install --upgrade pip @@ -35,6 +48,31 @@ jobs: bot \ tests + - name: Run pre-commit + run: make lint + + migration-heads: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.13" + cache: pip + cache-dependency-path: infra/requirements/dev.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r infra/requirements/dev.txt + + - name: Create CI env file + run: cp .env.example .env + - name: Check migration HEADs run: | export PYTHONPATH="$PWD" @@ -46,8 +84,27 @@ jobs: exit 1 fi - - name: Run pre-commit - run: make lint + tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.13" + cache: pip + cache-dependency-path: infra/requirements/dev.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r infra/requirements/dev.txt + + - name: Create CI env file + run: cp .env.example .env - name: Run tests with coverage run: make test-cov @@ -59,5 +116,13 @@ jobs: format: cobertura file: coverage.xml + docker-build: + runs-on: ubuntu-latest + needs: [static-checks, migration-heads, tests] + + steps: + - name: Checkout code + uses: actions/checkout@v6 + - name: Build Docker image run: docker build -f infra/docker/Dockerfile -t engflowbot:ci .