Skip to content

Advanded configurations

Dídac Coll Pujals edited this page Jun 17, 2021 · 6 revisions

Table of contents

Overview

Example of .shusky.yml configuration:

pre-push:
    - run:
        command: set -o pipefail && swift test 2>&1 | xcpretty --color
        critical: false
pre-commit:
    - swift-run:
        command: swiftformat .
        configuration: release
        package-path: BuildTools
    - swift-run:
        command: swiftlint lint --strict .
        configuration: release
        package-path: BuildTools
        verbose: false
        critical: true
    - run:
        command: swift test --generate-linuxmain
        verbose: false
    - swift-run:
        command: periphery scan
        configuration: release
        package-path: BuildTools
    - git add -A

NOTE: By default all commands run verbose and are set critical.

Avaialable hooks

  • applypatch-msg
  • pre-applypatch
  • post-applypatch
  • pre-commit
  • pre-merge-commit
  • prepare-commit-msg
  • commit-msg
  • post-commit
  • pre-rebase
  • post-checkout
  • post-merge
  • pre-push

Shusky config keys

verbose: bool: Set if all commands are verbose or not. By default is true. It doesn't need to define if you want that all commands become verbose.

verbose: false
pre-push:
    - set -o pipefail && swift test 2>&1 | xcpretty --color
pre-commit:
    - swift run -c release swiftformat .
    - swift run -c release swiftlint lint .
    - git add -A

Run

run: Special option for running advanced configurations in commands

pre-commit:
    - swift run -c release --package-path BuildTools swiftformat .
    - swift run -c release --package-path BuildTools swiftlint lint .
    - run: 
        command: set -o pipefail && swift test 2>&1 | xcpretty --color
        verbose: false
        critical: false
verbose: bool: Set if a concrete command is verbose or not.

pre-commit:
    - swift run -c release --package-path BuildTools swiftformat .
    - swift run -c release --package-path BuildTools swiftlint lint .
    - run: 
        command: set -o pipefail && swift test 2>&1 | xcpretty --color
        verbose: false
critical: bool: Set if a concrete command is critical or not. If not critical and the command fail will keep executing git hook. By default is true and there is no need to define it if you want that git hook stops when a command fails.

pre-commit:
    - swift run -c release --package-path BuildTools swiftformat .
    - swift run -c release --package-path BuildTools swiftlint lint .
    - run: 
        command: set -o pipefail && swift test 2>&1 | xcpretty --color
        critical: false

If the command fails, it will warn you.

Swift-run

swift-run: This option will try running binary if exists, if not will execute swift run.

pre-commit:
    - swift-run:
        command: swiftlint lint .
  • If the binary exists will run: ./.build/debug/swiftlint lint ./.
  • If the binary doesn't exist will run: swift run swiftlint lint ./.

Other options are available:

configuration: string: Can be release or debug.

pre-commit:
    - swift-run:
        command: swiftlint lint .
        configuration: release
  • If the binary exists will run: ./.build/release/swiftlint lint ..
  • If the binary doesn't exist will run: swift run -c release swiftlint lint ..
package-path: string: Package.swift path

pre-commit:
    - swift-run:
        command: swiftlint lint .
        package-path: BuildTools
  • If the binary exists will run: ./BuildTools/.build/debug/swiftlint lint ..
  • If the binary doesn't exist will run: swift run --package-path BuildTools swiftlint lint ..
build-path: string: Binary path

pre-commit:
    - swift-run:
        command: swiftlint lint .
        package-path: BuildTools
        build-path: my-build-path/path/.spm
  • If the binary exists will run: ./my-build-path/path/.spm/debug/swiftlint lint ..
  • If the binary doesn't exist will run: swift run --build-path my-build-path/path/.spm --package-path BuildTools swiftlint lint ..
jobs: int: Number of jobs for building the binary.

pre-commit:
    - swift-run:
        command: swiftlint lint .
        jobs: 10
  • If the binary exists will run: ./.build/debug/swiftlint lint ..
  • If the binary doesn't exist will run: swift run --jobs 10 swiftlint lint ..
verbose: bool

pre-commit:
    - swift-run:
        command: swiftlint lint .
        verbose: false
critical: bool

pre-commit:
    - swift-run:
        command: swiftlint lint .
        critical: false
Clone this wiki locally