You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- name: Detect and Test Submodulesrun: | # Find all directories containing a go.mod file within 'pkg' for module in $(find pkg -name "go.mod" -exec dirname {} \;); do echo "Testing module: $module" cd $module # Extract module name (replace '/' with '_') module_name=$(echo $module | tr '/' '_') # Download dependencies for the submodule go mod download go mod tidy # Run tests for the submodule and generate coverage export APP_ENV=test warning_count=$(go test ./... -v -short -coverprofile=${module_name}.cov -coverpkg=./... | tee /dev/tty | grep -c "WARNING" || true) total_warning_count=$((total_warning_count + warning_count)) # Return to the root directory cd - done echo "Total warnings found: $total_warning_count" echo "total_warning_count=$total_warning_count" >> $GITHUB_ENV
The code is too complicated to be maintained in a YAML file, and it cannot be easily tested without running it via a GHA
The code could be extracted to something like a shell script or equivalent
This idea comes from the discussion that happened here
The text was updated successfully, but these errors were encountered:
@ccoVeille Hi, wanting to take this as first-issue.
Can I know whether you are thinking of moving only this piece of code to a separate script or some others as well. With respect to length and complexity, this is another closest I see.
- name: Lint Submodules
run: |
echo "Searching for submodules..."
total_errors=0 # Initialize error counter
for module in $(find pkg -name "go.mod" -exec dirname {} \;); do
echo "Linting submodule: $module"
# Change directory to the submodule and run golangci-lint
cd $module
go mod tidy
golangci-lint run --timeout 9m0s || total_errors=$((total_errors + 1))
cd - # Return to the root directory
done
echo "Total submodule lint errors: $total_errors"
if [ $total_errors -gt 0 ]; then
echo "Linting failed for $total_errors submodule(s)."
exit 1 # Fail the job if there are linting errors in submodules
fi
The current code of .github/workflows/go.yml contains something like this
The code is too complicated to be maintained in a YAML file, and it cannot be easily tested without running it via a GHA
The code could be extracted to something like a shell script or equivalent
This idea comes from the discussion that happened here
The text was updated successfully, but these errors were encountered: