|
| 1 | +#!/bin/bash |
| 2 | +#### BEGIN SETUP ##### |
| 3 | +set -euo pipefail |
| 4 | +this=$(realpath -- "$0"); readonly this |
| 5 | +cd "$(dirname "$this")" |
| 6 | +shellcheck --external-sources "$this" |
| 7 | +# shellcheck source=lib.sh |
| 8 | +source 'lib.sh' |
| 9 | +#### END SETUP #### |
| 10 | + |
| 11 | +# TODO: send model to ctest_model tests using env variable |
| 12 | +# GG_TEST_CTEST_MODEL_MODELFILE=<snip> |
| 13 | + |
| 14 | +is_valid_test_target() { |
| 15 | + case "$1" in |
| 16 | + cmake | ctest_main | model_3b | model_7b | test_cpu | test_cuda | test_metal | ctest_model) |
| 17 | + return 0;; |
| 18 | + *) |
| 19 | + return 1;; |
| 20 | + esac |
| 21 | +} |
| 22 | + |
| 23 | +declare -a test_targets |
| 24 | +if (( $# > 0 )); then |
| 25 | + test_targets=("$@") |
| 26 | +elif _isset GG_TEST_TARGETS; then |
| 27 | + read -r -a test_targets <<< "$GG_TEST_TARGETS" |
| 28 | +else |
| 29 | + cat >&2 <<'EOF' |
| 30 | +You must specify the test targets either as commandline arguments or using the |
| 31 | +GG_TEST_TARGETS environment variable. Test targets will be run sequentially |
| 32 | +in-order. |
| 33 | +
|
| 34 | +Some test targets depend on other test targets, as described below. |
| 35 | +
|
| 36 | +cli usage: |
| 37 | + ci-run.sh test_targets... |
| 38 | +
|
| 39 | +ci usage: |
| 40 | + GG_TEST_TARGETS='test_targets...' ci-run.sh |
| 41 | +
|
| 42 | +example: |
| 43 | + # This is a typical run for a low-spec host without a dedicated GPU. |
| 44 | + ci-run.sh cmake ctest_main model_3b test_cpu ctest_model |
| 45 | +
|
| 46 | +test targets: |
| 47 | + cmake : run cmake to produce debug and release builds |
| 48 | + ctest_main : run main ctest tests for debug and release |
| 49 | + (requires: cmake) |
| 50 | + model_3b : download and quantize openllama_3b_v2 |
| 51 | + model_7b : download and quantize openllama_7b_v2 |
| 52 | + test_cpu : test CPU inference, perplexity tests, etc. |
| 53 | + (requires: model_3b or model_7b) |
| 54 | + test_cuda : test CUDA ... |
| 55 | + (requires: model_3b or model_7b) |
| 56 | + test_metal : test Metal ... |
| 57 | + ctest_model : run ctest tests that require the openllama model |
| 58 | + (requires: model_3b or model_7b) |
| 59 | +EOF |
| 60 | + exit 1 |
| 61 | +fi |
| 62 | + |
| 63 | +for target in "${test_targets[@]}"; do |
| 64 | + if is_valid_test_target "$target"; then |
| 65 | + _log_info "Received test target: $target" |
| 66 | + else |
| 67 | + _log_fatal "Invalid test target: $target" |
| 68 | + fi |
| 69 | +done |
0 commit comments