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: extract the code in .github/workflows/go.yml into a script #1399

Open
ccoVeille opened this issue Jan 18, 2025 · 0 comments
Open

CI: extract the code in .github/workflows/go.yml into a script #1399

ccoVeille opened this issue Jan 18, 2025 · 0 comments

Comments

@ccoVeille
Copy link
Contributor

The current code of .github/workflows/go.yml contains something like this

      - name: Detect and Test Submodules
        run: |
          # 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant