Merge pull request #12 from taling-dev/rebrand/docs #89
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Push | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/simaops | |
| jobs: | |
| # ─── Test gates ────────────────────────────────────────────────── | |
| # Each test job is the gate for its corresponding image build below. | |
| # Build is matrix-strategy and depends on `test` so a failing test | |
| # blocks `docker push` for any service. | |
| test-go-api: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.23" | |
| cache-dependency-path: apps/api/go.sum | |
| - name: go vet | |
| working-directory: apps/api | |
| run: go vet ./... | |
| - name: go test | |
| working-directory: apps/api | |
| run: go test -race -count=1 ./... | |
| test-go-outbox-publisher: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.23" | |
| cache-dependency-path: apps/outbox-publisher/go.sum | |
| - name: go vet | |
| working-directory: apps/outbox-publisher | |
| run: go vet ./... | |
| - name: go test | |
| working-directory: apps/outbox-publisher | |
| run: go test -race -count=1 ./... | |
| test-python-ai-worker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: install dev deps | |
| working-directory: apps/ai-worker | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest . | |
| - name: pytest | |
| working-directory: apps/ai-worker | |
| # Run the suite if tests exist; succeed (no-op) if there's no | |
| # tests/ directory yet so this gate doesn't block builds before | |
| # tests are written. Once a tests/ dir lands, this becomes a | |
| # hard gate automatically. | |
| run: | | |
| if [ -d tests ]; then | |
| pytest -q | |
| else | |
| echo "No tests/ directory yet; skipping pytest." | |
| fi | |
| - name: syntax check | |
| working-directory: apps/ai-worker | |
| # Always-on quick gate: every .py file must parse. | |
| run: | | |
| python -c " | |
| import ast, pathlib, sys | |
| fail = False | |
| for p in pathlib.Path('.').rglob('*.py'): | |
| if 'simaops_proto' in str(p): # generated stubs | |
| continue | |
| try: | |
| ast.parse(p.read_text()) | |
| except SyntaxError as e: | |
| print(f'{p}: {e}') | |
| fail = True | |
| sys.exit(1 if fail else 0) | |
| " | |
| test-web: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: pnpm | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: install | |
| working-directory: apps/web | |
| run: pnpm install --frozen-lockfile | |
| - name: svelte-check | |
| working-directory: apps/web | |
| run: pnpm svelte-kit sync && pnpm svelte-check --threshold error | |
| - name: vitest | |
| working-directory: apps/web | |
| # Same conditional gate: run vitest only if a test file exists, | |
| # so the workflow doesn't fail before tests ship. | |
| run: | | |
| if find . -name '*.test.ts' -o -name '*.spec.ts' | grep -q .; then | |
| pnpm vitest run | |
| else | |
| echo "No test files yet; skipping vitest." | |
| fi | |
| test-python-warehouse-intelligence: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: install deps | |
| working-directory: apps/warehouse-intelligence | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest . | |
| - name: pytest | |
| working-directory: apps/warehouse-intelligence | |
| run: pytest -q | |
| # ─── Build & push (only after all gates pass) ──────────────────── | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: [test-go-api, test-go-outbox-publisher, test-python-ai-worker, test-python-warehouse-intelligence, test-web] | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| app: [api, web, ai-worker, outbox-publisher, warehouse-intelligence] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: apps/${{ matrix.app }} | |
| push: ${{ github.event_name == 'push' }} | |
| cache-from: type=gha,scope=${{ matrix.app }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.app }} | |
| tags: | | |
| ${{ env.IMAGE_PREFIX }}-${{ matrix.app }}:${{ github.sha }} | |
| ${{ env.IMAGE_PREFIX }}-${{ matrix.app }}:latest |