Skip to content

Commit

Permalink
πŸŽ‰ init cdviz-svc
Browse files Browse the repository at this point in the history
  • Loading branch information
davidB committed Dec 30, 2023
1 parent 97f3e7f commit beb3884
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
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
30 changes: 30 additions & 0 deletions Cargo.toml
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}}"
19 changes: 19 additions & 0 deletions cdviz-svc/Cargo.toml
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 }
24 changes: 24 additions & 0 deletions cdviz-svc/src/main.rs
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>")
}
48 changes: 48 additions & 0 deletions justfile
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

0 comments on commit beb3884

Please sign in to comment.