git-next 2025.12.1

trunk-based development manager
git-host := "git.kemitix.net"
repo-name := "kemitix/git-next"
docker-test-image := git-host + "/" + repo-name + ":test"
docker-latest-image := git-host + "/" + repo-name + ":latest"
rust-latest-image := git-host + "/kemitix/rust:latest"

# list available recipes
default:
  just --list

# Monitor the status in a continuous loop
watch-status:
  viddy just status

# shows the project jj status
status:
  jj --color always

# Checks for any conflicts in the current change, and if clean builds and verifies the project
check:
  test "$(jj log -r '@' --no-graph --color=never -T 'conflict')" = "false"
  just build

# Advances the jujutsu workspace to edit the next change
advance:
  jj next --edit

# Performs a `check` then and `advance` in a loop until either the check fails of there are no clear jujutsu changes to advance to
build-forward:
  while (just check && just advance) ; do : ; done

# Generate LLVM code coverate in HTML
generate-coverage:
  cargo llvm-cov nextest --html

# starts a webserver on port 1111 for the LLVM code coverate report
serve-coverage:
  miniserve -p 1111 target/llvm-cov/html/

# build and verify the project
build:
  #!/usr/bin/env bash
  set -e
  cargo fmt
  cargo fmt --check
  forgejo-todo-checker --workspace $PWD --site https://{{ git-host }} --repo {{ repo-name }}
  cargo machete
  cargo clippy --all-targets -- -Dwarnings
  cargo check
  cargo test
  cargo doc
  # cargo test --example get
  # cargo mutants --jobs 4

# emulates the CI build process
ci:
  #!/usr/bin/env bash
  set -e
  cargo fmt
  cargo fmt --check
  forgejo-todo-checker --workspace $PWD --site https://{{ git-host }} --repo {{ repo-name }}
  cargo machete
  cargo hack --feature-powerset clippy --all-targets -- -Dwarnings
  cargo hack --feature-powerset check
  cargo hack --feature-powerset test
  cargo doc
  # cargo test --example get
  # cargo mutants --jobs 4

# check for linting errors
clippy:
  cargo clippy --all-targets -- -Dwarnings

# run the tests in a docker image
test-in-docker:
  docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/app/ {{ rust-latest-image }} cargo test

# starts an interactive shell in the docker image
shell-in-docker:
  docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ {{ rust-latest-image }} bash

# build the docker images
build-docker-test:
  docker build . -t {{ docker-test-image }}

docker-build:
  docker build -t {{ docker-latest-image }} . 
 
docker-run: docker-build
  docker run -it -p "7777:8888" -v .:/app/ {{ docker-latest-image }} server start --ui
 
# run the project
# Runs the built project inside a docker image
run-in-docker: build-docker-test
  docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/app/ {{ docker-test-image }} server start

# Runs the build project, using the TUI interface, inside a docker image
run-ui-in-docker: build-docker-test
  docker run --rm -u $(id -u):$(id -g) -it -v ${PWD}:/app/ {{ docker-test-image }} server start --ui

mock-ci:
  cargo fmt --check
  cargo hack --feature-powerset check
  cargo hack --feature-powerset test
  cargo hack --feature-powerset clippy
 
run *args:
  cargo run -- {{ args }}

# run the project using the interactive TUI
run-ui:
  just run server start --ui

# Push the tagged docker images to codeberg
publish-docker-image tag:
  docker pull {{ git-host }}/{{ repo-name }}:{{ tag }}
  docker tag {{ git-host }}/{{ repo-name }}:{{ tag }} codeberg.org/{{ repo-name }}:{{ tag }}
  docker push codeberg.org/{{ repo-name }}:{{ tag }}