name: oniguruma
on:
  push:
    branches:
      - master
  pull_request:

# Since builtin oniguruma is tested in the CI workflow,
# we test other options for --with-oniguruma here.
jobs:
  installed:
    runs-on: ubuntu-22.04
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
      - name: Install packages
        run: |
          sudo apt-get update
          sudo apt-get install -y automake autoconf libtool libonig-dev
      - name: Build
        run: |
          autoreconf -i
          ./configure \
            --disable-docs \
            --disable-maintainer-mode \
            --with-oniguruma=yes
          make -j"$(nproc)"
          file ./jq
      - name: Test
        run: |
          ./jq -n '"" | test("")'
          make check
          git diff --exit-code
      - name: Upload Test Logs
        if: ${{ failure() }}
        uses: actions/upload-artifact@v3
        with:
          name: test-logs-oniguruma-installed
          retention-days: 7
          path: |
            test-suite.log
            tests/*.log

  disabled:
    runs-on: ubuntu-22.04
    steps:
      - name: Clone repository
        uses: actions/checkout@v3
      - name: Install packages
        run: |
          sudo apt-get update
          sudo apt-get install -y automake autoconf libtool
      - name: Build
        run: |
          autoreconf -i
          ./configure \
            --disable-docs \
            --disable-maintainer-mode \
            --with-oniguruma=no
          make -j"$(nproc)"
          file ./jq
      - name: Test
        run: |
          ! ./jq -n '"" | test("")'
          make check
          git diff --exit-code
      - name: Upload Test Logs
        if: ${{ failure() }}
        uses: actions/upload-artifact@v3
        with:
          name: test-logs-oniguruma-disabled
          retention-days: 7
          path: |
            test-suite.log
            tests/*.log
