name: Validate Matrix Scaffold

on:
  push:
    branches: [main, master]
    paths:
      - "infra/matrix/**"
      - ".gitea/workflows/validate-matrix-scaffold.yml"
  pull_request:
    branches: [main, master]
    paths:
      - "infra/matrix/**"

jobs:
  validate-scaffold:
    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 dependencies
        run: pip install pyyaml

      - name: Validate Matrix/Conduit scaffold
        run: python3 infra/matrix/scripts/validate-scaffold.py --json

      - name: Check shell scripts are executable
        run: |
          test -x infra/matrix/deploy-matrix.sh
          test -x infra/matrix/host-readiness-check.sh
          test -x infra/matrix/scripts/deploy-conduit.sh

      - name: Validate docker-compose syntax
        run: |
          docker compose -f infra/matrix/docker-compose.yml config > /dev/null
