Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- run: just env-info
- run: just fmt
- run: just test-fmt
- run: just clippy
- run: just check
- run: just check-doc
Expand Down
55 changes: 34 additions & 21 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set shell := ["bash", "-c"]
PGPARAMS := ""
PGPORT := "5411"

export DATABASE_URL := "postgres://postgres:postgres@localhost:" + PGPORT + "/db" + (if PGPARAMS != "" { "?" + PGPARAMS } else { "" })
export DATABASE_URL := ("postgres://postgres:postgres@localhost:" + PGPORT + "/db" + (if PGPARAMS != "" { "?" + PGPARAMS } else { "" }))
Comment thread
nyurik marked this conversation as resolved.
export CARGO_TERM_COLOR := "always"

# Set AWS variables for testing pmtiles from S3
Expand All @@ -22,7 +22,7 @@ export AWS_REGION := "eu-central-1"
dockercompose := `if docker-compose --version &> /dev/null; then echo "docker-compose"; else echo "docker compose"; fi`

@_default:
{{just_executable()}} --list --unsorted
{{just_executable()}} --list

# Start Martin server
run *ARGS="--webui enable-for-all":
Expand Down Expand Up @@ -261,31 +261,45 @@ print-conn-str:
# Run cargo fmt and cargo clippy
lint: fmt clippy

# Run cargo fmt
fmt:
# Test code formatting
test-fmt:
cargo fmt --all -- --check

# Reformat all code `cargo fmt`. If nightly is available, use it for better results
fmt:
#!/usr/bin/env bash
set -euo pipefail
if rustup component list --toolchain nightly | grep rustfmt &> /dev/null; then
echo 'Reformatting Rust code using nightly Rust fmt to sort imports'
cargo +nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate
else
echo 'Reformatting Rust with the stable cargo fmt. Install nightly with `rustup install nightly` for better results'
cargo fmt --all
fi

# Reformat markdown files using markdownlint-cli2
fmt-md:
docker run -it --rm -v $PWD:/workdir davidanson/markdownlint-cli2 --config /workdir/.github/files/config.markdownlint-cli2.jsonc --fix

# Reformat all SQL files using docker
fmt-sql:
docker run -it --rm -v $PWD:/sql sqlfluff/sqlfluff:latest fix --dialect=postgres --exclude-rules=AL07,LT05,LT12
# Run Nightly cargo fmt, ordering imports
fmt2:
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate

# Run cargo check
check:
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin-tile-utils
RUSTFLAGS='-D warnings' cargo check --all-targets -p mbtiles
RUSTFLAGS='-D warnings' cargo check --all-targets -p mbtiles --no-default-features
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features --features fonts
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features --features mbtiles
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features --features pmtiles
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features --features postgres
RUSTFLAGS='-D warnings' cargo check --all-targets -p martin --no-default-features --features sprites
#!/usr/bin/env bash
set -euo pipefail
export RUSTFLAGS='-D warnings'
cargo check --all-targets -p martin-tile-utils
cargo check --all-targets -p mbtiles
cargo check --all-targets -p mbtiles --no-default-features
cargo check --all-targets -p martin
cargo check --all-targets -p martin --no-default-features
cargo check --all-targets -p martin --no-default-features --features fonts
cargo check --all-targets -p martin --no-default-features --features mbtiles
cargo check --all-targets -p martin --no-default-features --features pmtiles
cargo check --all-targets -p martin --no-default-features --features postgres
cargo check --all-targets -p martin --no-default-features --features sprites

# Verify doc build
check-doc:
Expand All @@ -306,12 +320,11 @@ update:
cargo update

# A few useful tests to run locally to simulate CI
ci-test: env-info restart fmt clippy check-doc test check
ci-test: env-info restart test-fmt clippy check-doc test check
Comment thread
CommanderStorm marked this conversation as resolved.

# Get environment info
[private]
# Print environment info
env-info:
@echo "OS is {{os()}}, arch is {{arch()}}"
@echo "Running on {{os()}} / {{arch()}}"
{{just_executable()}} --version
rustc --version
cargo --version
Expand Down
7 changes: 3 additions & 4 deletions martin/src/args/root.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::path::PathBuf;

use clap::{
Parser,
builder::{Styles, styling::AnsiColor},
};
use clap::Parser;
use clap::builder::Styles;
use clap::builder::styling::AnsiColor;
use log::warn;

