prometheus-client 0.25.1

Open Metrics client library allowing users to natively instrument applications.
Documentation
on:
  push:
    branches:
      - master
    tags:
      - "v*"
  pull_request:

name: Continuous integration

permissions:
  contents: read

concurrency:
  # GitHub concurrency keeps at most one running and one pending run per group.
  # Use ref_name for PRs so new commits cancel older PR runs on the same PR,
  # but key pushes by ref and SHA so postsubmit runs do not cancel each other,
  # and a release tag does not queue behind the master run for the same commit.
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.ref_name) || format('push-{0}-{1}', github.ref, github.sha) }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - name: Install Protoc
        uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}

      # Install prometheus_client python library.
      - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
        with:
          python-version: '3.x'
      - run: pip3 install prometheus_client

      - run: cargo check --locked

      - run: cargo test --locked --benches --all-features

  test:
    name: Test Suite
    runs-on: ubuntu-latest
    steps:
      - name: Install Protoc
        uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}

      # Install prometheus_client python library.
      - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
        with:
          python-version: '3.x'
      - run: pip3 install prometheus_client

      - run: cargo test --locked --all --all-features

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          toolchain: stable
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - name: Install Protoc
        uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          toolchain: stable
          components: clippy
      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}

      - run: cargo clippy --locked --workspace --all-targets -- -D warnings

  check-rustdoc-links:
    name: Check rustdoc intra-doc links
    runs-on: ubuntu-latest
    steps:
      - name: Install Protoc
        uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          toolchain: stable
      - run: cargo doc --locked --verbose --workspace --no-deps --document-private-items --all-features
        env:
          RUSTDOCFLAGS: "--deny broken_intra_doc_links"

  cross-compile:
    name: Cross compile
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - armv7-unknown-linux-gnueabihf
          - powerpc-unknown-linux-gnu
          - powerpc64-unknown-linux-gnu
          - wasm32-unknown-unknown
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
        with:
          target: ${{ matrix.target }}
          toolchain: stable

      # Note that this does not test the `protobuf` feature (for now). See reasoning in https://github.com/prometheus/client_rust/pull/98/.
      - run: cargo check --locked --target=${{ matrix.target }}