Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all): initial commit #1

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OS
Thumbs.db
.DS_Store

# Editors
.vs/
.vscode/
.idea/
.fleet/
10 changes: 10 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:

- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
timezone: "Europe/Warsaw"
day: "friday"
time: "18:00"
47 changes: 47 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: ci & cd

on:
push:
branches:
- "main"
tags:
- "v*.*.*"
pull_request:

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Run Cargo:fmt
run: cargo +nightly fmt --all -- --check

- name: Run Cargo:clippy
run: cargo clippy --all-features -- -D warnings

- name: Run Cargo:test
run: cargo test --verbose --all-features

publish:
runs-on: ubuntu-22.04
if: github.event_name == 'push'
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Publish
run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
44 changes: 29 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# Generated by Cargo
# will have compiled files and executables
# OS
Thumbs.db
.DS_Store
.ignore*/

# Editors
.vs/
.vscode/
.idea/
.fleet/

# Lang: Rust
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Output
dist/
output/
build/

# Environment
env/
.env
.env*

# Logs
logs/
*.log
*.log*

# Generated
/crates/schema/generated/
64 changes: 64 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace]
resolver = "2"
members = [
"./crates/cli",
"./crates/client",
"./crates/jsvm",
"./crates/schema",
"./crates/server",
]

[workspace.package]
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
publish = true

authors = ["Axiston <[email protected]>"]
repository = "https://github.com/axiston/runtime"
homepage = "https://github.com/axiston/runtime"
documentation = "https://docs.rs/axiston"

[workspace.dependencies]
axiston-rt-jsvm = { path = "./crates/jsvm", version = "0.1.0" }
axiston-rt-schema = { path = "./crates/schema", version = "0.1.0" }
axiston-rt-server = { path = "./crates/server", version = "0.1.0" }

