Skip to content

style(frigate-health-checker): format with ruff #11

style(frigate-health-checker): format with ruff

style(frigate-health-checker): format with ruff #11

name: Frigate Health Checker CI/CD
on:
push:
branches: [master]
paths:
- 'apps/frigate-health-checker/**'
- '.github/workflows/frigate-health-checker.yml'
pull_request:
branches: [master]
paths:
- 'apps/frigate-health-checker/**'
- '.github/workflows/frigate-health-checker.yml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/frigate-health-checker
defaults:
run:
working-directory: apps/frigate-health-checker
jobs:
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: '1.8.5'
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: apps/frigate-health-checker/.venv
key: venv-${{ runner.os }}-${{ hashFiles('apps/frigate-health-checker/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
- name: Run Ruff linter
run: poetry run ruff check src/ tests/
- name: Run Ruff formatter check
run: poetry run ruff format --check src/ tests/
- name: Run MyPy type checking
run: poetry run mypy src/
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: '1.8.5'
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: apps/frigate-health-checker/.venv
key: venv-${{ runner.os }}-${{ hashFiles('apps/frigate-health-checker/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
- name: Run tests with coverage
run: poetry run pytest --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: apps/frigate-health-checker/coverage.xml
flags: frigate-health-checker
fail_ci_if_error: false
build:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=raw,value=latest
type=raw,value={{date 'YYYYMMDD-HHmmss'}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: apps/frigate-health-checker
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
format: spdx-json
output-file: sbom.spdx.json
- name: Upload SBOM
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.spdx.json
notify-flux:
name: Trigger Flux Reconciliation
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
defaults:
run:
working-directory: .
steps:
- name: Trigger Flux webhook (optional)
run: |
echo "Image pushed: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
echo "Flux will auto-reconcile on image policy update"
# If using Flux image automation, the ImagePolicy will detect the new tag
# No manual trigger needed - Flux polls the registry