prometheus-client 0.25.2

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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}
          lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}

      # Install prometheus_client python library.
      - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}
          lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}

      # Install prometheus_client python library.
      - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # 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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
        with:
          toolchain: stable
          components: clippy
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
        with:
          # Don't let pull request branches evict the master cache.
          save-if: ${{ github.ref == 'refs/heads/master' }}
          lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}

      - 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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # 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@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # 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 }}