clap = { version = "4.5", features = ["derive"] }
tokio = { version = "1.43", features = ["macros", "rt-multi-thread", "signal"] }
deadpool = { version = "0.12", features = ["managed", "rt_tokio_1"] }
tokio-stream = { version = "0.1", features = [] }
futures = { version = "0.3", features = [] }
http = { version = "1.2", features = [] }
pin-project-lite = { version = "0.2", features = [] }
tracing = { version = "0.1", features = [] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tower = { version = "0.5", features = ["full"] }
tower-http = { version = "0.6", features = ["full"] }
thiserror = { version = "2.0", features = [] }
anyhow = { version = "1.0", features = ["backtrace"] }

derive_more = { version = "2.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_with = { version = "3.12", features = [] }
serde_toml = { package = "toml", version = "0.8", features = [] }
serde_json = { version = "1.0", features = [] }

ecow = { version = "0.2", features = ["serde"] }
time = { version = "0.3", features = ["serde"] }
uuid = { version = "1.12", features = ["serde", "v4", "v7"] }
bytes = { version = "1.9", features = ["serde"] }
hashbrown = { version = "0.15", features = ["serde"] }
petgraph = { version = "0.7", features = [] }
cron = { version = "0.15", features = ["serde"] }
semver = { version = "1.0", features = ["serde"] }
jsonschema = { version = "0.28", features = [] }

tonic = { version = "0.12", features = [] }
prost = { version = "0.13", features = [] }
tonic-types = { version = "0.12", features = [] }
prost-types = { version = "0.13", features = [] }
tonic-build = { version = "0.12", features = [] }
prost-build = { version = "0.13", features = [] }
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Stage 1: Build.
FROM rust:1.84 AS build
WORKDIR /usr/src/app/

RUN apt-get update
RUN apt-get install -y curl build-essential

# Cache dependencies by copying only Cargo.* files.
COPY Cargo.toml Cargo.lock? ./
COPY crates/cli/Cargo.toml crates/cli/
COPY crates/jsvm/Cargo.toml crates/jsvm/
COPY crates/schema/Cargo.toml crates/schema/
COPY crates/client/Cargo.toml crates/client/
COPY crates/server/Cargo.toml crates/server/

# Create a dummy files to allow dependency resolution.
RUN mkdir -p crates/cli crates/jsvm crates/schema
RUN mkdir -p crates/client crates/server
RUN echo "fn main() {}" > crates/cli/main.rs
RUN echo "" > crates/cli/lib.rs
RUN echo "" > crates/jsvm/lib.rs
RUN echo "" > crates/schema/lib.rs
RUN echo "" > crates/client/lib.rs
RUN echo "" > crates/server/lib.rs

# Pre-build dependencies to cache them.
RUN cargo build --release --workspace

# Copy the source code and build the final binaries.
COPY crates ./crates
RUN cargo build --release --workspace

# Stage 2: Runtime.
FROM debian:bookworm-slim AS runtime
WORKDIR /usr/src/bin/

# Copy the built binary from the previous stage.
COPY --from=build /usr/src/app/target/release/cli /usr/src/bin/cli

# Ensure the binary is an executable.
RUN chmod +x /usr/src/bin/cli

# Expose the port the server runs on.
EXPOSE 8080

# Set the default command to run the server.
CMD ["/usr/src/bin/cli", "--port", "8080"]
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 axiston
Copyright (c) 2024 Axiston

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Makefile for client & server GRPC Generation.
# https://github.com/hyperium/tonic

# Environment Variables
SCHEMA_OUTPUT = ./crates/schema/generated/

.PHONY: clean
clean: ## Deletes the output directory.
$(call print-info, "Cleaning project...")
rm -f $(SCHEMA_OUTPUT)
$(call print-success, "Project cleaned.")
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# runtime
### axiston/runtime

[![Build Status][action-badge]][action-url]
[![Crate Coverage][coverage-badge]][coverage-url]

[action-badge]: https://img.shields.io/github/actions/workflow/status/axiston/runtime/build.yaml
[action-url]: https://github.com/axiston/runtime/actions/workflows/build.yaml
[coverage-badge]: https://img.shields.io/codecov/c/github/axiston/runtime
[coverage-url]: https://app.codecov.io/gh/axiston/runtime

A server application based on `Deno` runtime, capable of running `JavaScript`,
`TypeScript`, and native `Rust` tasks.

#### Notes

- Lorem Ipsum.
- Lorem Ipsum.
- Lorem Ipsum.

#### Usage

```cmd
runtime --port 8080
```
47 changes: 47 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# https://doc.rust-lang.org/cargo/reference/manifest.html

[package]
name = "axiston-rt-cli"
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
readme = "./README.md"

authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[[bin]]
name = "axiston"
path = "main.rs"

[features]
default = []

# - Enables the global tracer provider.
support-otel = []

[dependencies]
axiston-rt-schema = { workspace = true, features = ["server"] }
axiston-rt-server = { workspace = true, features = [] }

clap = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
anyhow = { workspace = true }

tonic = { workspace = true }
prost = { workspace = true }
tonic-types = { workspace = true }
prost-types = { workspace = true }

serde = { workspace = true }
serde_toml = { workspace = true }
serde_json = { workspace = true }
20 changes: 20 additions & 0 deletions crates/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### runtime/client

[![Build Status][action-badge]][action-url]
[![Crate Docs][docs-badge]][docs-url]
[![Crate Version][crates-badge]][crates-url]

[action-badge]: https://img.shields.io/github/actions/workflow/status/axiston/runtime/build.yaml?branch=main&label=build&logo=github&style=flat-square
[action-url]: https://github.com/axiston/runtime/actions/workflows/build.yaml
[crates-badge]: https://img.shields.io/crates/v/axiston-rt-client.svg?logo=rust&style=flat-square
[crates-url]: https://crates.io/crates/axiston-rt-client
[docs-badge]: https://img.shields.io/docsrs/axiston-rt-client?logo=Docs.rs&style=flat-square
[docs-url]: http://docs.rs/axiston-rt-client

Lorem Ipsum. Lorem Ipsum. Lorem Ipsum.

#### Notes

- Lorem Ipsum.
- Lorem Ipsum.
- Lorem Ipsum.
14 changes: 14 additions & 0 deletions crates/cli/config/from_json.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::path::Path;

use crate::config::Args;

/// - Reads the entire contents of a file and deserializes an instance of [`Args`].
///
/// # Errors
///
/// - See [std::fs::read] and [`serde_json::from_slice`] documentation for details.
pub fn load_json(path: impl AsRef<Path>) -> anyhow::Result<Args> {
let file_content = std::fs::read(path)?;
let parsed_args = serde_json::from_slice(&file_content)?;
Ok(parsed_args)
}
14 changes: 14 additions & 0 deletions crates/cli/config/from_toml.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::path::Path;

use crate::config::Args;

/// - Reads the entire contents of a file and deserializes an instance of [`Args`].
///
/// # Errors
///
/// - See [std::fs::read_to_string] and [`serde_toml::from_str`] documentation for details.
pub fn load_toml(path: impl AsRef<Path>) -> anyhow::Result<Args> {
let file_content = std::fs::read_to_string(path)?;
let parsed_args = serde_toml::from_str(&file_content)?;
Ok(parsed_args)
}
Loading
Loading