Skip to content

Commit

Permalink
fix: ci (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored Apr 3, 2024
1 parent e2bc55d commit 4b5efc2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cargo:
- name: "Clippy"
cmd: clippy
args: --workspace --all-features --tests -- -D clippy::all -W clippy::style
args: --workspace --all-features --all-targets -- -D warnings
rust: stable
- name: "Formatting"
cmd: fmt
Expand Down
4 changes: 1 addition & 3 deletions crates/analytics/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use chrono::{NaiveDateTime, Utc};
pub const TIMESTAMP_FORMAT: &str = "%Y-%m-%d %H:%M:%S";

pub fn now() -> NaiveDateTime {
let now = Utc::now();
NaiveDateTime::from_timestamp_opt(now.timestamp(), now.timestamp_subsec_nanos())
.expect("invalid timestamp")
Utc::now().naive_utc()
}

pub fn format(t: &NaiveDateTime) -> String {
Expand Down
19 changes: 10 additions & 9 deletions crates/future/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ pub trait FutureExt {
/// # async fn example() {
/// let token = CancellationToken::new();
///
/// let answer = async {
/// tokio::time::sleep(Duration::from_millis(500)).await;
/// 42
/// }
/// .with_cancellation(token.clone())
/// .on_cancel(async {
/// // Run some cleanup routine...
/// })
/// .spawn("");
/// let answer = tokio::task::spawn(
/// async {
/// tokio::time::sleep(Duration::from_millis(500)).await;
/// 42
/// }
/// .with_cancellation(token.clone())
/// .on_cancel(async {
/// // Run some cleanup routine...
/// }),
/// );
///
/// tokio::time::sleep(Duration::from_millis(100)).await;
/// token.cancel();
Expand Down
2 changes: 1 addition & 1 deletion examples/geoblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn resolve_ip(_addr: IpAddr) -> geoip2::City<'static> {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resolver: LocalResolver = LocalResolver::new(Some(|caller| resolve_ip(caller)), None);
let resolver: LocalResolver = LocalResolver::new(Some(resolve_ip), None);
// The number after the colon is the ISO code of the subdivision when you don't
// want to block the whole country.
let blocked_countries = vec!["CU:12".into(), "IR".into(), "KP".into()];
Expand Down
25 changes: 22 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ clean:
@echo '==> Cleaning project target/*'
cargo clean

# Make sure we are running the right submodule versions
update-submodules:
git submodule update --init --recursive

# Lint the project for any quality issues
lint: check fmt clippy commit-check
lint: clippy fmt commit-check

unit: update-submodules lint test test-all

devloop: unit fmt-imports

# Run project linter
clippy:
Expand All @@ -53,7 +61,7 @@ clippy:

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

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

fmt-imports:
#!/bin/bash
set -euo pipefail

if command -v cargo-fmt >/dev/null; then
echo '==> Running rustfmt'
cargo +nightly fmt -- --config group_imports=StdExternalCrate,imports_granularity=One
else
echo '==> rustfmt not found in PATH, skipping'
fi

# Run commit checker
commit-check:
#!/bin/bash
Expand Down

0 comments on commit 4b5efc2

Please sign in to comment.