diff --git a/.config/env.sh b/.config/env.sh deleted file mode 100644 index 6a30564..0000000 --- a/.config/env.sh +++ /dev/null @@ -1,15 +0,0 @@ -export CARGO_TERM_COLOR="always" -export PYTHONUNBUFFERED=1 -export RUSTC_WRAPPER="sccache" - -if [[ -n "$SSH_CLIENT" ]]; then - export FEATURES="" -else - export FEATURES="dylib" -fi - -if [[ -n "$CI" ]]; then - export MISE_ENV="ci" -elif [[ -n "$SSH_CLIENT" ]]; then - export MISE_ENV="ssh" -fi diff --git a/.config/mise.ssh.toml b/.config/mise.ssh.toml deleted file mode 100644 index 2e03d7c..0000000 --- a/.config/mise.ssh.toml +++ /dev/null @@ -1,36 +0,0 @@ -# SSH ######################################################################### - -[env] -_.file = {path = ".config/.env.json", redact = true } -_.source = {path="~/.profile", redact=true} - -[tools] -sops = "latest" -age = "latest" -'pipx:cubething_psync' = "0.5" - -[tasks.play] -description="Run the application (SSH)" -usage = """ - arg "[file]" help="path to executable" default="workspace/target/debug/app" - flag "--example -x " help="run an example" - flag "--build-args -B " var=#true - flag "--env -e " help="environment variables" - flag "--args -a " help="command arguments" - flag "--assets -A " help="assets path" default="./workspace/assets" -""" -run = """ -#!/bin/bash -set -e -if [ -n "$usage_example" ]; then - EXAMPLE="--example $usage_example" -fi -mise build $usage_build_args $EXAMPLE -if [ -n "$usage_example" ]; then - TARGET_PATH="./workspace/target/debug/examples/$usage_example" -else - TARGET_PATH=$usage_file -fi -set -x -uvx --from cubething_psync psync "$TARGET_PATH" -e "${usage_env}" -a "${usage_args}" -A "${usage_assets}" -""" diff --git a/.config/mise.toml b/.config/mise.toml deleted file mode 100644 index 2669a18..0000000 --- a/.config/mise.toml +++ /dev/null @@ -1,148 +0,0 @@ -[env] -_.source = ".config/env.sh" - -[tools] -"cargo:cargo-binstall" = "latest" -"mold" = "latest" -sccache="latest" - -[tools.rust] -# keep in sync with bevy_cli -version = "nightly-2026-01-22" -components = "rustc-codegen-cranelift-preview,rustc-dev,llvm-tools-preview,clippy" -targets = "x86_64-pc-windows-msvc,x86_64-unknown-linux-gnu" - -[tasks.install_bevy_lint] -hide = true -run = """ -rustup run nightly-2026-01-22 cargo install \ - --git https://github.com/TheBevyFlock/bevy_cli.git \ - --tag lint-v0.6.0 \ - --locked \ - bevy_lint || true -""" - - -## CHECKS ##################################################################### - -[tasks."check:deps"] -alias = "deny" -tools = { "cargo:cargo-deny" = "latest" } -description = "Check dependencies with cargo-deny" -run = """ -cargo deny --workspace --manifest-path=./workspace/Cargo.toml \ - -L error \ - check advisories bans sources \ - --hide-inclusion-graph -""" - -[tasks.bevy_lint] -hide = true -depends = ["install_bevy_lint"] -usage = """ - arg "" var=#true default="" - flag "--fix" -""" -run = """ -#!/bin/bash -RUSTC_WRAPPER="" -if [[ $usage_pkg != "''" ]]; then PKG="-p $usage_pkg"; fi -bevy_lint --manifest-path=./workspace/Cargo.toml --all-features --target-dir=target/bevy_lint $FIX -""" - -[tasks.clippy] -hide = true -usage = """ - flag "-p " var=#true - flag "--fix" -""" -run = """ -FIX=${usage_fix:+--fix} -if [[ $usage_pkg != "''" ]]; then PKG="-p $usage_pkg"; fi -cargo --color=always clippy --manifest-path=./workspace/Cargo.toml --all-features --target-dir=target/clippy $FIX $PKG -""" - -[tasks.check] -description = "Lint package(s) with Clippy and bevy_lint." -usage = """ - arg "" var=#true default="" -""" -raw = true -run = """ -mise clippy -p ${usage_pkg} ::: bevy_lint -p ${usage_pkg} -""" - - -## FIXES ###################################################################### - -[tasks."fix:rust"] -alias = "fix-rust" -description = "Fix any fixable issues in rust. Includes formatting." -depends = ["check --fix"] - -[tasks.fix] -description = "Fix all fixable issues." -depends = ["fix:rust"] - -## BUILD AND DEPLOY ########################################################### - -[tasks.ci] -tools = { "act" = "latest" } -description = "Test CI locally with nektos/act" -run = """ -docker run \ - --name artifact-server \ - -d -p 8080:8080 \ - --add-host artifacts.docker.internal:host-gateway \ - -e AUTH_KEY=foo \ - ghcr.io/jefuller/artifact-server:latest || true && - -act -P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:act-24.04 \ - --env ACTIONS_RUNTIME_URL=http://artifacts.docker.internal:8080/ \ - --env ACTIONS_RUNTIME_TOKEN=foo \ - --env ACTIONS_CACHE_URL=http://artifacts.docker.internal:8080/ \ - --artifact-server-path ../artifacts \ - --env RUSTC_WRAPPER=""\ -""" - -[tasks.test] -tools = { "cargo:cargo-nextest" = "latest" } -description = "Run tests for a specific package or all packages" -usage = """ - arg "[rest]" default="r --workspace" help="Passed directly to `cargo nextest`" -""" -run = """ -cargo nextest --manifest-path=./workspace/Cargo.toml ${usage_rest} -""" - -[tasks.coverage] -tools = { "cargo:cargo-llvm-cov" = "latest", "cargo:cargo-nextest" = "latest" } -description = "Get test coverage report." -usage = """ - arg "[rest]" default="--html --open" -""" -run = """ -RUSTFLAGS=-Zcodegen-backend=llvm cargo llvm-cov nextest --html --open --manifest-path=./workspace/Cargo.toml -""" - -# LOCAL ####################################################################### - -[tasks.build] -description = "Cargo build." -tools = { "sccache" = "latest" } -usage = """ - arg "[args]" help="Args passed to cargo build. Run `cargo build --help` for more info." var=#true -""" -run = """ -cargo build --manifest-path=./workspace/Cargo.toml ${usage_args} -""" - -[tasks.play] -description = "Cargo run." -tools = { "sccache" = "latest" } -usage = """ - arg "[args]" help="Args passed to cargo run. Run `cargo run --help` for more info." var=#true -""" -run = """ -cargo run --manifest-path=./workspace/Cargo.toml ${usage_args} -""" diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eaee6d0..81b90f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ on: env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 - MISE_ENV: ci SCCACHE_GHA_ENABLED: true jobs: @@ -20,7 +19,25 @@ jobs: with: submodules: recursive - - name: Cache + - uses: cachix/install-nix-action@v31 + with: + extra_nix_config: | + extra-experimental-features = nix-command flakes + + - name: Cache Nix store + uses: actions/cache@v4 + with: + path: /tmp/nix-cache + key: nix-${{ matrix.target }}-${{ hashFiles('flake.lock') }} + restore-keys: nix-${{ matrix.target }}- + + - name: Import Nix cache + run: | + if [ -f /tmp/nix-cache/archive.nar ]; then + nix-store --import < /tmp/nix-cache/archive.nar || true + fi + + - name: Cache Cargo uses: actions/cache@v4 with: path: | @@ -44,19 +61,13 @@ jobs: libwayland-dev ; - - name: Install rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: nightly-2026-01-22 - components: rustc-codegen-cranelift-preview,rustc-dev,llvm-tools-preview,clippy - - - uses: cargo-bins/cargo-binstall@main - - - uses: jdx/mise-action@v3 - with: - log_level: info + - run: nix develop --command just build + - run: nix develop --command just clippy + - run: nix develop --command just bevy-lint + - run: nix develop --command just test - - run: "mise build" - - run: "mise clippy" - - run: "mise bevy_lint" - - run: "mise test" + - name: Export Nix cache + if: always() + run: | + mkdir -p /tmp/nix-cache + nix-store --export $(nix-store -qR $(nix develop --command bash -c 'echo $buildInputs $nativeBuildInputs' 2>/dev/null) 2>/dev/null) > /tmp/nix-cache/archive.nar 2>/dev/null || true diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 4d275e1..84b5372 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -6,9 +6,8 @@ on: env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 - MISE_ENV: ci RUSTFLAGS: -Zcodegen-backend=llvm - RUSTC_WRAPPER: sccache # disabled locally + RUSTC_WRAPPER: sccache jobs: generate-coverage: @@ -21,7 +20,25 @@ jobs: with: submodules: recursive - - name: Cache + - uses: cachix/install-nix-action@v31 + with: + extra_nix_config: | + extra-experimental-features = nix-command flakes + + - name: Cache Nix store + uses: actions/cache@v4 + with: + path: /tmp/nix-cache + key: nix-coverage-${{ matrix.package }}-${{ hashFiles('flake.lock') }} + restore-keys: nix-coverage-${{ matrix.package }}- + + - name: Import Nix cache + run: | + if [ -f /tmp/nix-cache/archive.nar ]; then + nix-store --import < /tmp/nix-cache/archive.nar || true + fi + + - name: Cache Cargo uses: actions/cache@v4 with: path: | @@ -46,22 +63,24 @@ jobs: libwayland-dev ; - - name: Install rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: nightly-2026-01-22 - components: rustc-dev,llvm-tools-preview - - - uses: taiki-e/install-action@cargo-llvm-cov - - uses: taiki-e/install-action@nextest - name: Collect coverage data - run: cargo llvm-cov nextest --manifest-path=./workspace/Cargo.toml -p ${{ matrix.package }} --lcov --output-path report.lcov + run: > + nix develop --command bash -c + "cargo llvm-cov nextest --manifest-path=./workspace/Cargo.toml + -p ${{ matrix.package }} --lcov --output-path report.lcov" - name: Upload to coveralls uses: coverallsapp/github-action@v2.3.6 with: parallel: true flag-name: ${{matrix.package}} + + - name: Export Nix cache + if: always() + run: | + mkdir -p /tmp/nix-cache + nix-store --export $(nix-store -qR $(nix develop --command bash -c 'echo $buildInputs $nativeBuildInputs' 2>/dev/null) 2>/dev/null) > /tmp/nix-cache/archive.nar 2>/dev/null || true + finish: runs-on: ubuntu-latest needs: generate-coverage diff --git a/.gitignore b/.gitignore index 76463b2..7395f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,9 @@ diff __pycache__ + +local.env + +# Nix +/result +.direnv/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 634528e..f23e22c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,87 @@ These crates are all very closely related. It's likely that if you edit one, you'll need to edit another. Additionally, they all use the same build tooling, so overall it's more convenient to have them all in the same place. +``` +qproj/ +├── workspace/ # Cargo workspace root +│ ├── Cargo.toml # Workspace manifest (members = ["crates/*"]) +│ ├── Cargo.lock +│ ├── assets/ +│ └── crates/ +│ ├── app/ # Main game application +│ ├── screens/ # q_screens — screen management plugin +│ ├── term/ # q_term — in-game terminal plugin +│ └── test_harness/ # q_test_harness — shared test utilities +├── submod/bevy # Bevy git submodule (reference only) +├── flake.nix # Nix flake (dev shell, tools, bevy_lint) +├── justfile # Task runner recipes +├── scripts/ # Task scripts invoked by justfile +├── .envrc # direnv integration +├── .config/ +│ └── nextest.toml # Test runner config +├── .cargo/config.toml # Cargo build settings (cranelift, mold) +├── deny.toml # cargo-deny dependency policy +└── .github/workflows/ # CI definitions +``` + +All Cargo commands should target `workspace/Cargo.toml`, e.g. +`cargo build --manifest-path=./workspace/Cargo.toml`. The justfile recipes +handle this automatically. + +## Setup + +Install [Nix](https://nixos.org/download/) and +[direnv](https://direnv.net/docs/installation.html), then: + +```sh +git clone --recurse-submodules https://github.com/ada-x64/qproj.git +cd qproj +direnv allow # Activates the Nix dev shell automatically +just # Lists all available tasks +``` + +Alternatively, without direnv: + +```sh +nix develop # Enter the dev shell manually +just # Lists all available tasks +``` + +The Nix dev shell provides the full toolchain: + +- **Rust nightly-2026-01-22** with cranelift, llvm-tools, and clippy +- **sccache** for compilation caching +- **mold** linker (Linux) +- **bevy_lint** (built from source) +- **cargo-nextest**, **cargo-deny**, **cargo-llvm-cov** +- **just** task runner + +### System dependencies (Linux) + +```sh +sudo apt-get install -y libasound2-dev libudev-dev libwayland-dev +``` + +## Building and running + +| Command | Description | +| -------------- | ---------------------------------------- | +| `just build` | Build the workspace | +| `just play` | Run the application | +| `just check` | Lint with Clippy and bevy_lint | +| `just deny` | Check dependencies with cargo-deny | +| `just test` | Run tests via cargo-nextest | +| `just coverage` | Generate test coverage report | +| `just ci` | Run CI locally with [act](https://github.com/nektos/act) | + +You can pass arguments through to the underlying tools. For example: + +```sh +just test r -p q_term # Test a specific package +just build --release # Release build +just clippy -p q_screens # Lint a specific package +``` + ## Testing Tests are handled @@ -37,6 +118,65 @@ This is used to automatically generate changelogs when we publish. PRs are expected to follow best practices. If you author a PR using an LLM, please disclose that you have done so. All CI checks should pass. +### Running CI locally + +```sh +just ci +# Or target a specific workflow/matrix: +just ci -W ./.github/workflows/ci.yml --matrix target:x86_64-unknown-linux-gnu +``` + +## Code style + +### Conventions + +- **Rust 2024 edition.** All crates use `edition = "2024"`. +- **Prelude pattern.** Each crate re-exports its public API through a + `prelude` module. Internal imports use `pub(crate) use bevy::prelude::*`. +- **Documentation.** Public-facing crates should use `#![deny(missing_docs)]`. +- **Error handling.** Use `tiny_bail` for fallible Bevy systems and `thiserror` + for typed errors. +- **Workspace lints.** Configured in `workspace/Cargo.toml` under + `[workspace.lints]`. All crates inherit these with `[lints] workspace = true`. + +### What the linters check + +CI runs both `clippy` and `bevy_lint`. Make sure both pass before submitting: + +```sh +just check +``` + +### Build profiles + +| Profile | Use case | +| ------------- | ------------------------------- | +| `dev` | Local development (cranelift) | +| `release` | Optimized for size, stripped | +| `dist` | Distribution (max optimization) | +| `wasm-dev` | WebAssembly development | +| `server-dev` | Server/headless development | +| `android-dev` | Android development | + +Dev builds use the **cranelift** codegen backend and the **mold** linker for +fast iteration. Dependencies are built at `opt-level = 3` even in dev. + +## PRs and commit messages + +PRs are squash-merged into a single commit using +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format. +This powers automatic changelog generation. + +Examples: + +``` +feat(screens): add transition animations +fix(term): correct line wrapping on resize +refactor: simplify test harness setup +``` + +All CI checks must pass. If you authored a PR using an LLM, please disclose +that. ## Publishing diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e1bb3b1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,116 @@ +{ + "nodes": { + "bevy-cli-src": { + "flake": false, + "locked": { + "lastModified": 1769978133, + "narHash": "sha256-Swj7j/A7Mgd2ufSADZdGMXOLbmvpdHGJfQVFCaWX9yg=", + "owner": "TheBevyFlock", + "repo": "bevy_cli", + "rev": "c4245c81b32d3391a37f44c613f919b947a29c0d", + "type": "github" + }, + "original": { + "owner": "TheBevyFlock", + "ref": "lint-v0.6.0", + "repo": "bevy_cli", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1773857772, + "narHash": "sha256-5xsK26KRHf0WytBtsBnQYC/lTWDhQuT57HJ7SzuqZcM=", + "owner": "ipetkov", + "repo": "crane", + "rev": "b556d7bbae5ff86e378451511873dfd07e4504cd", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "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": 1773840656, + "narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "bevy-cli-src": "bevy-cli-src", + "crane": "crane", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1774149071, + "narHash": "sha256-SYp8NyzwfCO3Guqmu9hPRHR1hwESlQia5nNz3lYo2qA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "6a031966eab3bfaa19be9e261eed5b8a79c04b18", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "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..54d9ec3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,120 @@ +# ------------------------------------------ +# SPDX-License-Identifier: MIT OR Apache-2.0 +# -------------------------------- 𝒒𝒑𝒓𝒐𝒋 -- +{ + description = "qproj - Bevy game utilities monorepo"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + crane.url = "github:ipetkov/crane"; + bevy-cli-src = { + url = "github:TheBevyFlock/bevy_cli/lint-v0.6.0"; + flake = false; + }; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + rust-overlay, + crane, + bevy-cli-src, + }: + flake-utils.lib.eachDefaultSystem ( + system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system overlays;}; + + # Keep in sync with bevy_cli + rustToolchain = pkgs.rust-bin.nightly."2026-01-22".default.override { + extensions = [ + "rustc-codegen-cranelift-preview" + "rustc-dev" + "llvm-tools-preview" + "clippy" + ]; + targets = [ + "x86_64-pc-windows-msvc" + "x86_64-unknown-linux-gnu" + ]; + }; + + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + + # bevy_lint — rustc driver built from the bevy_cli repository. + # Must use the exact same nightly toolchain since it links + # against rustc internals via #![feature(rustc_private)]. + bevy_lint = craneLib.buildPackage { + src = bevy-cli-src; + pname = "bevy_lint"; + version = "0.6.0"; + cargoExtraArgs = "-p bevy_lint"; + doCheck = false; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [rustToolchain]; + nativeBuildInputs = [pkgs.makeWrapper]; + + postInstall = '' + for bin in $out/bin/bevy_lint $out/bin/bevy_lint_driver; do + [ -f "$bin" ] && wrapProgram "$bin" \ + --prefix LD_LIBRARY_PATH : "${rustToolchain}/lib" + done + ''; + }; + + linuxDeps = pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [ + alsa-lib + udev + wayland + libxkbcommon + vulkan-loader + ]); + in { + devShells.default = pkgs.mkShell { + nativeBuildInputs = [pkgs.pkg-config]; + + buildInputs = + linuxDeps + ++ [ + rustToolchain + bevy_lint + ]; + + packages = with pkgs; [ + sccache + mold + cargo-nextest + cargo-deny + cargo-llvm-cov + act + just + uv + ]; + + shellHook = '' + export CARGO_TERM_COLOR="always" + export PYTHONUNBUFFERED=1 + export RUSTC_WRAPPER="sccache" + + if [ -n "$SSH_CLIENT" ]; then + export FEATURES="" + else + export FEATURES="dylib" + fi + + if [ -f ".env.local" ]; then + source ".env.local" + fi + ''; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath linuxDeps; + }; + } + ); +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..a0080cd --- /dev/null +++ b/justfile @@ -0,0 +1,43 @@ +# ------------------------------------------ +# SPDX-License-Identifier: MIT OR Apache-2.0 +# -------------------------------- 𝒒𝒑𝒓𝒐𝒋 -- + +# Build the workspace. +build *args: + ./scripts/build.sh {{args}} + +# Run the application. +play *args: + ./scripts/play.sh {{args}} + +# Lint with Clippy and bevy_lint. +check *args: + ./scripts/check.sh {{args}} + +# Run clippy. +clippy *args: + ./scripts/clippy.sh {{args}} + +# Run bevy_lint. +bevy-lint *args: + ./scripts/bevy-lint.sh {{args}} + +# Check dependencies with cargo-deny. +deny: + ./scripts/deny.sh + +# Run tests via cargo-nextest. +test *args: + ./scripts/test.sh {{args}} + +# Generate test coverage report. +coverage *args: + ./scripts/coverage.sh {{args}} + +# Fix all fixable issues. +fix *args: + ./scripts/clippy.sh --fix {{args}} + +# Test CI locally with act. +ci *args: + ./scripts/ci.sh {{args}} diff --git a/scripts/bevy-lint.sh b/scripts/bevy-lint.sh new file mode 100755 index 0000000..3379cca --- /dev/null +++ b/scripts/bevy-lint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +RUSTC_WRAPPER="" bevy_lint \ + --manifest-path=./workspace/Cargo.toml \ + --all-features \ + --target-dir=target/bevy_lint "$@" diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..e740292 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -euo pipefail +cargo build --manifest-path=./workspace/Cargo.toml "$@" diff --git a/scripts/check.sh b/scripts/check.sh new file mode 100755 index 0000000..bb718c4 --- /dev/null +++ b/scripts/check.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail +PKG="" +if [[ "${1:-}" != "" ]]; then PKG="-p $1"; fi +scripts/clippy.sh $PKG & +scripts/bevy-lint.sh $PKG & +wait diff --git a/scripts/ci.sh b/scripts/ci.sh new file mode 100755 index 0000000..a5ab511 --- /dev/null +++ b/scripts/ci.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail +docker run \ + --name artifact-server \ + -d -p 8080:8080 \ + --add-host artifacts.docker.internal:host-gateway \ + -e AUTH_KEY=foo \ + ghcr.io/jefuller/artifact-server:latest || true + +act -P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:act-24.04 \ + --env ACTIONS_RUNTIME_URL=http://artifacts.docker.internal:8080/ \ + --env ACTIONS_RUNTIME_TOKEN=foo \ + --env ACTIONS_CACHE_URL=http://artifacts.docker.internal:8080/ \ + --artifact-server-path ../artifacts \ + --env RUSTC_WRAPPER="" \ + "$@" diff --git a/scripts/clippy.sh b/scripts/clippy.sh new file mode 100755 index 0000000..710cd56 --- /dev/null +++ b/scripts/clippy.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail +cargo clippy --manifest-path=./workspace/Cargo.toml --all-features \ + --target-dir=target/clippy "$@" diff --git a/scripts/coverage.sh b/scripts/coverage.sh new file mode 100755 index 0000000..33e29d3 --- /dev/null +++ b/scripts/coverage.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail +if [ $# -eq 0 ]; then + RUSTFLAGS=-Zcodegen-backend=llvm cargo llvm-cov nextest \ + --manifest-path=./workspace/Cargo.toml \ + --html --open +else + RUSTFLAGS=-Zcodegen-backend=llvm cargo llvm-cov nextest \ + --manifest-path=./workspace/Cargo.toml \ + "$@" +fi diff --git a/scripts/deny.sh b/scripts/deny.sh new file mode 100755 index 0000000..61bff27 --- /dev/null +++ b/scripts/deny.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +cargo deny --workspace --manifest-path=./workspace/Cargo.toml \ + -L error \ + check advisories bans sources \ + --hide-inclusion-graph diff --git a/scripts/play.sh b/scripts/play.sh new file mode 100755 index 0000000..01525f2 --- /dev/null +++ b/scripts/play.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -e + +EXAMPLE="" +BUILD_ARGS="" +FILE="workspace/target/debug/app" +ENV_VARS="" +CMD_ARGS="" +ASSETS="./workspace/assets" + +while [[ $# -gt 0 ]]; do + case "$1" in + -x|--example) EXAMPLE="$2"; shift 2 ;; + -B|--build-args) BUILD_ARGS="$2"; shift 2 ;; + -e|--env) ENV_VARS="$2"; shift 2 ;; + -a|--args) CMD_ARGS="$2"; shift 2 ;; + -A|--assets) ASSETS="$2"; shift 2 ;; + *) FILE="$1"; shift ;; + esac +done + +if [ -n "$EXAMPLE" ]; then + CARGO_EXAMPLE="--example $EXAMPLE" +fi + +just build ${BUILD_ARGS:-} ${CARGO_EXAMPLE:-} + +if [ -n "$EXAMPLE" ]; then + TARGET_PATH="./workspace/target/debug/examples/$EXAMPLE" +else + TARGET_PATH="$FILE" +fi + +if [ -n "${SSH_CLIENT:-}" ]; then + set -x + PSYNC_LOG=debug uvx --from cubething_psync psync \ + "$TARGET_PATH" -e "${ENV_VARS}" -a "${CMD_ARGS}" -A "${ASSETS}" +else + set -x + exec "$TARGET_PATH" ${CMD_ARGS} +fi diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..ba2ebb5 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -ex +if [ $# -eq 0 ]; then + cargo nextest \ + --config-file=./.config/nextest.toml \ + --manifest-path=./workspace/Cargo.toml \ + r --workspace +else + cargo nextest \ + --config-file=./.config/nextest.toml \ + --manifest-path=./workspace/Cargo.toml \ + "$@" +fi