name: Package Checks

on:
  push:
    branches:
      - main
      - 3.0.x
  pull_request:
    branches:
      - main
      - 3.0.x
    types: [ labeled, opened, synchronize, reopened ]

permissions: {}

defaults:
  run:
    shell: bash -el {0}

jobs:
  pip:
    if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}}
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    strategy:
      matrix:
        extra: ["test", "pyarrow", "performance", "computation", "fss", "aws", "gcp", "excel", "parquet", "feather", "hdf5", "spss", "postgresql", "mysql", "sql-other", "html", "xml", "plot", "output-formatting", "clipboard", "compression", "all"]
      fail-fast: false
    name: Install Extras - ${{ matrix.extra }}
    concurrency:
      # https://github.community/t/concurrecy-not-work-for-push/183068/7
      group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-pip-extras-${{ matrix.extra }}
      cancel-in-progress: true

    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          fetch-depth: 0

      - name: Setup Python
        id: setup_python
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
        with:
          python-version: '3.11'

      - name: Pip install with extra
        run: |
          python -m pip install .[${{ matrix.extra }}] -v
        shell: bash -el {0}
  conda_forge_recipe:
    if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}}
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    name: Test Conda Forge Recipe
    concurrency:
      # https://github.community/t/concurrecy-not-work-for-push/183068/7
      group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-conda-forge-recipe
      cancel-in-progress: true
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          fetch-depth: 0

      - name: Set up Python
        uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2
        with:
          environment-name: recipe-test
          create-args: >-
            python=3.11
            boa
            conda-verify
          cache-downloads: true
          cache-environment: true

      - name: Build conda package
        run: conda mambabuild ci --no-anaconda-upload --verify --strict-verify --output --output-folder .
