ci: Simplify run_test.sh script.
Run tests and linters against a hard-coded set of local submodules instead of attempting to find submodules dynamically. While this has the obvious drawback of needing to manually update the list of submodules, it greatly simplifies the script by removing a bunch of regexes and string manipulation. This trade-off seems worthwhile because the list of submodules in this repo will not be something which changes often. This change makes the script less brittle because it is hard-coded to always run against the local code, regardless of any changes to module versionining or project dependencies.
This commit is contained in:
parent
6e558fb283
commit
1720fd2062
45
run_tests.sh
45
run_tests.sh
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020-2023 The Decred developers
|
# Copyright (c) 2020-2024 The Decred developers
|
||||||
# Use of this source code is governed by an ISC
|
# Use of this source code is governed by an ISC
|
||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
@ -11,30 +11,33 @@ set -e
|
|||||||
|
|
||||||
go version
|
go version
|
||||||
|
|
||||||
# Run tests on root module and all submodules.
|
# This list needs to be updated if new submodules are added to the vspd repo.
|
||||||
echo "==> test all modules"
|
submodules="client types"
|
||||||
ROOTPKG="github.com/decred/vspd"
|
|
||||||
GORACE="halt_on_error=1" go test -race $ROOTPKG/...
|
|
||||||
|
|
||||||
# Find submodules.
|
# Test main module.
|
||||||
ROOTPKGPATTERN=$(echo $ROOTPKG | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
|
echo "==> test main module"
|
||||||
MODPATHS=$(go list -m all | grep "^$ROOTPKGPATTERN" | cut -d' ' -f1)
|
GORACE="halt_on_error=1" go test -race ./...
|
||||||
|
|
||||||
for module in $MODPATHS; do
|
# Test all submodules in a subshell.
|
||||||
|
for module in $submodules
|
||||||
echo "==> lint ${module}"
|
do
|
||||||
|
echo "==> test ${module}"
|
||||||
# Get the path of the module.
|
|
||||||
MODNAME=$(echo $module | sed -E -e "s/^$ROOTPKGPATTERN//" \
|
|
||||||
-e 's,^/,,' -e 's,/v[0-9]+$,,')
|
|
||||||
if [ -z "$MODNAME" ]; then
|
|
||||||
MODNAME=.
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run commands in the module directory as a subshell.
|
|
||||||
(
|
(
|
||||||
cd $MODNAME
|
cd $module
|
||||||
|
GORACE="halt_on_error=1" go test -race .
|
||||||
|
)
|
||||||
|
done
|
||||||
|
|
||||||
|
# Lint main module.
|
||||||
|
echo "==> lint main module"
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
|
# Lint all submodules in a subshell.
|
||||||
|
for module in $submodules
|
||||||
|
do
|
||||||
|
echo "==> lint ${module}"
|
||||||
|
(
|
||||||
|
cd $module
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user