mirror of
https://github.com/anoma/juvix.git
synced 2024-08-16 11:40:36 +03:00
b0fb240219
This PR changes the CI build to use the justfile instead of the Makefile to run builds and tests. CI builds now take advantage of parallel module builds from https://github.com/anoma/juvix/pull/2729. In order support this the runtime build target in the justfile now supports `runtimeCcArg` and `runtimeLibtoolArg` so that the `CC` and `LIBTOOL` Makefile argument can be set. This is required for the macOS build. In addition this PR upgrades the stack setup step action. Previously the stack build flags included `--fast` which meant the whole project was rebuilt in the `test` step, this has also been fixed. Overall this speeds up the CI: * Linux now takes 30mins (from 40mins) * macOS now takes 60mins (from 80mins)
159 lines
4.5 KiB
Makefile
159 lines
4.5 KiB
Makefile
# set to non-empty string to disable parallel builds and tests
|
|
#
|
|
# e.g:
|
|
# just disableParallel=yes test
|
|
disableParallel := ''
|
|
|
|
# set to non-empty string to enable optimzed build
|
|
#
|
|
# e.g:
|
|
# just enableOptimized=yes install
|
|
enableOptimized := ''
|
|
|
|
# set to non-empty string to enable command debugging
|
|
enableDebug := ''
|
|
|
|
# set to number of parallel jobs
|
|
numParallelJobs := ''
|
|
|
|
# the command used to run stack
|
|
stack := "stack"
|
|
|
|
# the command used to run ormolu
|
|
ormolu := "ormolu"
|
|
|
|
# The CC argument to the runtime Makefile
|
|
runtimeCcArg := ''
|
|
|
|
# The LIBTOOL argument to the runtime Makefile
|
|
runtimeLibtoolArg := ''
|
|
|
|
# The flags used in the runtime make commands
|
|
runtimeCcFlag := if runtimeCcArg == '' { '' } else { "CC=" + runtimeCcArg }
|
|
runtimeLibtoolFlag := if runtimeLibtoolArg == '' { '' } else { "LIBTOOL=" + runtimeLibtoolArg }
|
|
runtimeArgs := trim(runtimeCcFlag + ' ' + runtimeLibtoolFlag)
|
|
|
|
# flags used in the stack command
|
|
stackOptFlag := if enableOptimized == '' { '--fast' } else { '' }
|
|
# The ghc `-j` flag defaults to number of cpus when no argument is passed
|
|
stackGhcParallelFlag := if disableParallel == '' { "--ghc-options=-j" + numParallelJobs } else { '' }
|
|
# The stack `-j` options requires an argument
|
|
stackParallelFlagJobs := if numParallelJobs == '' { num_cpus() } else { numParallelJobs }
|
|
stackParallelFlag := if disableParallel == '' { '-j' + stackParallelFlagJobs } else { '' }
|
|
stackArgs := stackOptFlag + ' ' + stackParallelFlag + ' ' + stackGhcParallelFlag
|
|
|
|
# flags used in the stack test command
|
|
testArgs := "--hide-successes"
|
|
rtsFlag := if disableParallel == '' { '+RTS -N -RTS' } else { '' }
|
|
|
|
# flag used to enable tracing of bash commands
|
|
bashDebugArg := if enableDebug == '' { '' } else { 'x' }
|
|
|
|
[private]
|
|
default:
|
|
@just --list
|
|
|
|
@_ormoluCmd filesCmd:
|
|
{{ trim(filesCmd) }} \
|
|
| xargs -r {{ ormolu }} --no-cabal \
|
|
--ghc-opt -XStandaloneDeriving \
|
|
--ghc-opt -XUnicodeSyntax \
|
|
--ghc-opt -XDerivingStrategies \
|
|
--ghc-opt -XPatternSynonyms \
|
|
--ghc-opt -XMultiParamTypeClasses \
|
|
--ghc-opt -XTemplateHaskell \
|
|
--ghc-opt -XImportQualifiedPost \
|
|
--ghc-opt -XBangPatterns \
|
|
--mode inplace
|
|
|
|
# Formats all Haskell files in the project. `format changed` formats only changed files. `format FILES` formats individual files.
|
|
format *opts:
|
|
#!/usr/bin/env bash
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
|
|
opts='{{ trim(opts) }}'
|
|
|
|
case $opts in
|
|
"")
|
|
just _ormoluCmd "git ls-files '*.hs'"
|
|
;;
|
|
changed)
|
|
just _ormoluCmd \
|
|
"(git --no-pager diff --name-only --diff-filter=AM && git --no-pager diff --cached --name-only --diff-filter=AM) | grep '\\.hs\$'"
|
|
;;
|
|
*)
|
|
just _ormoluCmd "echo {{ opts }}"
|
|
;;
|
|
esac
|
|
|
|
# Run the tests in the project. Use the filter arg to set a Tasty pattern.
|
|
[no-exit-message]
|
|
test *filter:
|
|
#!/usr/bin/env bash
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
filter='{{ trim(filter) }}'
|
|
if [ -n "$filter" ]; then
|
|
filter="-p \"$filter\""
|
|
fi
|
|
set -x
|
|
{{ stack }} test {{ stackArgs }} --ta "{{ testArgs }} {{ rtsFlag }} $filter"
|
|
|
|
# Run a juvix command and profile it
|
|
run-profile +cmd:
|
|
cabal run --enable-profiling juvix -- {{ cmd }} +RTS -p
|
|
|
|
# Build the juvix runtime
|
|
_buildRuntime:
|
|
cd runtime && make {{ runtimeArgs }} -j 4 -s
|
|
|
|
# Build the project. `build runtime` builds only the runtime.
|
|
[no-exit-message]
|
|
build *opts:
|
|
#!/usr/bin/env bash
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
opts='{{ trim(opts) }}'
|
|
|
|
case $opts in
|
|
runtime)
|
|
just runtimeArgs="{{ runtimeArgs }}" _buildRuntime
|
|
;;
|
|
*)
|
|
just runtimeArgs="{{ runtimeArgs }}" _buildRuntime
|
|
set -x
|
|
{{ stack }} build {{ stackArgs }}
|
|
;;
|
|
esac
|
|
|
|
# Install juvix
|
|
[no-exit-message]
|
|
install: _buildRuntime
|
|
{{ stack }} install {{ stackArgs }}
|
|
|
|
# Clean all .juvix-build directories in the project
|
|
_cleanJuvixBuild:
|
|
@find . -type d -name '.juvix-build' | xargs rm -rf
|
|
|
|
# Clean the juvix runtime build directory
|
|
_cleanRuntime:
|
|
@cd runtime && make clean
|
|
|
|
# Clean the project. `clean runtime` cleans only the runtime. `clean juvix-build` cleans only juvix-build dirs.
|
|
clean *opts:
|
|
#!/usr/bin/env bash
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
opts='{{ trim(opts) }}'
|
|
|
|
case $opts in
|
|
runtime)
|
|
just _cleanRuntime
|
|
;;
|
|
juvix-build)
|
|
just _cleanJuvixBuild
|
|
;;
|
|
*)
|
|
just _cleanRuntime
|
|
just _cleanJuvixBuild
|
|
{{ stack }} clean --full
|
|
;;
|
|
esac
|