name: execution environment images

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  # Run once per week (Monday at 08:00 UTC)
  schedule:
    - cron: '0 8 * * 1'

jobs:
  build:
    name: 'Build EE image: ${{ matrix.name }}'
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: community-ee-base
          - name: community-ee-minimal

    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          python-version: 3.11

      - name: Install dependencies
        run: |
          sudo apt-get install podman
          pip install ansible-core ansible-builder ansible-navigator

      - name: Build ${{ matrix.name }} image
        run: |
          ansible-builder build -v 3 -t test-ee:${{ matrix.name }}
        working-directory: ./execution-environments/${{ matrix.name }}

      - name: Run basic tests with ${{ matrix.name }} image
        run: |
          ansible-navigator -v --mode stdout --pull-policy never \
            --execution-environment-image test-ee:${{ matrix.name }} \
            run tests.yml
        working-directory: ./execution-environments/${{ matrix.name }}