use crate::MartinError::ConfigAndConnectionsError;
Expand Down
7 changes: 3 additions & 4 deletions martin/src/bin/martin-cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ use std::time::Duration;
use actix_http::error::ParseError;
use actix_http::test::TestRequest;
use actix_web::http::header::{ACCEPT_ENCODING, AcceptEncoding, Header as _};
use clap::{
Parser,
builder::{Styles, styling::AnsiColor},
};
use clap::Parser;
use clap::builder::Styles;
use clap::builder::styling::AnsiColor;
use futures::TryStreamExt;
use futures::stream::{self, StreamExt};
use log::{debug, error, info, log_enabled};
Expand Down
6 changes: 4 additions & 2 deletions martin/src/cog/model.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::{fs::File, path::Path};
use std::fs::File;
use std::path::Path;

use tiff::{decoder::Decoder, tags::Tag};
use tiff::decoder::Decoder;
use tiff::tags::Tag;

use super::CogError;

Expand Down
6 changes: 4 additions & 2 deletions martin/src/cog/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,16 @@ fn get_origin(

#[cfg(test)]
mod tests {
use std::{fs::File, path::PathBuf};
use std::fs::File;
use std::path::PathBuf;

use insta::assert_yaml_snapshot;
use martin_tile_utils::TileCoord;
use rstest::rstest;
use tiff::decoder::Decoder;

use crate::cog::{model::ModelInfo, source::get_tile_idx};
use crate::cog::model::ModelInfo;
use crate::cog::source::get_tile_idx;

#[test]
fn can_calc_tile_idx() {
Expand Down
2 changes: 1 addition & 1 deletion martin/src/fonts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fmt::Debug;
use std::path::PathBuf;
Expand All @@ -12,7 +13,6 @@ use pbf_font_tools::protobuf::Message;
use pbf_font_tools::{Fontstack, Glyphs, PbfFontError, render_sdf_glyph};
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

use crate::OptOneMany;

Expand Down
3 changes: 2 additions & 1 deletion martin/src/pmtiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use async_trait::async_trait;
use log::{trace, warn};
use martin_tile_utils::{Encoding, Format, TileCoord, TileInfo};
use pmtiles::async_reader::AsyncPmTilesReader;
use pmtiles::aws_sdk_s3::{Client as S3Client, config::Builder as S3ConfigBuilder};
use pmtiles::aws_sdk_s3::Client as S3Client;
use pmtiles::aws_sdk_s3::config::Builder as S3ConfigBuilder;
use pmtiles::cache::{DirCacheResult, DirectoryCache};
use pmtiles::reqwest::Client;
use pmtiles::{AwsS3Backend, Compression, Directory, HttpBackend, MmapBackend, TileType};
Expand Down
2 changes: 1 addition & 1 deletion martin/src/source.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::fmt::Debug;

use actix_web::error::ErrorNotFound;
Expand All @@ -6,7 +7,6 @@ use dashmap::DashMap;
use log::debug;
use martin_tile_utils::{TileCoord, TileInfo};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tilejson::TileJSON;

use crate::MartinResult;
Expand Down
3 changes: 1 addition & 2 deletions martin/src/sprites/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use std::fmt::Debug;
use std::path::PathBuf;

Expand Down
6 changes: 3 additions & 3 deletions martin/src/srv/styles.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::styles::StyleSources;
use actix_web::http::header::ContentType;
use actix_web::middleware;
use actix_web::web::{Data, Path};
use actix_web::{HttpResponse, route};
use actix_web::{HttpResponse, middleware, route};
use log::error;
use serde::Deserialize;

use crate::styles::StyleSources;

#[derive(Deserialize, Debug)]
struct StyleRequest {
style_id: String,
Expand Down
10 changes: 5 additions & 5 deletions martin/src/styles/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use dashmap::{DashMap, Entry};
use log::{info, warn};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap};
use std::fmt::Debug;
use std::path::{Path, PathBuf};

use dashmap::{DashMap, Entry};
use log::{info, warn};
use serde::{Deserialize, Serialize};

use crate::config::UnrecognizedValues;
use crate::file_config::{ConfigExtras, FileConfigEnum, FileError, FileResult};

Expand Down Expand Up @@ -190,9 +191,8 @@ fn is_hidden(entry: &walkdir::DirEntry) -> bool {

#[cfg(test)]
mod tests {
use crate::file_config::FileConfigSrc;

use super::*;
use crate::file_config::FileConfigSrc;
#[test]
fn test_add_single_source() {
use std::fs::File;
Expand Down
3 changes: 2 additions & 1 deletion mbtiles/src/bin/mbtiles.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::{Path, PathBuf};

use clap::builder::{Styles, styling::AnsiColor};
use clap::builder::Styles;
use clap::builder::styling::AnsiColor;
use clap::{Parser, Subcommand};
use log::error;
use mbtiles::{
Expand Down
4 changes: 0 additions & 4 deletions rustfmt.toml

This file was deleted.