-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: ci | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: full | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: jdx/rtx-action@v1 | ||
- name: Cache cargo registry | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo- | ||
- run: just check | ||
- run: just lint | ||
- run: just test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"cdviz-svc", | ||
# "examples/*", | ||
] | ||
|
||
[workspace.package] | ||
edition = "2021" | ||
version = "0.1.0" | ||
authors = ["David Bernard"] | ||
license = "AGPL-3.0-or-later" | ||
repository = "https://github.com/davidB/cdviz" | ||
rust-version = "1.75" | ||
publish = false | ||
|
||
[workspace.dependencies] | ||
rstest = "0.18" | ||
|
||
[profile.dev.package.insta] | ||
opt-level = 3 | ||
|
||
[profile.dev.package.similar] | ||
opt-level = 3 | ||
|
||
[workspace.metadata.release] | ||
pre-release-commit-message = "π (cargo-release) version {{version}}" | ||
tag-prefix = "" | ||
tag-name = "{{prefix}}{{version}}" | ||
tag-message = "π {{version}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "cvdiz-svc" | ||
description = "The service to collect cdevents" | ||
readme = "README.md" | ||
keywords = ["cd"] | ||
categories = [] | ||
edition.workspace = true | ||
version.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
publish.workspace = true | ||
|
||
[dependencies] | ||
axum = "0.7" | ||
tokio = { version = "1.0", features = ["full"] } | ||
|
||
[dev-dependencies] | ||
rstest = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Run with | ||
//! | ||
//! ```not_rust | ||
//! cargo run | ||
//! ``` | ||
use axum::{response::Html, routing::get, Router}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// build our application with a route | ||
let app = Router::new().route("/", get(handler)); | ||
|
||
// run it | ||
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000") | ||
.await | ||
.unwrap(); | ||
println!("listening on {}", listener.local_addr().unwrap()); | ||
axum::serve(listener, app).await.unwrap(); | ||
} | ||
|
||
async fn handler() -> Html<&'static str> { | ||
Html("<h1>Hello, World!</h1>") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
requirements: | ||
cargo install cargo-binstall | ||
cargo binstall cargo-nextest | ||
cargo binstall cargo-sort | ||
cargo binstall cargo-hack | ||
# cargo binstall cargo-insta | ||
cargo binstall cargo-release | ||
cargo binstall git-cliff | ||
|
||
check: | ||
cargo hack check --each-feature --no-dev-deps | ||
|
||
build: | ||
cargo build | ||
|
||
# Format the code and sort dependencies | ||
format: | ||
cargo fmt | ||
cargo sort --workspace --grouped | ||
|
||
deny: | ||
cargo deny check advisories | ||
cargo deny check bans licenses sources | ||
|
||
# Lint the rust code | ||
lint: | ||
cargo fmt --all -- --check | ||
cargo sort --workspace --grouped --check | ||
cargo clippy --workspace --all-features --all-targets -- --deny warnings --allow deprecated --allow unknown-lints | ||
|
||
megalinter: | ||
@just _container run --pull always --rm -it -v "$PWD:/tmp/lint:rw" "megalinter/megalinter:v7" | ||
|
||
# Launch tests | ||
test: | ||
cargo nextest run | ||
cargo test --doc | ||
cargo hack test --each-feature -- --test-threads=1 | ||
|
||
changelog: | ||
git-cliff -o "CHANGELOG.md" | ||
git add CHANGELOG.md && git commit -m "π update CHANGELOG" | ||
|
||
release *arguments: | ||
cargo release --workspace --execute {{arguments}} | ||
# git-cliff could not be used as `pre-release-hook` of cargo-release because it uses tag | ||
git-cliff -o "CHANGELOG.md" | ||
git add CHANGELOG.md && git commit -m "π update CHANGELOG" && git push |