.github/workflows/ci.yml

Source at 4d73c9795adca3e49eea74d1d2cbbbbdcbea0b6c

SHA-256: b5f997cc3330a0c1ea0c211742e2bcb8a7592041c25accd825abcd568b8ae7b0

name: Erlang checks

on:
  push:
    branches: [master]
  pull_request:
  workflow_dispatch:
  workflow_call:

permissions:
  contents: read

concurrency:
  group: erlang-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  ERL_FLAGS: '+S 4:4'

jobs:
  native:
    name: OTP 29 / tmux ${{ matrix.tmux }} / ${{ matrix.runner }}
    runs-on: ${{ matrix.runner }}
    timeout-minutes: 15
    strategy:
      fail-fast: false
      matrix:
        runner: [ubuntu-24.04, ubuntu-24.04-arm]
        tmux: ['3.3a', '3.8']
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: Read exact tool versions
        id: tools
        shell: bash
        run: |
          otp=$(awk '$1 == "erlang" {print $2}' .tool-versions)
          rebar=$(awk '$1 == "rebar" {print $2}' .tool-versions)
          test -n "$otp" && test -n "$rebar"
          printf 'otp=%s\nrebar=%s\n' "$otp" "$rebar" >> "$GITHUB_OUTPUT"
      - uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
        with:
          otp-version: ${{ steps.tools.outputs.otp }}
          rebar3-version: ${{ steps.tools.outputs.rebar }}
          version-type: strict
      - name: Install native dependencies
        run: |
          sudo timeout --kill-after=10 180 apt-get -o Acquire::Retries=3 update
          sudo timeout --kill-after=10 180 apt-get -o Acquire::Retries=3 install --yes --no-install-recommends \
            build-essential bison libevent-dev libncurses-dev pkg-config
      - name: Plan exact tmux build
        id: tmux
        env:
          TMUX_VERSION: ${{ matrix.tmux }}
        run: python3 tools/ci/build_tmux.py plan "$TMUX_VERSION"
      - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        id: tmux-cache
        with:
          path: ${{ steps.tmux.outputs.prefix }}
          key: ${{ steps.tmux.outputs.key }}
      - name: Validate or build tmux
        env:
          TMUX_VERSION: ${{ matrix.tmux }}
          CACHE_HIT: ${{ steps.tmux-cache.outputs.cache-hit }}
        run: python3 tools/ci/build_tmux.py prepare "$TMUX_VERSION"
      - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: _build/default/*_plt
          key: plt-${{ runner.os }}-${{ runner.arch }}-${{ steps.tools.outputs.otp }}-${{ steps.tools.outputs.rebar }}-${{ hashFiles('rebar.config', 'rebar.lock', 'apps/*/src/*.app.src') }}
      - name: Verify selected toolchain
        run: |
          erl -noshell -noinput -eval 'io:format("OTP ~s / ERTS ~s~n", [erlang:system_info(otp_release), erlang:system_info(version)]), halt().'
          rebar3 version
          "$LIBTMUX_TEST_TMUX" -V
          sha256sum "$LIBTMUX_TEST_TMUX"
      - name: Unit, generated-source and whitespace checks
        run: python3 tools/check.py mid
      - name: Compile, helper, Dialyzer, owned integration and archive consumer
        run: python3 tools/check.py outer
      - name: Prepare pinned source-package tools
        run: python3 tools/check_source_package.py --prepare
      - name: Build and install exact Hex source artifacts
        run: python3 tools/check_source_package.py
      - name: Save tmux only after owned runtime qualification
        if: steps.tmux-cache.outputs.cache-hit != 'true'
        uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: ${{ steps.tmux.outputs.prefix }}
          key: ${{ steps.tmux.outputs.key }}
      - name: Preserve check receipts and integration logs
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: checks-${{ matrix.runner }}-tmux-${{ matrix.tmux }}
          path: |
            _build/checks
            _build/test/logs
            _build/package-check/receipt.json
            _build/source-package-check
          if-no-files-found: warn
          retention-days: 14

  native-helper:
    name: Native helper sanitizers / ${{ matrix.runner }}
    runs-on: ${{ matrix.runner }}
    timeout-minutes: 10
    strategy:
      fail-fast: false
      matrix:
        runner: [ubuntu-24.04, ubuntu-24.04-arm]
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: Install instrumented native toolchain
        run: |
          sudo timeout --kill-after=10 180 apt-get -o Acquire::Retries=3 update
          sudo timeout --kill-after=10 180 apt-get -o Acquire::Retries=3 install --yes --no-install-recommends \
            clang-18 libclang-rt-18-dev
      - name: Check helper lifecycle and framed-input parser
        run: python3 tools/check_helper_native.py
      - name: Preserve sanitizer logs and crash inputs
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: native-helper-${{ matrix.runner }}
          path: _build/checks/helper-native
          if-no-files-found: warn
          retention-days: 14

  properties:
    name: Generated filter properties
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: Read exact tool versions
        id: tools
        run: |
          printf 'otp=%s\nrebar=%s\n' "$(awk '$1 == "erlang" {print $2}' .tool-versions)" "$(awk '$1 == "rebar" {print $2}' .tool-versions)" >> "$GITHUB_OUTPUT"
      - uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
        with:
          otp-version: ${{ steps.tools.outputs.otp }}
          rebar3-version: ${{ steps.tools.outputs.rebar }}
          version-type: strict
      - name: Prepare isolated test dependencies
        run: rebar3 as property,test get-deps
      - name: Run PropEr properties
        run: |
          mkdir -p _build/checks
          time rebar3 as property proper --dir property --numtests 300 2>&1 | tee _build/checks/properties.log
      - name: Preserve property counterexamples and log
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: generated-properties
          path: _build/checks/properties.log
          if-no-files-found: warn
          retention-days: 14

  regex:
    name: Portable regex reference engines
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    env:
      RUSTUP_TOOLCHAIN: '1.99.0'
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: Read exact tool versions
        id: tools
        run: |
          printf 'otp=%s\nrebar=%s\n' "$(awk '$1 == "erlang" {print $2}' .tool-versions)" "$(awk '$1 == "rebar" {print $2}' .tool-versions)" >> "$GITHUB_OUTPUT"
      - uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
        with:
          otp-version: ${{ steps.tools.outputs.otp }}
          rebar3-version: ${{ steps.tools.outputs.rebar }}
          version-type: strict
      - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
        with:
          node-version: '26.5.1'
          package-manager-cache: false
      - name: Prepare reference backends
        run: |
          rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal
          cargo build --manifest-path tools/regex-conformance/Cargo.toml --locked --target-dir _build/regex-conformance
          rebar3 compile
      - name: Check fixture drift and differential matches
        run: |
          time python3 tools/regex-conformance/generate_fixture.py --check
          time python3 tools/check_regex.py
      - name: Preserve reference engine receipt
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: regex-conformance
          path: _build/checks/regex.json
          if-no-files-found: warn
          retention-days: 14

  documentation:
    name: Native API browser and guide corpus
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          # Rendered ADR links are checked against their pinned source commits.
          fetch-depth: 0
          persist-credentials: false
      - name: Read exact tool versions
        id: tools
        run: |
          printf 'otp=%s\nrebar=%s\n' "$(awk '$1 == "erlang" {print $2}' .tool-versions)" "$(awk '$1 == "rebar" {print $2}' .tool-versions)" >> "$GITHUB_OUTPUT"
      - uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
        with:
          otp-version: ${{ steps.tools.outputs.otp }}
          rebar3-version: ${{ steps.tools.outputs.rebar }}
          version-type: strict
      - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: _build/tools/ex_doc
          key: exdoc-${{ hashFiles('tools/docs-tool.json') }}
      - name: Prepare pinned documentation renderer
        run: python3 tools/build_docs.py --prepare
      - name: Compile native documentation chunks
        run: rebar3 compile
      - name: Verify public contracts and guide corpus
        run: |
          escript tools/check_api_docs.escript > _build/api-docs.json
          escript tools/generate_reference.escript --check
          python3 tools/check_docs.py
      - name: Render warnings-free API browser
        run: python3 tools/build_docs.py
      - name: Preserve browser and documentation receipts
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: native-api-browser
          include-hidden-files: true
          path: |
            _build/docs/core
            _build/checks
            _build/api-docs.json
          if-no-files-found: warn
          retention-days: 14