Skip to content
Merged
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
33 changes: 30 additions & 3 deletions .githooks/pre-commit
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,38 @@

echo "Running pre-commit hook..."

# Navigate to frontend directory from repo root
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT/frontend" || exit 1
STAGED_FILES=$(git diff --cached --name-only)
NEEDS_TOOLCHAIN=0

if ! command -v bun >/dev/null 2>&1; then
NEEDS_TOOLCHAIN=1
fi

if echo "$STAGED_FILES" | grep -Eq '^frontend/src-tauri/.*\.(rs|toml|lock)$' \
&& ! command -v cargo >/dev/null 2>&1; then
NEEDS_TOOLCHAIN=1
fi

if [ "$NEEDS_TOOLCHAIN" -eq 1 ]; then
if [ "${MAPLE_HOOK_NIX_BOOTSTRAPPED:-0}" = "1" ]; then
echo "Error: Maple's Nix development shell did not provide the required tools."
exit 1
fi

if command -v nix >/dev/null 2>&1 && [ -f "$REPO_ROOT/flake.nix" ]; then
echo "Required tools are not on PATH; entering the Maple Nix development shell..."
exec nix develop "$REPO_ROOT" -c env MAPLE_HOOK_NIX_BOOTSTRAPPED=1 \
"$REPO_ROOT/.githooks/pre-commit"
fi

echo "Error: This hook requires bun, plus cargo for staged Rust changes."
echo "Install the missing tools or run the commit from 'nix develop'."
exit 1
fi

# Navigate to frontend directory from repo root
cd "$REPO_ROOT/frontend" || exit 1

# Run prettier check
echo "Checking code formatting with Prettier..."
Expand DownExpand Up@@ -35,7 +63,6 @@ if ! bun run test; then
fi

# Run Rust unit tests only when relevant Rust/Tauri files are staged
STAGED_FILES=$(git diff --cached --name-only)
if echo "$STAGED_FILES" | grep -Eq '^frontend/src-tauri/.*\.(rs|toml|lock)$'; then
echo "Running Rust unit tests..."
cd "$REPO_ROOT/frontend/src-tauri" || exit 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/desktop-build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ permissions:

on:
push:
branches: [master]
branches: [master]

jobs:
build-macos:
Expand DownExpand Up@@ -239,7 +239,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # was stable
with:
toolchain: 1.88.0
toolchain: 1.94.1

- name: Install sccache
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/desktop-pr-build.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ permissions:

on:
pull_request:
branches: [master]
branches: [master]

jobs:
build-macos:
Expand DownExpand Up@@ -138,7 +138,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # was stable
with:
toolchain: 1.88.0
toolchain: 1.94.1

- name: Install sccache
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -191,7 +191,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # was stable
with:
toolchain: 1.88.0
toolchain: 1.94.1

- name: Install sccache
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-tests.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,9 +5,9 @@ permissions:

on:
push:
branches: [master]
branches: [master]
pull_request:
branches: [master]
branches: [master]

jobs:
rust-tests:
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,11 @@ rustup target add aarch64-apple-darwin x86_64-apple-darwin
./setup-hooks.sh
```

This will configure git to use the project's pre-commit hooks, which run `bun run build` before each commit.
This configures Git to use the project's pre-commit hook. Managed
`opensecret-workspaces` checkouts enable the same hook automatically. The hook
checks formatting, builds the frontend, runs frontend tests, and runs Rust tests
when Tauri files are staged. If Bun or Cargo is not already available and Nix
is installed, the hook enters this repository's Nix development shell.

## Development

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@

versions = {
bun = "1.3.5";
rust = "1.88.0";
rust = "1.94.1";
jdk = "21";
xcode = "26.5";
android = {
Expand Down
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# Public OpenSecret project id. Optional; the app uses this value by default.
VITE_CLIENT_ID=ba5a14b5-d915-47b1-b7b1-afda52bc5fc6
VITE_OPEN_SECRET_API_URL=http://127.0.0.1:3000
#VITE_OS_FLAGS_BASE_URL=https://flags-dev.opensecret.cloud
#VITE_MAPLE_BILLING_API_URL=http://127.0.0.1:3001
#VITE_DEV_MODEL_OVERRIDE=gpt-4o
Loading
Loading