diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 52dc0605..04ad50b7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,9 +9,54 @@ on: env: CARGO_TERM_COLOR: always # Pinned toolchain for linting and benchmarks - ACTIONS_LINTS_TOOLCHAIN: 1.47.0 + ACTIONS_LINTS_TOOLCHAIN: 1.53.0 + EXTRA_FEATURES: "protobuf push process" jobs: + tests-stable: + name: "Tests, stable toolchain" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: "stable" + default: true + - name: cargo build + run: cargo build + - name: cargo test + run: cargo test + - name: cargo test (extra features) + run: cargo test --no-default-features --features="${{ env['EXTRA_FEATURES'] }}" + - name: cargo package + run : cargo package && cargo package --manifest-path static-metric/Cargo.toml + tests-other-channels: + name: "Tests, unstable toolchain" + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + channel: + - "beta" + - "nightly" + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.channel }} + default: true + - name: cargo build + run: cargo build + - name: cargo test + run: cargo test + - name: cargo build (static-metric) + run: cargo build -p prometheus-static-metric --examples --no-default-features --features="${{ env['EXTRA_FEATURES'] }}" + - name: cargo test (static-metric) + run: cargo test -p prometheus-static-metric --no-default-features --features="${{ env['EXTRA_FEATURES'] }}" linting: name: "Lints, pinned toolchain" runs-on: ubuntu-latest @@ -21,15 +66,13 @@ jobs: - name: Install toolchain uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }} + toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }} default: true components: rustfmt, clippy - name: cargo fmt (check) run: cargo fmt --all -- --check -l - name: cargo clippy - run: cargo clippy --all -- -D clippy - - name: cargo package - run : cargo package && cargo package --manifest-path static-metric/Cargo.toml + run: cargo clippy --all -- -D clippy::all criterion: name: "Benchmarks (criterion)" runs-on: ubuntu-latest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 843aa7d0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: rust -sudo: false - -os: - - linux - - osx - -addons: - apt: - packages: - - gcc-multilib - -env: - matrix: - - FEATURES="protobuf push process" - - FEATURES="" - global: - - RUSTFLAGS=--deny=warnings - - ARCH=i686 - -# Must be present for matrix. -rust: - -matrix: - fast_finish: true - include: - - rust: nightly - - rust: nightly - env: FEATURES="nightly protobuf push process" - - rust: beta - - rust: stable - allow_failures: - - rust: nightly - -script: - - cargo test --no-default-features --features="$FEATURES" - - | - if [ $TRAVIS_RUST_VERSION = 'nightly' ]; then - cargo build -p prometheus-static-metric --examples --no-default-features --features="$FEATURES" - cargo test -p prometheus-static-metric --no-default-features --features="$FEATURES" - fi diff --git a/src/registry.rs b/src/registry.rs index 3aa0d22e..d204d8e0 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -93,7 +93,7 @@ impl RegistryCore { let mut id_set = Vec::new(); let mut collector_id: u64 = 0; for desc in c.desc() { - if id_set.iter().find(|id| **id == desc.id).is_none() { + if !id_set.iter().any(|id| *id == desc.id) { id_set.push(desc.id); collector_id = collector_id.wrapping_add(desc.id); } diff --git a/static-metric/src/util.rs b/static-metric/src/util.rs index 2a41c6a9..182b8685 100644 --- a/static-metric/src/util.rs +++ b/static-metric/src/util.rs @@ -9,8 +9,8 @@ pub fn is_local_metric(metric_type: Ident) -> bool { pub fn to_non_local_metric_type(metric_type: Ident) -> Ident { let metric_type_str = metric_type.to_string(); - if metric_type_str.starts_with("Local") { - Ident::new(&metric_type_str[5..], Span::call_site()) + if let Some(stripped) = metric_type_str.strip_prefix("Local") { + Ident::new(stripped, Span::call_site()) } else { metric_type }