Skip to content

Commit 3cc5d87

Browse files
Merge pull request #1 from manuschillerdev/ci/basic-ci-pipeline
Add Rust project CI and release hardening
2 parents d413aad + c63ce7e commit 3cc5d87

14 files changed

Lines changed: 776 additions & 50 deletions

File tree

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: weekly
12+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,43 @@ on:
55
branches: [main]
66
pull_request:
77

8+
permissions:
9+
contents: read
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
814
jobs:
9-
rust:
15+
lint-test:
16+
name: Lint, test, and package
1017
runs-on: ubuntu-latest
1118
steps:
1219
- uses: actions/checkout@v4
1320
- uses: dtolnay/rust-toolchain@stable
1421
with:
1522
components: clippy, rustfmt
16-
- run: cargo fmt --check
17-
- run: cargo clippy --all-targets -- -D warnings
18-
- run: cargo test
23+
- uses: Swatinem/rust-cache@v2
24+
- run: cargo fmt --all --check
25+
- run: cargo clippy --all-targets --all-features -- -D warnings
26+
- run: cargo test --all-targets --all-features
27+
- run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
28+
- run: cargo package
29+
30+
msrv:
31+
name: MSRV
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: dtolnay/rust-toolchain@1.85.0
36+
- uses: Swatinem/rust-cache@v2
37+
- run: cargo check --all-targets --all-features
38+
39+
dependencies:
40+
name: Dependency policy
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: EmbarkStudios/cargo-deny-action@v2
45+
with:
46+
command: check
47+
command-arguments: advisories bans licenses sources

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
release-plz:
17+
name: Release-plz
18+
runs-on: ubuntu-latest
19+
concurrency:
20+
group: release-plz-${{ github.ref }}
21+
cancel-in-progress: true
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- uses: dtolnay/rust-toolchain@stable
27+
- uses: Swatinem/rust-cache@v2
28+
- uses: release-plz/action@v0.5
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Cargo.toml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
11
[package]
22
name = "absurd-rust-sdk"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
5+
rust-version = "1.85"
56
authors = ["Manuel Schiller"]
67
description = "Community Rust SDK for Absurd, a Postgres-native durable workflow system"
78
license = "Apache-2.0"
89
repository = "https://github.com/manuschillerdev/absurd-rust-sdk"
910
readme = "README.md"
1011
keywords = ["absurd", "postgres", "workflow", "durable", "queue"]
1112
categories = ["asynchronous", "database"]
13+
include = ["Cargo.toml", "LICENSE", "README.md", "examples/**", "src/**", "tests/**"]
1214

1315
[lib]
1416
name = "absurd_rust_sdk"
1517
path = "src/lib.rs"
1618

