Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Simplify run_test.sh script. #475

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/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
# license that can be found in the LICENSE file.
#
Expand All @@ -11,30 +11,33 @@ set -e

go version

# Run tests on root module and all submodules.
echo "==> test all modules"
ROOTPKG="github.com/decred/vspd"
GORACE="halt_on_error=1" go test -race $ROOTPKG/...
# This list needs to be updated if new submodules are added to the vspd repo.
submodules="client types"

# Find submodules.
ROOTPKGPATTERN=$(echo $ROOTPKG | sed 's/\\/\\\\/g' | sed 's/\//\\\//g')
MODPATHS=$(go list -m all | grep "^$ROOTPKGPATTERN" | cut -d' ' -f1)
# Test main module.
echo "==> test main module"
GORACE="halt_on_error=1" go test -race ./...

for module in $MODPATHS; do

echo "==> lint ${module}"
# Test all submodules in a subshell.
for module in $submodules
do
echo "==> test ${module}"
(
cd $module
GORACE="halt_on_error=1" go test -race .
)
done

# 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
# Lint main module.
echo "==> lint main module"
golangci-lint run

# Run commands in the module directory as a subshell.
# Lint all submodules in a subshell.
for module in $submodules
do
echo "==> lint ${module}"
(
cd $MODNAME

cd $module
golangci-lint run
)
done
Expand Down
Loading