diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..dd787e6 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] + +[target.aarch64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..52615b3 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,21 @@ +name: Nix Checks + +on: + push: + branches: [main] + pull_request: + +jobs: + nix-build: + name: Nix Build + runs-on: blacksmith-2vcpu-ubuntu-2404 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - run: sudo mkdir -p /nix && sudo chown "$(id -u):$(id -g)" /nix + - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 + with: + path: /nix + key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} + restore-keys: nix-${{ runner.os }}-${{ runner.arch }}- + - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 + - run: nix develop --command true diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 0000000..8b0108d --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,29 @@ +name: PR Title + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + pr-title: + name: Conventional Commit + runs-on: blacksmith-2vcpu-ubuntu-2404 + steps: + - name: Validate PR title + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + pattern='^(feat|fix|refactor|ci|test|chore|docs|perf|style|build|revert)(\((core|renderer|deps)\))?!?: [a-z].+' + if [[ "$PR_TITLE" =~ $pattern ]]; then + echo "✓ $PR_TITLE" + else + echo "::error::PR title does not follow Conventional Commits format." + echo "" + echo "Expected: (): " + echo "Got: $PR_TITLE" + echo "" + echo "Allowed types: feat, fix, refactor, ci, test, chore, docs, perf, style, build, revert" + echo "Allowed scopes (optional): core, renderer, deps" + echo "Description must start with a lowercase letter." + exit 1 + fi diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..23bd5a1 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,91 @@ +name: Rust Checks + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: Rustfmt (${{ matrix.package }}) + runs-on: blacksmith-2vcpu-ubuntu-2404 + strategy: + fail-fast: false + matrix: + package: [tellur-core, tellur-renderer] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - run: sudo mkdir -p /nix && sudo chown "$(id -u):$(id -g)" /nix + - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 + with: + path: /nix + key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} + restore-keys: nix-${{ runner.os }}-${{ runner.arch }}- + - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 + - run: nix develop --command cargo fmt -p ${{ matrix.package }} -- --check + + clippy: + name: Clippy (${{ matrix.package }}) + runs-on: blacksmith-2vcpu-ubuntu-2404 + strategy: + fail-fast: false + matrix: + package: [tellur-core, tellur-renderer] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - run: sudo mkdir -p /nix && sudo chown "$(id -u):$(id -g)" /nix + - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 + with: + path: /nix + key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} + restore-keys: nix-${{ runner.os }}-${{ runner.arch }}- + - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 + - uses: useblacksmith/rust-cache@f53e7f127245d2a269b3d90879ccf259876842d5 # v3 + with: + key: ${{ matrix.package }} + - run: nix develop --command cargo clippy --locked -p ${{ matrix.package }} -- -D warnings + + build: + name: Build (${{ matrix.package }}) + runs-on: blacksmith-2vcpu-ubuntu-2404 + strategy: + fail-fast: false + matrix: + package: [tellur-core, tellur-renderer] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - run: sudo mkdir -p /nix && sudo chown "$(id -u):$(id -g)" /nix + - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 + with: + path: /nix + key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} + restore-keys: nix-${{ runner.os }}-${{ runner.arch }}- + - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 + - uses: useblacksmith/rust-cache@f53e7f127245d2a269b3d90879ccf259876842d5 # v3 + with: + key: ${{ matrix.package }} + - run: nix develop --command cargo build --locked -p ${{ matrix.package }} + + test: + name: Test (${{ matrix.package }}) + runs-on: blacksmith-2vcpu-ubuntu-2404 + strategy: + fail-fast: false + matrix: + package: [tellur-core, tellur-renderer] + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - run: sudo mkdir -p /nix && sudo chown "$(id -u):$(id -g)" /nix + - uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 + with: + path: /nix + key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }} + restore-keys: nix-${{ runner.os }}-${{ runner.arch }}- + - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 + - uses: useblacksmith/rust-cache@f53e7f127245d2a269b3d90879ccf259876842d5 # v3 + with: + key: ${{ matrix.package }} + - run: nix develop --command cargo nextest run --locked -p ${{ matrix.package }} --no-tests=warn diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b7f7b51 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +target/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..aeb92c8 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,14 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "tellur-core" +version = "0.1.0" + +[[package]] +name = "tellur-renderer" +version = "0.1.0" +dependencies = [ + "tellur-core", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..46501df --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["tellur-core", "tellur-renderer"] +resolver = "2" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..be9faa5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,114 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1779442979, + "narHash": "sha256-CtoDst6OfZYWAuqT7J5A9QduRYIL7+xTlBd9CS8RKOk=", + "owner": "nix-community", + "repo": "fenix", + "rev": "e8d2e251fa22fd892997612423e16c733a8775c4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1778869304, + "narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d233902339c02a9c334e7e593de68855ad26c4cb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1779414690, + "narHash": "sha256-gOTcX/9MZVMUE0Xvb4IEcv+0TQJkZFNEnL757ljU360=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6dedf69f94d03cbe7bdde106f2d4c23ae2a853bf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1779303932, + "narHash": "sha256-alMOllPgosTsuXGjhvQvbGH0ekPOZW0QfGTI0NdJtbQ=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "7f916ab1b1f669cec017960c2d91a9a87b4b7bae", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6129912 --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + fenix.url = "github:nix-community/fenix"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + fenix, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + rustToolchain = fenix.packages.${system}.fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk="; + }; + in + { + devShells.default = pkgs.mkShell { + name = "tellur"; + + packages = [ + rustToolchain + pkgs.cargo-watch + pkgs.cargo-nextest + pkgs.just + ] + ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ + pkgs.pkg-config + pkgs.mold + ]; + }; + } + ); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..00ca9d3 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.95.0" +components = ["cargo", "rustc", "rustfmt", "clippy", "rust-analyzer", "rust-src"] diff --git a/tellur-core/Cargo.toml b/tellur-core/Cargo.toml new file mode 100644 index 0000000..9227ca5 --- /dev/null +++ b/tellur-core/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "tellur-core" +version = "0.1.0" +edition = "2021" diff --git a/tellur-core/src/lib.rs b/tellur-core/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tellur-core/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tellur-renderer/Cargo.toml b/tellur-renderer/Cargo.toml new file mode 100644 index 0000000..e09a3a5 --- /dev/null +++ b/tellur-renderer/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "tellur-renderer" +version = "0.1.0" +edition = "2021" + +[dependencies] +tellur-core = { path = "../tellur-core" } diff --git a/tellur-renderer/src/lib.rs b/tellur-renderer/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tellur-renderer/src/lib.rs @@ -0,0 +1 @@ +