1719
[dependencies]
18-
chrono = { version = "0.4", features = ["serde"] }
19-
deadpool-postgres = { version = "0.14", features = ["rt_tokio_1"] }
20+
chrono = { version = "0.4", default-features = false, features = ["clock", "serde", "std"] }
21+
deadpool-postgres = { version = "0.14", default-features = false, features = ["rt_tokio_1"] }
2022
hostname = "0.4"
21-
serde = { version = "1", features = ["derive"] }
22-
serde_json = "1"
23-
thiserror = "2"
24-
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal", "sync", "time"] }
25-
tokio-postgres = { version = "0.7", features = ["runtime", "with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] }
23+
serde = { version = "1.0", features = ["derive"] }
24+
serde_json = "1.0"
25+
thiserror = "2.0"
26+
tokio = { version = "1.21", features = ["macros", "rt-multi-thread", "signal", "sync", "time"] }
27+
tokio-postgres = { version = "0.7", default-features = false, features = ["runtime", "with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] }
2628
tracing = "0.1"
27-
uuid = { version = "1", features = ["serde", "v4"] }
29+
uuid = { version = "1.0", default-features = false, features = ["serde", "std", "v4"] }
2830

2931
[dev-dependencies]
30-
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
32+
tokio = { version = "1.21", features = ["macros", "rt-multi-thread", "time"] }
3133
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
34+
35+
[lints.rust]
36+
future_incompatible = { level = "deny", priority = -1 }
37+
nonstandard_style = { level = "deny", priority = -1 }
38+
rust_2018_idioms = { level = "deny", priority = -1 }
39+
unsafe_code = "forbid"
40+
41+
[lints.clippy]
42+
all = { level = "deny", priority = -1 }
43+
cargo = { level = "deny", priority = -1 }
44+
dbg_macro = "deny"
45+
expect_used = "deny"
46+
multiple_crate_versions = "allow"
47+
panic = "deny"
48+
todo = "deny"
49+
unimplemented = "deny"
50+
unwrap_used = "deny"

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ Next hardening targets:
115115

116116
Environment resolution uses `ABSURD_DATABASE_URL`, then `DATABASE_URL`, then `PGDATABASE`, then `postgresql://localhost/absurd`.
117117

118+
## Development
119+
120+
The crate targets Rust 1.85+ and edition 2024.
121+
122+
```sh
123+
cargo fmt --all --check
124+
cargo clippy --all-targets --all-features -- -D warnings
125+
cargo test --all-targets --all-features
126+
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
127+
cargo deny check advisories bans licenses sources
128+
cargo package
129+
```
130+
131+
`Cargo.lock` is intentionally not committed because this is a library crate; CI resolves the current compatible dependency graph and Dependabot tracks manifest/action updates.
132+
118133
## License
119134

120135
Apache-2.0

deny.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[advisories]
2+
ignore = []
3+
4+
[licenses]
5+
allow = [
6+
"Apache-2.0",
7+
"Apache-2.0 WITH LLVM-exception",
8+
"BSL-1.0",
9+
"MIT",
10+
"Unicode-3.0",
11+
"Zlib",
12+
]
13+
confidence-threshold = 0.8
14+
15+
[bans]
16+
highlight = "all"
17+
multiple-versions = "warn"
18+
wildcards = "deny"
19+
20+
[sources]
21+
allow-git = []
22+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
23+
unknown-git = "deny"
24+
unknown-registry = "deny"

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = ["clippy", "rustfmt"]
4+
profile = "minimal"

rustfmt.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
edition = "2024"
2+
newline_style = "Unix"
3+
use_field_init_shorthand = true
4+
use_try_shorthand = true

src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use crate::context::TaskContext;
2-
use crate::error::{map_database_error, Error, Result};
2+
use crate::error::{Error, Result, map_database_error};
33
use crate::executor::execute_claimed_catching;
44
use crate::task::Task;
55
use crate::types::{
6-
duration_seconds_ceil, validate_queue_name, CancellationPolicy, ClaimedTask, CleanupResult,
7-
Json, SpawnOptions, SpawnResult, TaskOptions, WorkBatchOptions, WorkerOptions,
6+
CancellationPolicy, ClaimedTask, CleanupResult, Json, SpawnOptions, SpawnResult, TaskOptions,
7+
WorkBatchOptions, WorkerOptions, duration_seconds_ceil, validate_queue_name,
88
};
99
use crate::worker::Worker;
1010
use deadpool_postgres::{Config as PoolConfig, Pool, Runtime};
11-
use serde::{de::DeserializeOwned, Serialize};
11+
use serde::{Serialize, de::DeserializeOwned};
1212
use serde_json::Value;
1313
use std::collections::HashMap;
1414
use std::future::Future;

src/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::error::{map_database_error, Error, Result};
2-
use crate::types::{duration_seconds_ceil, ClaimedTask, Json};
1+
use crate::error::{Error, Result, map_database_error};
2+
use crate::types::{ClaimedTask, Json, duration_seconds_ceil};
33
use chrono::{DateTime, Utc};
44
use deadpool_postgres::Pool;
5-
use serde::{de::DeserializeOwned, Serialize};
5+
use serde::{Serialize, de::DeserializeOwned};
66
use serde_json::{Map, Value};
77
use std::collections::{HashMap, HashSet};
88
use std::future::Future;

0 commit comments

Comments
 (0)