Skip to content

Instantly share code, notes, and snippets.

@edvardm
Last active July 5, 2024 08:54
Show Gist options
  • Save edvardm/dea4c456d0ae6d6627e35eb2362aa729 to your computer and use it in GitHub Desktop.
Save edvardm/dea4c456d0ae6d6627e35eb2362aa729 to your computer and use it in GitHub Desktop.
sample common rules with Justfiles
### resource/common.just
# std set of rules for all projects. Should be overridden in
# project-specific justfiles, preferably using same signature if possible
# (think this as an interface in programming languages).
# Basically it means that if a base rule doesn't accept parameters,
# overridden version should also do without those unless necessary
# DISCLAIMER: it's probably quite hard to end up with general, valid "signature" for all rules
# without making it insufficient for some users and unnecessary complex for others, so maybe
# rule names themselves and their precense could be considered to be more strict than
# parameters to those
# TODO: how to get list of all rules by running a command by not showing those that are not implemented?
# there should be also probably option to list all unimplemented tasks
# prepare project ready for development
dev-init: # MAY prompt user for confirmation
echo "not implemented"
# list unimplemented tasks
not-implemented:
# should be probably a feature in the tool
# build the project
build env="dev": # env could be also production, test etc
echo "not implemented"
# run automated tests
test opts="": # opts should be passed to test runner after fixed parameters
echo "not implemented"
# run static code analysis and other linting tools
lint mode="": # by default just run mandatory linters
echo "not implemented"
# automatically format code
format:
echo "not implemented"
# install application
install:
echo "not implemented"
# validate project setup
validate:
echo "not implemented"
# generate project documentation
build-docs:
echo "not implemented"
# start the application in debug mode
debug opts="": # pass opts to application after fixed arguments
echo "not implemented"
# prepare new release
prepare-release:
echo "not implemented"
# create new release
release:
echo "not implemented"
# publish to a package registry/index
publish:
echo "not implemented"
# in service.just
# start service
serve:
echo "not implemented"
# deploy the application to a server or cloud
deploy env="dev" version="":
echo "not implemented"
# in resource/docker.just
# build docker image, parameterized for dev and prod versions
docker-build env="production":
echo "not implemented"
# run application with docker
docker-run:
echo "not implemented"
# run (application) shell in docker container for debugging
docker-shell:
echo "not implemented"
# run tests in docker container
docker-test:
echo "not implemented"
# in project-specific justfile
include resource/common.just
set allow-duplicate-recipes
#
# Override common rules. Note that even though dev-init depends on custom rules,
# it's "signature" is same as in common.just, meaning it doesn't take any arguments
#
dev-init: (build "dev") install-dev-tools setup-pre-commit validate
build env="dev":
cargo build
validate: _validate_rust_toolchain
# custom rules
[confirm("ok to install xh and pre-commit?")]
[unix]
install-dev-tools:
brew install xh pre-commit
setup-pre-commit:
pre-commit install
reticulate-splines:
echo "reticulating splines"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment