diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 2f624e8..8d5be6b 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -12,14 +12,12 @@ jobs: - name: "Checkout Codebase" uses: "actions/checkout@v4" - - name: "Install nix" - uses: "cachix/install-nix-action@v27" - with: - nix_path: "nixpkgs=channel:nixos-24.05" + - name: "Install Nix" + uses: "DeterminateSystems/nix-installer-action@v16" - - name: "Use Magic Nix cache" - uses: "DeterminateSystems/magic-nix-cache-action@v7" + - name: "Use Nix Cache" + uses: "DeterminateSystems/magic-nix-cache-action@v8" - name: "Check, Test and Build" run: | - nix-shell --pure --run "cabal update --ignore-project && dev-test-build" + nix-shell --pure --run "cabal update --ignore-project && cabal dev-test-build" diff --git a/README.md b/README.md index ba2c415..74bc946 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,22 @@ hpack && cabal haddock -O0 ``` -To test and build codebase in development environment, run: +To run checks, tests and build the codebase in the development environment, run: ```sh -dev-test-build +cabal-dev-test-build +``` + +You can pass `-c` to clean the build artifacts first: + +```sh +cabal-dev-test-build -c +``` + +As of Cabal 3.12, you can now run the above as an external `cabal` command: + +```sh +cabal dev-test-build [-c] ``` diff --git a/default.nix b/default.nix index b950431..5bfde38 100644 --- a/default.nix +++ b/default.nix @@ -67,7 +67,7 @@ let ## Prepare dev-test-build script: dev-test-build = pkgs.writeShellApplication { - name = "dev-test-build"; + name = "cabal-dev-test-build"; text = builtins.readFile ./nix/dev-test-build.sh; runtimeInputs = [ pkgs.bash pkgs.bc pkgs.moreutils ]; }; diff --git a/nix/dev-test-build.sh b/nix/dev-test-build.sh index 37c7885..80652b4 100644 --- a/nix/dev-test-build.sh +++ b/nix/dev-test-build.sh @@ -44,6 +44,16 @@ fi _clean="" +## Check if we are an cabal external command: +CABAL="${CABAL:-}" +if [ -n "${CABAL}" ]; then + _cabal="${CABAL}" + shift +else + _cabal="$(command -v cabal)" +fi + +## Parse options: while getopts ":c" opt; do case ${opt} in c) @@ -80,7 +90,7 @@ _print_success() { _clean() { _print_header "clean" _start=$(_get_now) - chronic -- cabal clean && chronic -- cabal v1-clean + chronic -- "${_cabal}" clean && chronic -- "${_cabal}" v1-clean _print_success "${_start}" "$(_get_now)" } @@ -120,23 +130,23 @@ _hlint() { } _cabal_build() { - _print_header "cabal build (v$(cabal --numeric-version))" + _print_header "cabal build (v$("${_cabal}" --numeric-version))" _start=$(_get_now) - chronic -- cabal build -O0 + chronic -- "${_cabal}" build -O0 _print_success "${_start}" "$(_get_now)" } _cabal_run() { - _print_header "cabal run (v$(cabal --numeric-version))" + _print_header "cabal run (v$("${_cabal}" --numeric-version))" _start=$(_get_now) - chronic -- cabal run -O0 haskell-template-hebele -- --version + chronic -- "${_cabal}" run -O0 haskell-template-hebele -- --version _print_success "${_start}" "$(_get_now)" } _cabal_test() { - _print_header "cabal test (v$(cabal --numeric-version))" + _print_header "cabal test (v$("${_cabal}" --numeric-version))" _start=$(_get_now) - chronic -- cabal v1-test + chronic -- "${_cabal}" v1-test _print_success "${_start}" "$(_get_now)" } @@ -147,10 +157,17 @@ _weeder() { _print_success "${_start}" "$(_get_now)" } +_stan() { + _print_header "stan ($(stan --version | head -n 1 | cut -f 2 -d " "))" + _start=$(_get_now) + chronic -- stan --hiedir ./dist-newstyle + _print_success "${_start}" "$(_get_now)" +} + _cabal_haddock() { - _print_header "cabal haddock (v$(cabal --numeric-version))" + _print_header "cabal haddock (v$("${_cabal}" --numeric-version))" _start=$(_get_now) - chronic -- cabal haddock -O0 \ + chronic -- "${_cabal}" haddock -O0 \ --haddock-quickjump \ --haddock-hyperlink-source \ --haddock-html-location="https://hackage.haskell.org/package/\$pkg-\$version/docs" @@ -169,6 +186,7 @@ _hlint _cabal_build _cabal_run _cabal_test +_stan _weeder _cabal_haddock printf "Finished all in %ss\n" "$(_get_diff "${_scr_start}" "$(_get_now)")"