pprof 0.15.0

An internal perf tools for rust programs.
on: [push, pull_request]

name: build

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

jobs:
  lint:
    name: Format and Clippy
    runs-on: ubuntu-latest

    steps:
      - name: Checkout sources
        uses: actions/checkout@v3

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1.0.7
        with:
          profile: minimal
          toolchain: 1.74.0
          override: true
          components: rustfmt, clippy

      - name: Install protobuf compiler
        run: sudo apt-get install -y protobuf-compiler

      - name: Run cargo fmt
        uses: actions-rs/cargo@v1.0.3
        with:
          command: fmt
          args: --all -- --check

      - name: Remove pre-generated prost files to force regeneration
        run: rm proto/*.rs

      - name: Run cargo clippy prost
        uses: actions-rs/cargo@v1.0.3
        with:
          command: clippy
          args: --all-targets --features flamegraph,prost-codec -- -D warnings

      - name: Run cargo clippy protobuf
        uses: actions-rs/cargo@v1.0.3
        with:
          command: clippy
          args: --all-targets --features flamegraph,protobuf-codec -- -D warnings

      - name: Check if the prost file committed to git is up-to-date
        run: |
          git diff --no-ext-diff --exit-code

  build:
    name: Build
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        toolchain: [stable, nightly, 1.74.0]
        target:
          [
            x86_64-unknown-linux-gnu,
            aarch64-unknown-linux-gnu,
            x86_64-unknown-linux-musl,
            x86_64-apple-darwin,
            aarch64-apple-darwin,
          ]
        exclude:
          - os: ubuntu-latest
            target: x86_64-apple-darwin
          - os: ubuntu-latest
            target: aarch64-apple-darwin
          - os: macos-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-unknown-linux-gnu
          - os: macos-latest
            target: x86_64-unknown-linux-musl
      fail-fast: false
    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout sources
        uses: actions/checkout@v3

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1.0.7
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }}
          target: ${{ matrix.target }}
          override: true

      - name: Run cargo build prost
        uses: actions-rs/cargo@v1.0.3
        with:
          command: build
          args: --features flamegraph,prost-codec --target ${{ matrix.target }}

      - name: Run cargo build protobuf
        uses: actions-rs/cargo@v1.0.3
        with:
          command: build
          args: --features flamegraph,protobuf-codec --target ${{ matrix.target }}

      - name: Run cargo build frame pointer
        if: ${{ matrix.toolchain == 'nightly' && matrix.os == 'ubuntu-latest' }}
        uses: actions-rs/cargo@v1.0.3
        with:
          command: build
          args: --no-default-features --features frame-pointer --target ${{ matrix.target }}

  test:
    name: Test
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        toolchain: [stable, nightly]
        target:
          [
            x86_64-unknown-linux-gnu,
            x86_64-unknown-linux-musl,
            x86_64-apple-darwin,
          ]
        exclude:
          - os: ubuntu-latest
            target: x86_64-apple-darwin
          - os: macos-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: x86_64-unknown-linux-musl
      fail-fast: false
    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout sources
        uses: actions/checkout@v3

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1.0.7
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }}
          target: ${{ matrix.target }}
          override: true

      - if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
        name: Install musl
        run: sudo apt install musl-tools

      - name: Run cargo test prost
        uses: actions-rs/cargo@v1.0.3
        with:
          command: test
          args: --features flamegraph,prost-codec --target ${{ matrix.target }}

      - name: Run cargo test protobuf
        uses: actions-rs/cargo@v1.0.3
        with:
          command: test
          args: --features flamegraph,protobuf-codec --target ${{ matrix.target }}