name: Linux

on:
    push:
        paths-ignore:
            - 'doc/**'
    pull_request:
        paths-ignore:
            - 'doc/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: Linux ${{ matrix.type }}
    defaults:
      run:
        shell: bash -l {0}
    runs-on: 'ubuntu-latest'
    if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
    strategy:
      fail-fast: false
      matrix:
        type: ['current','fixed']
    env:
      BUILD_TYPE: ${{ matrix.type }}
    steps:
    - uses: actions/checkout@v4
    - uses: mamba-org/setup-micromamba@v2
      with:
        init-shell: bash
        environment-file: "scripts/ci/${{ matrix.type }}-environment.yml"
        environment-name: "pdal-build"
        cache-environment: true
        cache-downloads: true

    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-ubuntu-latest

    - name: Setup
      run: |
          source ./scripts/ci/linux/setup.sh

    - name: CMake
      run: |
          source ../scripts/ci/linux/cmake.sh
      working-directory: ./build

    - name: Compile
      run: |
          source ../scripts/ci/linux/compile.sh
      working-directory: ./build

    - name: Test
      run: |
          source ../scripts/ci/linux/test.sh
      working-directory: ./build

    - name: Examples
      run: |
          source ./scripts/ci/linux/examples.sh

    - name: Standalone Plugins
      run: |
          source ./scripts/ci/linux/standalone.sh

    - name: Install German locale
      env:
        DEBIAN_FRONTEND: noninteractive
        TZ: Etc/UTC
      run: sudo apt-get install -y tzdata locales && sudo locale-gen de_DE.UTF-8

    - name: Test with German locale (except io_tiledb)
      env:
        TEST_SET_LOCALE: de_DE.UTF-8
      run: |
          # Exclude 5 tiledb io tests that fail due to TileDB library implementation
          # and 2 e57 io tests for the same reason.
          # please, remove the exception rule here when fixed
          source ../scripts/ci/linux/test.sh -E 'pdal_io_tiledb_(time_writer|time_reader|writer|reader|bit_fields)_test|pdal_io_e57_(write|read)_test|pdal_io_stac_reader_test'
      working-directory: ./build


