builder / ci.yaml
mgbam's picture
Update ci.yaml
4610542 verified
# .github/workflows/ci.yaml
# --------------------------------------------------------------
# AnyCoder AI – Continuous Integration pipeline
# --------------------------------------------------------------
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
PYTHON_VERSION_MATRIX: "3.9,3.10,3.11"
DOCKER_IMAGE: anycoder:latest
jobs:
# --------------------------------------------------------------
# 1. Lint & Test (Python)
# --------------------------------------------------------------
lint-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [${{ fromJSON(env.PYTHON_VERSION_MATRIX) }}]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 pytest nbmake
# style / typing (optional)
pip install black==24.2.0 mypy
- name: Lint with flake8 & black‑check
run: |
black --check .
flake8 .
- name: Run pytest
run: |
pytest -q
- name: Validate notebooks with nbmake
run: |
pytest --nbmake notebooks/
# --------------------------------------------------------------
# 2. Build static front‑end (HTML/CSS/JS) – no node needed
# --------------------------------------------------------------
build-frontend:
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- uses: actions/checkout@v4
- name: Archive static assets
uses: actions/upload-artifact@v4
with:
name: static-assets
path: |
static/index.html
static/style.css
static/index.js
# --------------------------------------------------------------
# 3. Docker build & (optional) publish
# --------------------------------------------------------------
build-and-deploy:
runs-on: ubuntu-latest
needs:
- lint-and-test
- build-frontend
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: |
docker build -t ${{ env.DOCKER_IMAGE }} .
# Optionally push to GHCR / DockerHub
# - name: Log in to registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GHCR_TOKEN }}
#
# - name: Push image
# run: |
# docker tag ${{ env.DOCKER_IMAGE }} ghcr.io/${{ github.repository }}:latest
# docker push ghcr.io/${{ github.repository }}:latest