---
name: CI
on:  # yamllint disable-line rule:truthy
  pull_request:
  workflow_call:
jobs:
  test_frontend:
    name: Test alertmanager frontend
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - run: make clean
      - run: make all
        working-directory: ./ui/app
      - run: make assets
      - run: make apiv2
      - run: git diff --exit-code

  build:
    name: Build Alertmanager for common architectures
    runs-on: ubuntu-latest
    strategy:
      matrix:
        thread: [0, 1, 2]
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.0.0
      - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
      - uses: ./.github/promci/actions/build
        with:
          promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386"
          parallelism: 3
          thread: ${{ matrix.thread }}

  test:
    name: Test
    runs-on: ubuntu-latest
    # Whenever the Go version is updated here, .promu.yml
    # should also be updated.
    container:

      image: quay.io/prometheus/golang-builder:1.25-base
    services:
      maildev-noauth:
        image: maildev/maildev:2.2.1
      maildev-auth:
        image: maildev/maildev:2.2.1
        env:
          MAILDEV_INCOMING_USER: user
          MAILDEV_INCOMING_PASS: pass
    env:
      EMAIL_NO_AUTH_CONFIG: testdata/noauth.yml
      EMAIL_AUTH_CONFIG: testdata/auth.yml
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
      - uses: ./.github/promci/actions/setup_environment
      - run: make
      - run: git diff --exit-code
