Skip to content

Commit 5521cf3

Browse files
committed
feat: Improve based on review comments
1 parent b159df5 commit 5521cf3

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

scripts/lint-golangci-lint.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,21 @@ else
2828
exit 1
2929
fi
3030

31-
# If a service is specified, only lint that service
32-
if [ ! -z "${SERVICE}" ]; then
33-
echo ">> Linting service ${SERVICE}"
34-
cd ${SERVICES_PATH}/${SERVICE}
31+
lint_service() {
32+
service=$1
33+
34+
echo ">> Linting service ${service}"
35+
cd ${SERVICES_PATH}/${service}
3536
if [ "${SKIP_NON_GENERATED_FILES}" = true ]; then
3637
golangci-lint run ${GOLANG_CI_ARGS} --skip-dirs wait # All manually maintained files are in subfolders
3738
else
3839
golangci-lint run ${GOLANG_CI_ARGS}
3940
fi
41+
}
42+
43+
# If a service is specified, only lint that service
44+
if [ ! -z "${SERVICE}" ]; then
45+
lint_service ${SERVICE}
4046
# Otherwise, lint all modules and examples
4147
else
4248
if [ "${SKIP_NON_GENERATED_FILES}" = false ]; then
@@ -47,13 +53,7 @@ else
4753

4854
for service_dir in ${SERVICES_PATH}/*; do
4955
service=$(basename ${service_dir})
50-
echo ">> Linting service ${service}"
51-
cd ${service_dir}
52-
if [ "${SKIP_NON_GENERATED_FILES}" = true ]; then
53-
golangci-lint run ${GOLANG_CI_ARGS} --skip-dirs wait # All manually maintained files are in subfolders
54-
else
55-
golangci-lint run ${GOLANG_CI_ARGS}
56-
fi
56+
lint_service ${service}
5757
done
5858

5959
if [ "${SKIP_NON_GENERATED_FILES}" = false ]; then

scripts/test-go.sh

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@ else
2525
exit 1
2626
fi
2727

28-
# If a service is specified, only test that service
29-
if [ ! -z "${SERVICE}" ]; then
30-
echo ">> Testing services/${SERVICE}"
31-
cd ${SERVICES_PATH}/${SERVICE}
28+
test_service() {
29+
service=$1
30+
31+
echo ">> Testing services/${service}"
3232
if [ "${SKIP_NON_GENERATED_FILES}" = true ]; then
33-
go test ./ ${GOTEST_ARGS} # All manually maintained files are in subfolders
33+
go test ${SERVICES_PATH}/${service}/... ${GOTEST_ARGS} # All manually maintained files are in subfolders
3434
else
35-
go test ./... ${GOTEST_ARGS}
35+
go test ${SERVICES_PATH}/${service}/... ${GOTEST_ARGS}
3636
fi
37-
exit 0
38-
# Otherwise, test all modules
39-
else
37+
}
4038

39+
# If a service is specified, only test that service
40+
if [ ! -z "${SERVICE}" ]; then
41+
test_service ${SERVICE}
42+
# Otherwise, test all services and core
43+
else
4144
if [ "${SKIP_NON_GENERATED_FILES}" = false ]; then
4245
echo ">> Testing core"
43-
cd ${CORE_PATH}
44-
go test ./... ${GOTEST_ARGS}
46+
go test ${CORE_PATH}/... ${GOTEST_ARGS}
4547
fi
4648

4749
for service_dir in ${SERVICES_PATH}/*; do
@@ -54,12 +56,6 @@ else
5456
continue
5557
fi
5658

57-
echo ">> Testing services/${service}"
58-
cd ${service_dir}
59-
if [ "${SKIP_NON_GENERATED_FILES}" = true ]; then
60-
go test ./ ${GOTEST_ARGS} # All manually maintained files are in subfolders
61-
else
62-
go test ./... ${GOTEST_ARGS}
63-
fi
59+
test_service ${service}
6460
done
6561
fi

0 commit comments

Comments
 (0)