-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: list modules and pass it to test matrix
Signed-off-by: Marko Kungla <[email protected]>
- Loading branch information
Showing
3 changed files
with
41 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 20 additions & 5 deletions
25
.github/actions/go-test-monorepo-action/go-test-monorepo-action.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Check if only module list should be outputted | ||
ONLY_MODULE_LIST="$1" | ||
|
||
# Array to hold module paths | ||
modules=() | ||
|
||
# Find all directories containing a go.mod file | ||
while IFS= read -r module; do | ||
modules+=("$module") | ||
echo "Testing and generating coverage for module: $module" | ||
(cd "$module" && go test -race -coverpkg=./... -coverprofile=coverage.out -timeout=1m ./...) | ||
modules+=("$module") | ||
|
||
# Run tests only if ONLY_MODULE_LIST is not "true" | ||
if [ "$ONLY_MODULE_LIST" != "true" ]; then | ||
echo "Testing and generating coverage for module: $module" | ||
(cd "$module" && go test -race -coverpkg=./... -coverprofile=coverage.out -timeout=1m ./...) | ||
fi | ||
done < <(find . -type f -name 'go.mod' -exec dirname {} \;) | ||
|
||
# Convert modules array to JSON array format | ||
modules_json=$(printf '%s\n' "${modules[@]}" | jq -R . | jq -cs .) | ||
|
||
# Check if GITHUB_OUTPUT is set, else use /dev/null | ||
if [ -z "$GITHUB_OUTPUT" ]; then | ||
GITHUB_OUTPUT="/dev/null" | ||
GITHUB_OUTPUT="/dev/null" | ||
fi | ||
|
||
# Output the modules for the matrix | ||
echo "modules=$modules_json" >> $GITHUB_OUTPUT | ||
echo "${modules_json}" | ||
|
||
# If running in GitHub Actions, set info message | ||
if [ "$GITHUB_ACTIONS" == "true" ]; then | ||
echo "::info::Monorepo modules: $modules_json" | ||
else | ||
echo "${modules_json}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters