Skip to content

Commit 4b5efc2

Browse files
authored
fix: ci (#15)
1 parent e2bc55d commit 4b5efc2

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
cargo:
2929
- name: "Clippy"
3030
cmd: clippy
31-
args: --workspace --all-features --tests -- -D clippy::all -W clippy::style
31+
args: --workspace --all-features --all-targets -- -D warnings
3232
rust: stable
3333
- name: "Formatting"
3434
cmd: fmt

crates/analytics/src/time.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use chrono::{NaiveDateTime, Utc};
33
pub const TIMESTAMP_FORMAT: &str = "%Y-%m-%d %H:%M:%S";
44

55
pub fn now() -> NaiveDateTime {
6-
let now = Utc::now();
7-
NaiveDateTime::from_timestamp_opt(now.timestamp(), now.timestamp_subsec_nanos())
8-
.expect("invalid timestamp")
6+
Utc::now().naive_utc()
97
}
108

119
pub fn format(t: &NaiveDateTime) -> String {

crates/future/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,16 @@ pub trait FutureExt {
174174
/// # async fn example() {
175175
/// let token = CancellationToken::new();
176176
///
177-
/// let answer = async {
178-
/// tokio::time::sleep(Duration::from_millis(500)).await;
179-
/// 42
180-
/// }
181-
/// .with_cancellation(token.clone())
182-
/// .on_cancel(async {
183-
/// // Run some cleanup routine...
184-
/// })
185-
/// .spawn("");
177+
/// let answer = tokio::task::spawn(
178+
/// async {
179+
/// tokio::time::sleep(Duration::from_millis(500)).await;
180+
/// 42
181+
/// }
182+
/// .with_cancellation(token.clone())
183+
/// .on_cancel(async {
184+
/// // Run some cleanup routine...
185+
/// }),
186+
/// );
186187
///
187188
/// tokio::time::sleep(Duration::from_millis(100)).await;
188189
/// token.cancel();

examples/geoblock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn resolve_ip(_addr: IpAddr) -> geoip2::City<'static> {
3434

3535
#[tokio::main]
3636
async fn main() -> Result<(), Box<dyn std::error::Error>> {
37-
let resolver: LocalResolver = LocalResolver::new(Some(|caller| resolve_ip(caller)), None);
37+
let resolver: LocalResolver = LocalResolver::new(Some(resolve_ip), None);
3838
// The number after the colon is the ISO code of the subdivision when you don't
3939
// want to block the whole country.
4040
let blocked_countries = vec!["CU:12".into(), "IR".into(), "KP".into()];

justfile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ clean:
4343
@echo '==> Cleaning project target/*'
4444
cargo clean
4545

46+
# Make sure we are running the right submodule versions
47+
update-submodules:
48+
git submodule update --init --recursive
49+
4650
# Lint the project for any quality issues
47-
lint: check fmt clippy commit-check
51+
lint: clippy fmt commit-check
52+
53+
unit: update-submodules lint test test-all
54+
55+
devloop: unit fmt-imports
4856

4957
# Run project linter
5058
clippy:
@@ -53,7 +61,7 @@ clippy:
5361

5462
if command -v cargo-clippy >/dev/null; then
5563
echo '==> Running clippy'
56-
cargo clippy --workspace --all-features --tests -- -D clippy::all -W clippy::style
64+
cargo clippy --workspace --all-features --all-targets -- -D warnings
5765
else
5866
echo '==> clippy not found in PATH, skipping'
5967
echo ' ^^^^^^ To install `rustup component add clippy`, see https://github.com/rust-lang/rust-clippy for details'
@@ -66,12 +74,23 @@ fmt:
6674

6775
if command -v cargo-fmt >/dev/null; then
6876
echo '==> Running rustfmt'
69-
cargo +nightly fmt --all -- --check
77+
cargo +nightly fmt --all
7078
else
7179
echo '==> rustfmt not found in PATH, skipping'
7280
echo ' ^^^^^^ To install `rustup component add rustfmt`, see https://github.com/rust-lang/rustfmt for details'
7381
fi
7482

83+
fmt-imports:
84+
#!/bin/bash
85+
set -euo pipefail
86+
87+
if command -v cargo-fmt >/dev/null; then
88+
echo '==> Running rustfmt'
89+
cargo +nightly fmt -- --config group_imports=StdExternalCrate,imports_granularity=One
90+
else
91+
echo '==> rustfmt not found in PATH, skipping'
92+
fi
93+
7594
# Run commit checker
7695
commit-check:
7796
#!/bin/bash

0 commit comments

Comments
 (0)