Skip to main content

ci/ts

1#!/usr/bin/env bash
3set -o errexit
4set -o nounset
6function run_go_tests() {
7 # Look for changed Go packages, and pass the list to `go test`.
8 if test -e "./tool/go"; then
9 GO="./tool/go"
10 else
11 GO=$(which go)
12 fi
14 CHANGED_PACKAGES=$(
15 git ls-files --modified \
16 | xargs dirname \
17 | uniq \
18 | xargs -I '{}' echo "./{}" \
19 | tr '\n' ' '
20 )
22 print_info "-> $GO test $CHANGED_PACKAGES"
23 "$GO" test $CHANGED_PACKAGES
26function run_rust_tests() {
27 print_info "-> cargo fmt"
28 cargo fmt
30 echo ""
32 print_info "-> cargo build"
33 cargo build
35 echo ""
37 print_info -n "-> cargo test"
38 cargo test --quiet
41if test -f Cargo.toml
42then
43 run_rust_tests
44elif test -f go.mod
45then
46 run_go_tests
48# If there's a `scripts` folder with a test script, run that
49elif find "scripts" -name 'run_*_tests.sh' >/dev/null 2>&1
50then
51 print_info "-> bash scripts/run_*_tests.sh"
52 bash scripts/run_*_tests.sh
54else
55 echo "No run_*_tests.sh runner found in scripts!" 2>&1
56 exit 1
57fi