
name: Spec Compliance

on:
  schedule:
  - cron: "0 0 * * 3"

permissions:
  contents: read

jobs:
  h2spec:
    name: h2spec
    runs-on: ubuntu-latest
    if: ${{ github.repository_owner == 'haproxy' || github.event_name == 'workflow_dispatch' }}
    steps:
    - uses: actions/checkout@v5
    - name: Install h2spec
      id: install-h2spec
      run: |
        H2SPEC_VERSION=`curl --silent "https://api.github.com/repos/summerwind/h2spec/releases/latest" | jq -r -j '.tag_name'`
        curl -fsSL https://github.com/summerwind/h2spec/releases/download/${H2SPEC_VERSION}/h2spec_linux_amd64.tar.gz -o h2spec.tar.gz
        tar xvf h2spec.tar.gz
        sudo install -m755 h2spec /usr/local/bin/h2spec
        echo "version=${H2SPEC_VERSION}" >> $GITHUB_OUTPUT
    - name: Compile HAProxy with gcc
      run: |
        make -j$(nproc) all \
          ERR=1 \
          TARGET=linux-glibc \
          CC=gcc \
          DEBUG="-DDEBUG_POOL_INTEGRITY" \
          USE_OPENSSL=1
        sudo make install
    - name: Show HAProxy version
      id: show-version
      run: |
        echo "::group::Show dynamic libraries."
        if command -v ldd > /dev/null; then
          # Linux
          ldd $(which haproxy)
        else
          # macOS
          otool -L $(which haproxy)
        fi
        echo "::endgroup::"
        haproxy -vv
        echo "version=$(haproxy -v |awk 'NR==1{print $3}')" >> $GITHUB_OUTPUT
    - name: Launch HAProxy ${{ steps.show-version.outputs.version }}
      run: haproxy -f .github/h2spec.config -D
    - name: Run h2spec ${{ steps.install-h2spec.outputs.version }}
      run: h2spec -Svtk -h 127.0.0.1 -p 8443
