Skip to content

docs: actualizar PROJECT_STATUS.md a v1.0.0 — 228 tests, LUNA2000, SU… #16

docs: actualizar PROJECT_STATUS.md a v1.0.0 — 228 tests, LUNA2000, SU…

docs: actualizar PROJECT_STATUS.md a v1.0.0 — 228 tests, LUNA2000, SU… #16

Workflow file for this run

name: CI
on:
push:
branches: ["**"]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
IMAGE_NAME: bessai-edge-gateway
jobs:
# ─────────────────────────────────────────────────────────────────
# Job 1: Lint
# ─────────────────────────────────────────────────────────────────
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install ruff
run: pip install ruff
- name: Run ruff check
run: ruff check src/ tests/
- name: Run ruff format check
run: ruff format --check src/ tests/
# ─────────────────────────────────────────────────────────────────
# Job 2: Type check
# ─────────────────────────────────────────────────────────────────
typecheck:
name: Type check (mypy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt -r requirements-dev.txt
- name: Run mypy
run: mypy src/ --ignore-missing-imports --no-error-summary
# ─────────────────────────────────────────────────────────────────
# Job 3: Unit tests
# ─────────────────────────────────────────────────────────────────
test:
name: Tests (pytest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- name: Install dependencies
run: pip install -r requirements.txt -r requirements-dev.txt
- name: Run tests with coverage
run: |
pytest tests/ -v --tb=short \
--cov=src \
--cov-report=xml \
--cov-report=term-missing \
--cov-fail-under=80
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v4
with:
file: coverage.xml
flags: unittests
fail_ci_if_error: false
# ─────────────────────────────────────────────────────────────────
# Job 4: Terraform validate (no GCP credentials needed)
# ─────────────────────────────────────────────────────────────────
terraform-validate:
name: Terraform validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~> 1.7"
- name: Terraform init (local backend only)
run: terraform -chdir=infrastructure/terraform init -backend=false
- name: Terraform validate
run: terraform -chdir=infrastructure/terraform validate
- name: Terraform fmt check
run: terraform -chdir=infrastructure/terraform fmt -check -recursive
# ─────────────────────────────────────────────────────────────────
# Job 5: Helm lint & template validation
# ─────────────────────────────────────────────────────────────────
helm-lint:
name: Helm lint & template
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: "3.14.0"
- name: Helm lint
run: helm lint infrastructure/helm/bessai-edge/
- name: Helm template dry-run
run: |
helm template bessai-test infrastructure/helm/bessai-edge/ \
--set config.inverterIp=10.0.1.50 \
--set config.siteId=CI-TEST \
| head -60
# ─────────────────────────────────────────────────────────────────
# Job 6: Docker build (valida que la imagen construye)
# ─────────────────────────────────────────────────────────────────
docker-build:
name: Docker build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image (no push)
uses: docker/build-push-action@v5
with:
context: .
file: infrastructure/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ─────────────────────────────────────────────────────────────────
# Job 5: Push to GCP Artifact Registry (solo en main)
# ─────────────────────────────────────────────────────────────────
docker-push:
name: Push to Artifact Registry
runs-on: ubuntu-latest
needs: [docker-build]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: read
id-token: write # Required for Workload Identity Federation
steps:
- uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev --quiet
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: infrastructure/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/bessai/${{ env.IMAGE_NAME }}:latest
${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/bessai/${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max