Skip to content

Commit b3d2d9f

Browse files
committed
Refresh codebase
I copied most of these changes from many other projects I maintain * Update all dependencies * Set MSRV * Add `justfile` similar to many other FOSS projects to simplify development * Update README * Add pre-commit-config to allow https://pre-commit.com/hooks.html once enabled * Consolidate testing in the `justfile` - this way CI tests can be run locally with the same command * Add ability to auto-publish directly from github on release (needs tokens) * add dependabot
1 parent 0cffc73 commit b3d2d9f

10 files changed

+245
-53
lines changed

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: cargo
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
time: "02:00"
13+
open-pull-requests-limit: 10

.github/workflows/ci.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
- trying
9+
- release/**
10+
pull_request:
11+
branches: [ main ]
12+
release:
13+
types: [ published ]
14+
workflow_dispatch:
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
jobs:
21+
test:
22+
name: Test
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: taiki-e/install-action@v2
26+
with: { tool: just }
27+
- uses: actions/checkout@v4
28+
- name: Ensure this crate has not yet been published (on release)
29+
if: github.event_name == 'release'
30+
run: just check-if-published
31+
- uses: Swatinem/rust-cache@v2
32+
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
33+
- run: just ci-test
34+
- name: Check semver
35+
uses: obi1kenobi/cargo-semver-checks-action@v2
36+
37+
msrv:
38+
name: Test MSRV
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: taiki-e/install-action@v2
42+
with: { tool: just }
43+
- uses: actions/checkout@v4
44+
- uses: Swatinem/rust-cache@v2
45+
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
46+
- name: Read crate metadata
47+
id: metadata
48+
run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
49+
- name: Install Rust
50+
uses: dtolnay/rust-toolchain@stable
51+
with:
52+
toolchain: ${{ steps.metadata.outputs.rust-version }}
53+
- run: just ci-test-msrv
54+
55+
publish:
56+
name: Publish to crates.io
57+
if: startsWith(github.ref, 'refs/tags/')
58+
needs: [ test, msrv ]
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Publish to crates.io
63+
run: cargo publish
64+
env:
65+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/dependabot.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions: write-all
5+
6+
jobs:
7+
dependabot:
8+
runs-on: ubuntu-latest
9+
if: github.actor == 'dependabot[bot]'
10+
steps:
11+
- name: Dependabot metadata
12+
id: metadata
13+
uses: dependabot/fetch-metadata@v2.3.0
14+
with:
15+
github-token: "${{ secrets.GITHUB_TOKEN }}"
16+
- name: Approve Dependabot PRs
17+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
18+
run: gh pr review --approve "$PR_URL"
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
- name: Enable auto-merge for Dependabot PRs
23+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
24+
run: gh pr merge --auto --squash "$PR_URL"
25+
env:
26+
PR_URL: ${{github.event.pull_request.html_url}}
27+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/rust.yml

-30
This file was deleted.

.pre-commit-config.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
exclude: '.+/tsconfig.json'
11+
- id: check-shebang-scripts-are-executable
12+
exclude: '.+\.rs' # would be triggered by #![some_attribute]
13+
- id: check-symlinks
14+
- id: check-toml
15+
- id: check-yaml
16+
args: [ --allow-multiple-documents ]
17+
- id: destroyed-symlinks
18+
- id: end-of-file-fixer
19+
- id: mixed-line-ending
20+
args: [ --fix=lf ]
21+
- id: trailing-whitespace
22+
23+
- repo: local
24+
hooks:
25+
- id: cargo-fmt
26+
name: Rust Format
27+
description: "Automatically format Rust code with cargo fmt"
28+
entry: sh -c "cargo fmt --all"
29+
language: rust
30+
pass_filenames: false

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<a name="v0.4.2"></a>
2+
### v0.4.2 (2025-03-03)
3+
* Update dependencies, set MSRV to 1.78, and some internal cleanup
4+
15
<a name="v0.4.1"></a>
26
### v0.4.1 (2022-12-08)
37
* Add `Bounds::from` for `(f64, f64, f64, f64)` tuple. Same for `f32` and `i32`.

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tilejson"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
description = "Library for serializing the TileJSON file format"
55
authors = [
66
"Stepan Kuzmin <to.stepan.kuzmin@gmail.com>",
@@ -14,12 +14,13 @@ repository = "https://github.com/georust/tilejson"
1414
readme = "README.md"
1515
keywords = ["maplibre", "mapbox", "tilejson", "serde"]
1616
categories = ["science::geo"]
17+
rust-version = "1.78"
1718

1819
[dependencies]
1920
serde = { version = "1", features = ["derive"] }
2021
serde_json = "1"
21-
serde_tuple = "0.5"
22-
thiserror = "1"
22+
serde_tuple = "1.1.0"
23+
thiserror = "2"
2324

2425
[lints.rust]
2526
unsafe_code = "forbid"

README.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# tilejson
22

3-
[![Build Status](https://github.com/georust/tilejson/workflows/Run%20tests/badge.svg)](https://github.com/georust/tilejson/actions)
4-
[![tilejson on crates.io](https://img.shields.io/crates/v/tilejson.svg)](https://crates.io/crates/tilejson)
5-
[![API Docs](https://docs.rs/tilejson/badge.svg)](https://docs.rs/tilejson)
3+
[![GitHub](https://img.shields.io/badge/github-tilejson-8da0cb?logo=github)](https://github.com/georust/tilejson)
4+
[![crates.io version](https://img.shields.io/crates/v/tilejson.svg)](https://crates.io/crates/tilejson)
5+
[![docs.rs docs](https://docs.rs/tilejson/badge.svg)](https://docs.rs/tilejson)
6+
[![license](https://img.shields.io/crates/l/tilejson.svg)](https://github.com/georust/tilejson/blob/main/LICENSE-APACHE)
7+
[![CI build](https://github.com/georust/tilejson/actions/workflows/ci.yml/badge.svg)](https://github.com/georust/tilejson/actions)
68

79
`tilejson` is a crate for serializing/deserializing the [TileJSON](https://github.com/mapbox/tilejson-spec) format — an open standard for representing map metadata.
810

@@ -55,17 +57,24 @@ fn main() {
5557

5658
Contributions are welcome! Have a look at the [issues](https://github.com/georust/tilejson/issues), and open a pull request if you'd like to add an algorithm or some functionality.
5759

60+
## Development
61+
62+
* This project is easier to develop with [just](https://github.com/casey/just#readme), a modern alternative to `make`.
63+
Install it with `cargo install just`.
64+
* To get a list of available commands, run `just`.
65+
* To run tests, use `just test`.
66+
5867
## License
5968

6069
Licensed under either of
6170

62-
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
63-
- MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
64-
65-
at your option.
71+
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
72+
* MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/licenses/MIT>)
73+
at your option.
6674

6775
### Contribution
6876

69-
Unless you explicitly state otherwise, any contribution intentionally submitted
70-
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
77+
Unless you explicitly state otherwise, any contribution intentionally
78+
submitted for inclusion in the work by you, as defined in the
79+
Apache-2.0 license, shall be dual licensed as above, without any
7180
additional terms or conditions.

justfile

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env just --justfile
2+
3+
@_default:
4+
just --list
5+
6+
# Clean all build artifacts
7+
clean:
8+
cargo clean
9+
rm -f Cargo.lock
10+
11+
# Update dependencies, including breaking changes
12+
update:
13+
cargo +nightly -Z unstable-options update --breaking
14+
cargo update
15+
16+
# Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
17+
msrv:
18+
cargo msrv find --write-msrv
19+
20+
# Run cargo clippy
21+
clippy:
22+
cargo clippy --workspace --all-targets -- -D warnings
23+
24+
# Test code formatting
25+
test-fmt:
26+
cargo fmt --all -- --check
27+
28+
# Run cargo fmt
29+
fmt:
30+
cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate
31+
32+
# Build and open code documentation
33+
docs:
34+
cargo doc --no-deps --open
35+
36+
# Quick compile
37+
check:
38+
RUSTFLAGS='-D warnings' cargo check
39+
40+
# Run all tests
41+
test:
42+
RUSTFLAGS='-D warnings' cargo test
43+
44+
# Test documentation
45+
test-doc:
46+
cargo test --doc
47+
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
48+
49+
rust-info:
50+
rustc --version
51+
cargo --version
52+
53+
# Run all tests as expected by CI
54+
ci-test: rust-info test-fmt clippy check test test-doc
55+
56+
# Run minimal subset of tests to ensure compatibility with MSRV
57+
ci-test-msrv: rust-info check test
58+
59+
# Verify that the current version of the crate is not the same as the one published on crates.io
60+
check-if-published:
61+
#!/usr/bin/env bash
62+
LOCAL_VERSION="$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')"
63+
echo "Detected crate version: $LOCAL_VERSION"
64+
CRATE_NAME="$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')"
65+
echo "Detected crate name: $CRATE_NAME"
66+
PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')"
67+
echo "Published crate version: $PUBLISHED_VERSION"
68+
if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
69+
echo "ERROR: The current crate version has already been published."
70+
exit 1
71+
else
72+
echo "The current crate version has not yet been published."
73+
fi

0 commit comments

Comments
 (0)