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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @svix/Maintainers
31 changes: 25 additions & 6 deletions .github/workflows/CI.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: CI
name: Rust CI
on:
push:
branches:
- main
pull_request: {}
workflow_call:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -13,11 +11,17 @@ jobs:
with:
toolchain: nightly
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v1
- uses: taiki-e/install-action@cargo-sort
- uses: taiki-e/install-action@cargo-machete
- uses: Swatinem/rust-cache@v2
- name: clippy
run: cargo clippy --all --all-targets --all-features
- name: rustfmt
run: cargo fmt --all -- --check
- name: cargo-sort
run: cargo sort --check --no-format -o package,lib,bin,features,dependencies,dev-dependencies,lints,workspace
- name: cargo-machete
run: cargo machete
test-versions:
runs-on: ubuntu-latest
strategy:
Expand All @@ -41,3 +45,18 @@ jobs:
run: cargo test --all --no-default-features --features "chrono04" --all-targets
- name: Run tests (time03)
run: cargo test --all --no-default-features --features "time03" --all-targets
prek:
name: Validate prek
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- uses: j178/prek-action@v1
cargo-deny:
name: cargo-deny check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: EmbarkStudios/cargo-deny-action@v2
with:
manifest-path: Cargo.toml
10 changes: 10 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI on PR
on:
pull_request:
branches: ['*']
jobs:
ci:
permissions:
contents: read
uses: ./.github/workflows/ci.yml
secrets: inherit
10 changes: 10 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI on Push to Main
on:
push:
branches: [main]
jobs:
ci:
permissions:
contents: read
uses: ./.github/workflows/ci.yml
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI/CD on Push Tag
on:
push:
tags:
- 'v*'
permissions:
contents: read
id-token: write
jobs:
ci:
permissions:
contents: read
uses: ./.github/workflows/ci.yml
secrets: inherit
release:
needs: [ci]
permissions:
contents: read
id-token: write
uses: ./.github/workflows/release.yml
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Release
env:
CARGO_TERM_COLOR: always
on:
push:
tags:
- 'v*'
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/security.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: builtin
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: check-json
- repo: https://github.com/google/yamlfmt
rev: v0.20.0
hooks:
- id: yamlfmt
exclude: "^infra/helm"
- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
- repo: https://github.com/crate-ci/typos
rev: v1.45.0
hooks:
- id: typos
exclude: tests/test_kuids.txt
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.13.1-1
hooks:
- id: shfmt
args: ["--write", "-i", "4", "-ci"]
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.11.0
hooks:
- id: shellcheck
4 changes: 4 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default.extend-identifiers]
# example ksuids
24CtFf3hyVZHdSkQy0nMBa1OjOA = "24CtFf3hyVZHdSkQy0nMBa1OjOA"
02GY99XXwBHbeBundUPJoqYpvet = "02GY99XXwBHbeBundUPJoqYpvet"
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ license="MIT"
keywords=["ksuid", "uuid", "svix", "segment"]
categories = ["data-structures", "concurrency", "database", "encoding"]

[badges]
maintenance = {status="actively-developed"}

[features]
# Include `time` by default, to match old behavior
default = ["time03"]
Expand All @@ -26,12 +23,15 @@ chrono04 = ["dep:chrono"]
[dependencies]
base-encode = "^0.3.1"
byteorder = "^1.4.3"
getrandom = "0.4.2"
time = { version = "0.3.47", optional = true }
chrono = { version = "0.4", optional = true }
getrandom = "0.4.2"
jiff = { version = "0.2", optional = true }
serde = { version = "^1.0.145", optional = true, features = ["derive"] }
time = { version = "0.3.47", optional = true }

[dev-dependencies]
serde = { version = "^1.0.145", features = ["derive"] }
serde_json = "^1.0.85"

[badges]
maintenance = {status="actively-developed"}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ And they both implement the same `KsuidLike` trait.
### Opt-in features
* `serde` - adds the ability to serialize and deserialize `Ksuid` and `KsuidMs`
using serde.
* `time03` - accept timestamps as the `time::OffsetDateTime` type from the [time](https://crates.io/crates/time) (0.3.x) crate – this feature is enabled by default, for compatibility with 0.8.x and older verisons
* `time03` - accept timestamps as the `time::OffsetDateTime` type from the [time](https://crates.io/crates/time) (0.3.x) crate – this feature is enabled by default, for compatibility with 0.8.x and older versions
* `chrono04` - accept timestamps as the `chrono::DateTime<chrono::Utc>` type from the [chrono](https://crates.io/crates/chrono) (0.4.x) crate
* `jiff02` - accept timestamps as the `jiff::Timestamp` type from the [jiff](https://crates.io/crates/jiff) (0.2.x) crate

Expand Down
42 changes: 42 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
HERE := justfile_directory()

build:
cargo build

test:
cargo test --all --all-features --all-targets
cargo test --all --no-default-features --all-targets
cargo test --doc
cargo test --all --no-default-features --features "jiff02" --all-targets
cargo test --all --no-default-features --features "chrono04" --all-targets
cargo test --all --no-default-features --features "time03" --all-targets

[group('lint')]
lint: clippy machete fmt sort audit

# run clippy in --fix mode
[group('lint')]
clippy:
# keep this nightly to keep it in sync with CI
cargo +nightly clippy --fix --allow-dirty --all-features --all-targets

# run cargo-machete in --fix mode
[group('lint')]
machete:
cargo machete --fix

# run cargo-fmt in --fix mode
[group('lint')]
fmt:
# this has to be nightly to get import sorting working correctly
cargo +nightly fmt

# run cargo sort
[group('lint')]
sort:
cargo sort --no-format -o package,lib,bin,features,dependencies,dev-dependencies,lints

# run security lints
[group('lint')]
audit:
cargo deny check -c {{ HERE / "deny.toml" }}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ type DefaultTimestamp = MinimalTimestamp;
/// assert_eq!(ksuid, ksuid2);
/// ```
pub trait KsuidLike {
/// The type of the Ksuid struct beind implemented
/// The type of the Ksuid struct being implemented
type Type;

/// The number of bytes used for timestamp (`TIMESTAMP_BYTES + PAYLOAD_BYTES == 20`)
Expand Down
Loading