name: Push

on:
  push:
    branches:
      - master

jobs:
  build:
    name: ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }}
    runs-on: ${{ matrix.build.os }}

    strategy:
      fail-fast: false
      matrix:
        build:
          - system_name: Linux
            build_type: Release
            compiler_name: GCC
            test_path: WhoaTest
            os: ubuntu-latest
            cc: gcc
            cxx: g++

          - system_name: macOS
            build_type: Release
            compiler_name: Clang
            test_path: WhoaTest
            os: macos-latest
            cc: clang
            cxx: clang++

          - system_name: Windows
            build_type: Release
            compiler_name: MSVC
            test_path: WhoaTest
            os: windows-latest
            cc: cl
            cxx: cl

    steps:
      - uses: actions/checkout@v6
        with:
          submodules: recursive

      - name: Download Fixtures
        run: aws s3 cp --endpoint-url ${{ env.AWS_ENDPOINT_URL }} s3://reliquaryhq-whoa/fixture.tgz  test/fixture/
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.STORAGE_AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.STORAGE_AWS_SECRET_ACCESS_KEY }}
          AWS_ENDPOINT_URL: ${{ vars.STORAGE_AWS_ENDPOINT_URL }}

      - name: Unpack Fixtures
        run: tar -xvzf fixture.tgz
        working-directory: test/fixture

      - name: Prepare
        run: mkdir build

      - name: Configure
        run: cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build.build_type }}
        working-directory: build

      - name: Build
        run: cmake --build . --config ${{ matrix.build.build_type }}
        working-directory: build

      - name: Install
        run: cmake --install . --config ${{ matrix.build.build_type }}
        working-directory: build

      - name: Test
        run: ../../build/dist/bin/${{ matrix.build.test_path }}
        working-directory: test/fixture
