Skip to content

Integrations

Scilo can be run on its own or integrated with other tools for easier consistency across teams.

Git hooks

Git hooks automatically run code when you perform some operation in git, like a commit or a push. Two useful hooks to consider are the pre-commit and pre-push hooks, which, as the names imply, are run before a commit is made or before commits are pushed to a remote 1.

Git hooks are installed in the .git/hooks/ directory in a repository, which are not synced across copies of the repository. If you're going to use them, you need to set them up in each repository copy. You can do this manually or using one of the tools listed below.

Hooks API

In Git v2.54, you can declare hooks via a configuration file.

.git/config
[hook "scilo"]
  event = pre-commit
  command = scilo lint

You can enter this manually, or configure it from the command line.

git config set hook.scilo.command scilo lint
git config set --append hook.scilo.event pre-commit
.git/config
[hook "scilo"]
  event = pre-push
  command = scilo lint

You can enter this manually, or configure it from the command line.

git config set hook.scilo.command scilo lint
git config set --append hook.scilo.event pre-push
.git/config
[hook "scilo"]
  event = pre-commit
  event = pre-push
  command = scilo lint

You can enter this manually, or configure it from the command line.

git config set hook.scilo.command scilo lint
git config set --append hook.scilo.event pre-commit
git config set --append hook.scilo.event pre-push

Manual configuration

To run scilo as a pre-commit hook, create and/or edit the .git/hooks/pre-commit file to include:

.git/hooks/pre-commit
scilo lint

Please ensure the file is executable, too.

chmod +x .git/hooks/pre-commit

To run scilo as a pre-push hook, create and/or edit the .git/hooks/pre-push file to include:

.git/hooks/pre-push
scilo lint

Please ensure the file is executable, too.

chmod +x .git/hooks/pre-push

To run scilo as both a pre-commit and pre-push hook, create and/or edit both files in .git/hooks/ to include:

.git/hooks/pre-commit
scilo lint
.git/hooks/pre-push
scilo lint

Please ensure the files are executable, too.

chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/pre-push

Pre-commit

pre-commit is a tool to manage git pre-commit hooks within the repository itself. Install pre-commit using your environment or package manager of choice, then add the following lines to the .pre-commit-config.yaml file in the project's root directory:

.pre-commit-config.yaml
repos:
  - repo: https://gitlab.com/jrhawley/scilo
    rev: v0.3.0
    hooks:
    - id: lint

If you already have a .pre-commit-config.yaml file with existing hooks and a repo: header, don't duplicate the repos: line. For example:

.pre-commit-config.yaml
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks # (1)!
    rev: v1.2.3
    hooks:
    -   id: trailing-whitespace
  - repo: https://gitlab.com/jrhawley/scilo # (2)!
    rev: v0.3.0
    hooks:
    - id: lint
  1. This is a pre-commit hook from another repository
  2. This is the pre-commit hook from scilo

The lint hook runs all configured lints on the project. If you only want to run a subset of lints, you can list the ids of the selected lints. For example:

.pre-commit-config.yaml
repos:
  - repo: https://gitlab.com/jrhawley/scilo
    rev: v0.3.0
    hooks: # (1)!
    - id: root_dirs
    - id: root_files
  1. These hooks will only check for required directories and files in the project root.

Alternatively, you can leave - id: lint alone in .pre-commit-config.yaml and configure which lints run in the configuration file. Running scilo lint from the terminal or through pre-commit will respect the configuration in the project's scilo.toml file.

Prek

prek is a drop-in replacement of pre-commit, built in Rust with slightly different goals in mind. If you use prek instead of pre-commit, the above configuration for pre-commit should still work.

Shell completions

Scilo can integrate with your terminal shell of choice, allowing autocompletion when doubled-pressing Tab. To add scilo completions for supported shells, add the following to your shell's configuration file:

~/.bashrc
source <(scilo completions bash)
~/.config/elvish/rc.elv
eval (scilo completions elvish)
~/.config/fish/config.fish
scilo completions fish | source
$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
scilo completions powershell | Out-String | Invoke-Expression
~/.zshrc
autoload -U compinit
compinit
source <(scilo completions bash)

  1. See this blog post for concerns about pre-commit hooks and where pre-push hooks are preferable.