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
19 changes: 16 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
indent_size = 2

[*.{yml,yaml}]
indent_size = 2

[LICENSE-{APACHE,MIT}]
indent_size = unset

[*.lock]
indent_size = unset
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
Expand All @@ -31,36 +31,38 @@ jobs:
name: Test MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with: { tool: 'just' }
with: { tool: 'just,cargo-binstall,cargo-minimal-versions,cargo-hack' }
Comment thread
nyurik marked this conversation as resolved.
Resolved
- name: Read MSRV
id: msrv
run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT
- name: Install nightly Rust for minimal dependency resolution
uses: dtolnay/rust-toolchain@stable
with: { toolchain: nightly }
- name: Install MSRV Rust ${{ steps.msrv.outputs.value }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ steps.msrv.outputs.value }}
- run: just ci_mode=0 ci-test-msrv # Ignore warnings in MSRV
- run: just ci-test-msrv

coverage:
name: Code Coverage
if: github.event_name != 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with: { tool: 'just,cargo-llvm-cov' }
- name: Generate code coverage
run: just ci-coverage
- run: just ci-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/llvm-cov/codecov.info
files: target/llvm-cov/lcov.info

# This job checks if any of the previous jobs failed or were canceled.
# This approach also allows some jobs to be skipped if they are not needed.
Expand Down Expand Up @@ -92,7 +94,7 @@ jobs:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
with: { fetch-depth: 0 }
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io if crate's version is newer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
uses: dependabot/fetch-metadata@v3
- name: Approve Dependabot PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr review --approve "$PR_URL"
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
**/*.rs.bk
*.iml
*.pdb
.DS_Store
.idea/
.vscode/
codecov
codecov.SHA256SUM*
debug/
flamegraph*.svg
perf.data*
target/
temp/
tmp/
Expand Down
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
rev: v1.5.6
hooks:
- id: forbid-tabs
- id: remove-tabs
Expand All @@ -33,3 +33,8 @@ repos:
entry: sh -c "cargo fmt --all"
language: rust
pass_filenames: false

- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 3.6.1
hooks:
- id: editorconfig-checker
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ categories = ["science::geo"]
rust-version = "1.78"

[dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde = { version = "1.0.103", features = ["derive"] }
serde_json = "1.0.50"
serde_tuple = "1.1.0"
thiserror = "2"

Expand Down
25 changes: 0 additions & 25 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
allow-mixed-uninlined-format-args = false
allow-unwrap-in-tests = true
avoid-breaking-exported-api = false
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
codecov:
require_ci_to_pass: false

coverage:
status:
patch: off
67 changes: 45 additions & 22 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env just --justfile

# Define the name of the main crate based
main_crate := file_name(justfile_directory())
main_crate := 'tilejson'
# How to call the current just executable. Note that just_executable() may have `\` in Windows paths, so we need to quote it.
just := quote(just_executable())
# cargo-binstall needs a workaround due to caching when used in CI
binstall_args := if env('CI', '') != '' {'--no-confirm --no-track --disable-telemetry'} else {''}
# location of the coverage output, used by CI
coverage_lcov := 'target/llvm-cov/lcov.info'

# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
Expand All @@ -26,17 +27,23 @@ build:
check:
cargo check --workspace --all-features --all-targets

# Generate code coverage report to upload to codecov.io
# Generate LCOV coverage report for CI to upload to codecov.io
ci-coverage: env-info && \
(coverage '--codecov --output-path target/llvm-cov/codecov.info')
# ATTENTION: the full file path above is used in the CI workflow
mkdir -p target/llvm-cov
(_coverage '--lcov' '--output-path' quote(coverage_lcov))
rm -rf {{quote(parent_directory(coverage_lcov))}}
mkdir -p {{quote(parent_directory(coverage_lcov))}}
Comment thread
nyurik marked this conversation as resolved.
Resolved

# Run all tests as expected by CI
ci-test: env-info test-fmt clippy check test test-doc && assert-git-is-clean
ci-test: env-info test-fmt clippy test test-doc && assert-git-is-clean

# Run minimal subset of tests to ensure compatibility with MSRV
ci-test-msrv: env-info check test
# Compile default features with minimal dependencies on the configured MSRV
ci-test-msrv:
{{just}} ci_mode=0 env-info _check-msrv-default
{{just}} assert-git-is-clean

# Set toolchain and run ci-test-msrv
ci-test-msrv-with-toolchain:
RUSTUP_TOOLCHAIN="$({{just}} get-msrv)" {{just}} ci-test-msrv

# Clean all build artifacts
clean:
Expand All @@ -47,9 +54,14 @@ clean:
clippy *args:
cargo clippy --workspace --all-features --all-targets {{args}}

# Generate code coverage report. Will install `cargo llvm-cov` if missing.
coverage *args='--no-clean --open': (cargo-install 'cargo-llvm-cov')
cargo llvm-cov --workspace --all-features --all-targets --include-build-script {{args}}
# Generate and open the HTML coverage report
coverage: (_coverage '--open')

# Clean, collect, and aggregate coverage using the requested report arguments
_coverage *report_args: (cargo-install 'cargo-llvm-cov')
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report --workspace --all-features --all-targets
cargo llvm-cov report --include-build-script {{report_args}}

# Build and open code documentation
docs *args='--open':
Expand All @@ -58,7 +70,7 @@ docs *args='--open':
# Print environment info
env-info:
@echo "Running for '{{main_crate}}' crate {{if ci_mode == '1' {'in CI mode'} else {'in dev mode'} }} on {{os()}} / {{arch()}}"
@echo "PWD $(pwd)"
@echo "PWD {{justfile_directory()}}"
{{just}} --version
rustc --version
cargo --version
Expand All @@ -85,14 +97,25 @@ fmt-toml *args: (cargo-install 'cargo-sort')

# Get a package field from the metadata
get-crate-field field package=main_crate: (assert-cmd 'jq')
cargo metadata --format-version 1 | jq -e -r '.packages | map(select(.name == "{{package}}")) | first | .{{field}} // error("Field \"{{field}}\" is missing in Cargo.toml for package {{package}}")'
@cargo metadata --no-deps --format-version 1 | jq -e -r '.packages | map(select(.name == "{{package}}")) | first | .{{field}} // error("Field \"{{field}}\" is missing in Cargo.toml for package {{package}}")'

# Get the minimum supported Rust version (MSRV) for the crate
get-msrv package=main_crate: (get-crate-field 'rust_version' package)

# Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
# Find the minimum supported Rust version (MSRV), update Cargo.toml, and test minimal dependencies
msrv: (cargo-install 'cargo-msrv')
cargo msrv find --write-msrv --ignore-lockfile --all-features
cargo msrv find --write-msrv --ignore-lockfile -- {{just}} _check-msrv-default

# Compile the crate's default features using a dynamically generated minimal Cargo.lock
_check-msrv-default: (cargo-install 'cargo-minimal-versions') (cargo-install 'cargo-hack')
#!/usr/bin/env bash
set -euo pipefail
# cargo-msrv probes with rustup, but nested cargo subcommands may otherwise
# fall back to the default Cargo and emit flags unsupported by the candidate rustc.
toolchain="$(rustc --version | cut -d' ' -f2)"
export RUSTUP_TOOLCHAIN="$toolchain"
export CARGO="$(rustup which --toolchain "$toolchain" cargo)"
cargo minimal-versions check --direct --package {{main_crate}}

# Run cargo-release
release *args='': (cargo-install 'release-plz')
Expand All @@ -102,7 +125,7 @@ release *args='': (cargo-install 'release-plz')
semver *args: (cargo-install 'cargo-semver-checks')
cargo semver-checks --all-features {{args}}

# Run all unit and integration tests
# Run all tests
test:
cargo test --workspace --all-features --all-targets
cargo test --doc --workspace --all-features
Expand Down Expand Up @@ -135,11 +158,11 @@ assert-cmd command:
[private]
assert-git-is-clean:
@if [ -n "$(git status --untracked-files --porcelain)" ]; then \
>&2 echo "ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified." ;\
>&2 echo "######### git status ##########" ;\
git status ;\
git --no-pager diff ;\
exit 1 ;\
>&2 echo "ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified." ;\
>&2 echo "######### git status ##########" ;\
git status ;\
git --no-pager diff ;\
exit 1 ;\
fi

# Check if a certain Cargo command is installed, and install it if needed
Expand Down