🏡 index : quine-global/quine-anaconda-webui.git

name: test-compose
on:
  schedule:
    - cron: '0 1 * * *'
  # can be run manually on https://github.com/rhinstaller/anaconda-webui/actions
  workflow_dispatch:
    inputs:
      compose_id:
        description: 'Compose ID to test (leave empty to test against current event)'
      staging:
        description: 'Whether to test the staging wiki'
        default: 'false'
jobs:
  test-compose:
    environment: 'fedora-wiki'
    permissions:
      statuses: write
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v4

      - name: Get compose ID
        id: get-compose
        run: |
          if [ -n "${{ github.event.inputs.compose_id }}" ]; then
            echo "compose_id=${{ github.event.inputs.compose_id }}" >> $GITHUB_OUTPUT
          else
            sudo apt-get update
            sudo apt-get install -y python3-pip
            sudo pip3 install wikitcms
            COMPOSE_ID=$(python3 test/fedora-wiki/get_current_compose.py)
            echo "compose_id=$COMPOSE_ID" >> $GITHUB_OUTPUT
          fi

      - name: Trigger and verify compose tests
        timeout-minutes: 90
        run: |
          set -euo pipefail
          mkdir -p ~/.config/cockpit-dev
          echo "${{ github.token }}" >> ~/.config/cockpit-dev/github-token

          export TEST_COMPOSE=${{ steps.get-compose.outputs.compose_id }}
          if [ "${{ github.event.inputs.staging }}" = "true" ]; then
            make test-compose-staging
          else
            make test-compose
          fi

          bots/tests-status - --wait 2>&1 | tee tests-status.log

          if grep -q '^  not ok ' tests-status.log; then
            echo "Failed test cases:"
            grep '^  not ok ' tests-status.log
            exit 1
          fi