Repository navigation
Expand adversarial HTTP request parser coverage #12177
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Core | |
| on: | |
| schedule: | |
| # Once per day, Monday to Friday | |
| - cron: '0 19 * * 1-5' | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| concurrency: | |
| group: core-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - os: macos-latest | |
| cc: clang | |
| cxx: clang++ | |
| type: static | |
| shell: sh | |
| benchmark: macos/llvm | |
| - os: macos-latest | |
| cc: clang | |
| cxx: clang++ | |
| type: shared | |
| shell: sh | |
| - os: ubuntu-latest | |
| cc: clang | |
| cxx: clang++ | |
| type: static | |
| shell: sh | |
| options: -DSOURCEMETA_CORE_CRYPTO_USE_REFERENCE:BOOL=ON | |
| benchmark: linux/llvm | |
| - os: ubuntu-latest | |
| cc: gcc | |
| cxx: g++ | |
| type: static | |
| shell: sh | |
| options: -DSOURCEMETA_CORE_HTTP_USE_SYSTEM_CURL:BOOL=ON | |
| apt: libcurl4-openssl-dev | |
| benchmark: linux/gcc | |
| - os: ubuntu-latest | |
| cc: clang | |
| cxx: clang++ | |
| type: shared | |
| shell: sh | |
| - os: ubuntu-latest | |
| cc: gcc | |
| cxx: g++ | |
| type: shared | |
| shell: sh | |
| - os: windows-latest | |
| type: static | |
| shell: pwsh | |
| benchmark: windows/msvc | |
| - os: windows-latest | |
| type: shared | |
| shell: pwsh | |
| - os: windows-latest | |
| cc: gcc | |
| cxx: g++ | |
| type: static | |
| shell: 'msys2 {0}' | |
| msystem: MINGW64 | |
| # Sanitizers | |
| - os: ubuntu-latest | |
| cc: clang | |
| cxx: clang++ | |
| type: static | |
| shell: sh | |
| options: -DSOURCEMETA_CORE_ADDRESS_SANITIZER:BOOL=ON | |
| defaults: | |
| run: | |
| shell: ${{ matrix.platform.shell }} | |
| runs-on: ${{ matrix.platform.os }} | |
| # Reading the repository is all the build needs. The benchmark report is | |
| # the one thing that writes anywhere, and it writes to the conversation | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| CC: ${{ matrix.platform.cc }} | |
| CXX: ${{ matrix.platform.cxx }} | |
| # The build downloads a pinned compiler cache of its own during | |
| # configuration and points the compiler at it, so the only settings left | |
| # here are the ones that route cannot carry. The Visual Studio generator | |
| # ignores compiler launchers, so those builds read the cache location | |
| # from the environment rather than from the build system | |
| CCACHE_DIR: ${{ github.workspace }}/.ccache | |
| # Runner images are re-provisioned on every run, so the default check of | |
| # the compiler modification time and size would miss on an unchanged | |
| # compiler. Hash its contents instead | |
| CCACHE_COMPILERCHECK: content | |
| # Nothing in the cache should depend on where the build happens to sit. | |
| # Rewriting absolute paths so that they are relative to the workspace, | |
| # and keeping the working directory out of the hash, is what lets an | |
| # entry written from one build directory serve another | |
| CCACHE_BASEDIR: ${{ github.workspace }} | |
| CCACHE_NOHASHDIR: "1" | |
| CCACHE_MAXSIZE: 500M | |
| # Bump the version segment to invalidate every compiler cache by hand. | |
| # The job index disambiguates matrix entries that otherwise share an | |
| # operating system, a compiler, and a linkage | |
| CACHE_KEY: ccache-v2-${{ matrix.platform.os }}-${{ matrix.platform.cc || 'msvc' }}-${{ matrix.platform.type }}-${{ strategy.job-index }} | |
| # What every configure in this job passes. The compiler cache hashes the | |
| # arguments it is handed, so a single one that differs between two | |
| # configures of the same job misses on every translation unit. Spelling | |
| # them once here is what keeps them from drifting apart | |
| CONFIGURE_BASE_FLAGS: >- | |
| -DCMAKE_BUILD_TYPE:STRING=Release | |
| -DSOURCEMETA_CORE_TESTS:BOOL=ON | |
| -DSOURCEMETA_CORE_TESTS_CI:BOOL=ON | |
| -DSOURCEMETA_CORE_BENCHMARK:BOOL=ON | |
| -DSOURCEMETA_CORE_DOCS:BOOL=OFF | |
| -DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON | |
| -DBUILD_SHARED_LIBS:BOOL=${{ matrix.platform.type == 'shared' && 'ON' || 'OFF' }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup MSYS2 (Windows) | |
| if: matrix.platform.msystem | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.platform.msystem }} | |
| update: true | |
| pacboy: gcc:p cmake:p | |
| - name: Install dependencies (macOS) | |
| if: runner.os == 'macos' | |
| run: brew bundle | |
| env: | |
| HOMEBREW_NO_ANALYTICS: 1 | |
| HOMEBREW_NO_AUTO_UPDATE: 1 | |
| # Only the job that builds against the system libraries still reaches for | |
| # the package manager. The Azure Ubuntu mirror stalls often enough to | |
| # matter, and without a bound a stalled mirror burns the entire job | |
| # timeout rather than failing while the run is still useful | |
| - name: Install dependencies (Linux) | |
| if: matrix.platform.apt | |
| timeout-minutes: 5 | |
| run: sudo apt-get update && sudo apt-get install --yes ${{ matrix.platform.apt }} | |
| # The primary key never matches, as it carries the run identifier, so a | |
| # restore always walks the fallbacks in order. A previous run of this same | |
| # pull request comes first, as it is the closest to what we are about to | |
| # compile, and `main` is the fallback. A cache written by a pull request | |
| # run is only visible to re-runs of that same pull request, so no entry | |
| # here can leak sideways into an unrelated branch | |
| - name: Restore ccache | |
| id: ccache | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: ${{ github.workspace }}/.ccache | |
| key: ${{ env.CACHE_KEY }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| restore-keys: | | |
| ${{ env.CACHE_KEY }}-${{ github.ref_name }}- | |
| ${{ env.CACHE_KEY }}-main- | |
| - run: cmake --version | |
| - name: Configure | |
| run: > | |
| cmake -S . -B ./build | |
| ${{ env.CONFIGURE_BASE_FLAGS }} | |
| ${{ matrix.platform.options }} | |
| - run: cmake --build ./build --config Release --target ccache_stats_zero | |
| - run: cmake --build ./build --config Release --target clang_format_test | |
| - run: cmake --build ./build --config Release --parallel 4 | |
| - run: cmake --build ./build --config Release --target ccache_stats | |
| - run: > | |
| cmake --install ./build --prefix ./build/dist --config Release --verbose | |
| --component sourcemeta_core | |
| - run: > | |
| cmake --install ./build --prefix ./build/dist --config Release --verbose | |
| --component sourcemeta_core_dev | |
| # Not every CTest version supports the --test-dir option. If such option | |
| # is not recognized, `ctest` will successfully exit finding no tests. | |
| # Better to be sure and `cd` all the time here. | |
| - run: cd ./build && ctest --build-config Release --output-on-failure --parallel | |
| env: | |
| # See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html | |
| UBSAN_OPTIONS: print_stacktrace=1 | |
| # The two names an interpreter goes by are not both on the path | |
| # everywhere this runs, and on one of them the name resolves to a stub | |
| # that sends you to an app store, so the path is asked for outright | |
| - uses: actions/setup-python@v7 | |
| id: python | |
| if: matrix.platform.benchmark && github.event_name == 'pull_request' | |
| with: | |
| python-version: '3.13' | |
| # The base revision gets a directory of its own, so that each side keeps | |
| # the libraries it was built against and a shared build stays honest. It | |
| # configures with the same arguments as this branch bar the analysis, | |
| # which changes the build rule rather than the compiler arguments and is | |
| # by far the slowest part, so the compiler cache carries all but the | |
| # handful of files that actually differ | |
| - name: Benchmark (Before + After) | |
| if: matrix.platform.benchmark && github.event_name == 'pull_request' | |
| shell: bash | |
| env: | |
| # The name of the base branch resolves to whatever its tip happens to | |
| # be by the time this runs, which for a job that waited in a queue, or | |
| # one re-run later on, is not what this branch was merged with. | |
| # Anything that landed in between would be measured and reported as | |
| # though this branch had caused it. The commit the event carries does | |
| # not move | |
| BENCHMARK_BASE: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| git fetch --no-tags --depth 1 origin "$BENCHMARK_BASE" | |
| echo "BENCHMARK_BASELINE_REVISION=$(git rev-parse --short "$BENCHMARK_BASE")" >> "$GITHUB_ENV" | |
| git checkout --force --detach "$BENCHMARK_BASE" | |
| cmake -S . -B ./build-base ${{ env.CONFIGURE_BASE_FLAGS }} \ | |
| -DSOURCEMETA_CORE_CLANG_TIDY:BOOL=OFF ${{ matrix.platform.options }} | |
| cmake --build ./build-base --config Release --parallel 4 --verbose --target benchmark | |
| git checkout --force --detach "$GITHUB_SHA" | |
| cmake --build ./build --config Release --verbose --target benchmark | |
| # A fork only gets a read only token, so it reports to the run summary | |
| # and stops there. The number a pull request carries is never zero, | |
| # which is what lets this pick between the two | |
| # See https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows | |
| - name: Benchmark Report GitHub Comment | |
| if: matrix.platform.benchmark && github.event_name == 'pull_request' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PULL_REQUEST: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request.number || '' }} | |
| run: > | |
| ${{ steps.python.outputs.python-path }} | |
| ./contrib/benchmark-compare.py | |
| "${{ matrix.platform.benchmark }}" | |
| ./build-base/benchmark.json | |
| ./build/benchmark.json | |
| "${{ env.PULL_REQUEST }}" | |
| # Saving on a cancelled run is pointless, as the cache would only hold | |
| # whatever the build got through before the interruption | |
| - name: Save ccache | |
| if: success() || failure() | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: ${{ github.workspace }}/.ccache | |
| key: ${{ steps.ccache.outputs.cache-primary-key }} |