name: CI/CD Workflow

on:
  pull_request_target:
    branches:
      - '*'
    types: [labeled]
  release:
    types: [published]
      
jobs:        
  check:
    if: github.event.label.name == 'ci' || github.event_name == 'release'
    uses: ./.github/workflows/cppcheck.yml
    with:
      image_name: registry.agibot.com/agibot-tech/gitlab-ci
      image_tag: latest
    secrets: inherit
  
  test_gcc11_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-gcc11-ubuntu22_04
      image_tag: latest
      run_platform: amd64
      test_report: true
    secrets: inherit  
    needs: [check]
  
  test_gcc11_arm64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-arm64-gcc11-ubuntu22_04
      image_tag: latest
      run_platform: arm64
    secrets: inherit
    needs: [test_gcc11_amd64]
  
  test_msvc:
    uses: ./.github/workflows/test-msvc-workflow.yml
    with:
      run_platform: msvc
    secrets: inherit
    needs: [test_gcc11_amd64]
    
  test_gcc12_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-gcc12-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]
  
  test_gcc13_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-gcc13-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]
  
  test_clang15_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-clang15-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]
  
  test_clang16_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-clang16-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]
    
  test_clang17_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-clang17-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]
  
  test_clang18_amd64:
    uses: ./.github/workflows/test-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-clang18-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_gcc11_amd64]


  build_x86:
    uses: ./.github/workflows/build-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-amd64-gcc11-ubuntu22_04
      image_tag: latest
      run_platform: amd64
    secrets: inherit
    needs: [test_msvc, test_gcc11_arm64, test_gcc12_amd64, test_gcc13_amd64, test_clang15_amd64, test_clang16_amd64, test_clang17_amd64, test_clang18_amd64]
  
  build_arm64:
    uses: ./.github/workflows/build-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/aimrt_ci-arm64-gcc11-ubuntu22_04
      image_tag: latest
      run_platform: arm64
    secrets: inherit
    needs: [test_msvc, test_gcc11_arm64, test_gcc12_amd64, test_gcc13_amd64, test_clang15_amd64, test_clang16_amd64, test_clang17_amd64, test_clang18_amd64]
    
  build_msvc:
    uses: ./.github/workflows/build-msvc-workflow.yml
    with:
      run_platform: msvc
    secrets: inherit
    needs: [test_msvc, test_gcc11_arm64, test_gcc12_amd64, test_gcc13_amd64, test_clang15_amd64, test_clang16_amd64, test_clang17_amd64, test_clang18_amd64]
    

  release:
    uses: ./.github/workflows/release-workflow.yml
    with:
      image_name: registry.agibot.com/agibot-tech/gitlab-ci
      image_tag: latest
    secrets: inherit
    if: |
      github.event_name == 'release' ||
      startsWith(github.ref, 'refs/tags/release') ||
      startsWith(github.ref, 'refs/tags/v') ||
      startsWith(github.ref, 'refs/heads/release')
    needs: [build_x86, build_arm64, build_msvc]
