.github/workflows/ragel.yml

Summary

Maintainability
Test Coverage
name: ragel

on: [push, pull_request, workflow_dispatch]

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
  skip_duplicate_runs:
    uses: ./.github/workflows/skip_duplicate_workflow_runs.yml
    with:
      paths: '["ext/**", ".github/workflows/ragel.yml"]'

  ragel:
    name: >-
      ragel ${{ matrix.os }} ${{ matrix.ruby }}
    needs: skip_duplicate_runs
    env:
      PUMA_NO_RUBOCOP: true
      PUMA_TEST_DEBUG: true

    runs-on: ${{ matrix.os }}
    if: |
      !(   contains(github.event.pull_request.title,  '[ci skip]')
        || contains(github.event.pull_request.title,  '[skip ci]'))
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-20.04 , ruby: head }
          - { os: macos-11     , ruby: head }
          # Dec-2023 - incorrect line directives with Windows
          # occurs with both MSYS2 and MSFT/vpkg versions of ragel
          # - { os: windows-2022 , ruby: ucrt } 

    steps:
      # windows git will convert \n to \r\n
      - name: git config
        if: |
          startsWith(matrix.os, 'windows') &&
          (needs.skip_duplicate_runs.outputs.should_skip != 'true')
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf

      - name: repo checkout
        if: ${{ needs.skip_duplicate_runs.outputs.should_skip != 'true' }}
        uses: actions/checkout@v4

      - name: load ruby
        if: ${{ needs.skip_duplicate_runs.outputs.should_skip != 'true' }}
        uses: ruby/setup-ruby-pkgs@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          apt-get: ragel
          brew: ragel
          bundler-cache: true
        timeout-minutes: 10

      - name: check ragel generation
        if: ${{ needs.skip_duplicate_runs.outputs.should_skip != 'true' }}
        shell: pwsh
        run:  |
          ragel --version
          Remove-Item -Path ext/puma_http11/http11_parser.c
          Remove-Item -Path ext/puma_http11/org/jruby/puma/Http11Parser.java
          bundle exec rake ragel
          if ($IsWindows) {
            dos2unix ext/puma_http11/http11_parser.c
            dos2unix ext/puma_http11/org/jruby/puma/Http11Parser.java
          }
          $git_out = $(git status --porcelain)
          if ($git_out -ne $null) {
            echo "** $git_out **`n"
            git --no-pager diff
            echo "`nbundle exec ragel changes a file"
            exit 1
          }

      - name: save ragel generated files on fail
        uses: actions/upload-artifact@v4
        if: ${{ failure() }}
        with:
          name: ${{ matrix.os }}-ragel-generated-files
          path: |
            ext/puma_http11/http11_parser.c
            ext/puma_http11/org/jruby/puma/Http11Parser.java