diff --git a/.github/workflows/go_app_pull_requests.yml b/.github/workflows/go_app_pull_requests.yml index 299727f..e893bbb 100644 --- a/.github/workflows/go_app_pull_requests.yml +++ b/.github/workflows/go_app_pull_requests.yml @@ -20,6 +20,20 @@ on: env: GOPRIVATE: ${{ inputs.GOPRIVATE }} jobs: + discover-modules: + # + # finds all go modules in the repository + # + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.set-modules.outputs.modules }} + steps: + - uses: actions/checkout@v4 + - name: Find Go modules + id: set-modules + run: | + MODS=$(find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | jq -R . | jq -sc .) + echo "modules=$MODS" >> $GITHUB_OUTPUT commitlint: # # ensures commit messages follow conventional commits @@ -68,20 +82,20 @@ jobs: # # ensure go standards and tests pass # + needs: discover-modules runs-on: ubuntu-latest strategy: matrix: - # List of go versions to test on. - go: ['^1'] + module: ${{ fromJson(needs.discover-modules.outputs.modules) }} steps: # Checkout go code to test. - name: Checkout repo uses: actions/checkout@v4 - # Setup Go for each version in the matrix. + # Setup Go. - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: @@ -89,35 +103,35 @@ jobs: GITHUB_USERNAME: ${{ inputs.GH_CI_USER }} run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" - # Go vet every Go module. + # Go vet the module. - name: go vet - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go vet ./..." + working-directory: ${{ matrix.module }} + run: go vet ./... # Install go-junit-report to format test results. - name: Install go-junit-report run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - # Run unit test for evet Go module. + # Run unit tests for the module. - name: go test - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..." - | go-junit-report -set-exit-code > junit_report.xml || true + working-directory: ${{ matrix.module }} + run: go test -coverprofile=coverage.txt --race -v ./... 2>&1 | go-junit-report -set-exit-code > junit_report.xml || true - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Test Report - path: junit_report.xml + name: Test Report (${{ matrix.module }}) + path: ${{ matrix.module }}/junit_report.xml reporter: java-junit - uses: codecov/test-results-action@v1 with: fail_ci_if_error: true # optional (default = false) - files: ./junit_report.xml - name: junit-report + files: ${{ matrix.module }}/junit_report.xml + name: junit-report-${{ strategy.job-index }} token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test coverage results to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ matrix.module }}/coverage.txt docker-build: # # ensures the docker image will build without pushing to the registry diff --git a/.github/workflows/go_app_push_main.yml b/.github/workflows/go_app_push_main.yml index a0a69fb..0824ef7 100644 --- a/.github/workflows/go_app_push_main.yml +++ b/.github/workflows/go_app_push_main.yml @@ -21,24 +21,38 @@ on: env: GOPRIVATE: ${{ inputs.GOPRIVATE }} jobs: + discover-modules: + # + # finds all go modules in the repository + # + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.set-modules.outputs.modules }} + steps: + - uses: actions/checkout@v4 + - name: Find Go modules + id: set-modules + run: | + MODS=$(find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | jq -R . | jq -sc .) + echo "modules=$MODS" >> $GITHUB_OUTPUT test: # # ensure go standards and tests pass # + needs: discover-modules runs-on: ubuntu-latest strategy: matrix: - # List of go versions to test on. - go: ['^1'] + module: ${{ fromJson(needs.discover-modules.outputs.modules) }} steps: # Checkout go code to test. - name: Checkout repo - uses: actions/checkout@v3 - # Setup Go for each version in the matrix. + uses: actions/checkout@v4 + # Setup Go. - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: @@ -46,35 +60,35 @@ jobs: GITHUB_USERNAME: ${{ inputs.GH_CI_USER }} run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" - # Go vet every Go module. + # Go vet the module. - name: go vet - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go vet ./..." + working-directory: ${{ matrix.module }} + run: go vet ./... # Install go-junit-report to format test results. - name: Install go-junit-report run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - # Run unit test for evet Go module. + # Run unit tests for the module. - name: go test - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..." - | go-junit-report -set-exit-code > junit_report.xml || true + working-directory: ${{ matrix.module }} + run: go test -coverprofile=coverage.txt --race -v ./... 2>&1 | go-junit-report -set-exit-code > junit_report.xml || true - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Test Report - path: junit_report.xml + name: Test Report (${{ matrix.module }}) + path: ${{ matrix.module }}/junit_report.xml reporter: java-junit - uses: codecov/test-results-action@v1 with: fail_ci_if_error: true # optional (default = false) - files: ./junit_report.xml - name: junit-report + files: ${{ matrix.module }}/junit_report.xml + name: junit-report-${{ strategy.job-index }} token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test coverage results to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ matrix.module }}/coverage.txt release: # # Create a GitHub Release based on conventional commits. diff --git a/.github/workflows/go_lib_pull_requests.yml b/.github/workflows/go_lib_pull_requests.yml index 5ed8c86..34c152d 100644 --- a/.github/workflows/go_lib_pull_requests.yml +++ b/.github/workflows/go_lib_pull_requests.yml @@ -24,6 +24,20 @@ on: env: GOPRIVATE: ${{ inputs.GOPRIVATE }} jobs: + discover-modules: + # + # finds all go modules in the repository + # + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.set-modules.outputs.modules }} + steps: + - uses: actions/checkout@v4 + - name: Find Go modules + id: set-modules + run: | + MODS=$(find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | jq -R . | jq -sc .) + echo "modules=$MODS" >> $GITHUB_OUTPUT commitlint: # # ensures commit messages follow conventional commits @@ -74,20 +88,20 @@ jobs: # # ensure go standards and tests pass # + needs: discover-modules runs-on: ubuntu-latest strategy: matrix: - # List of go versions to test on. - go: ["^1"] + module: ${{ fromJson(needs.discover-modules.outputs.modules) }} steps: # Checkout go code to test. - name: Checkout repo uses: actions/checkout@v4 - # Setup Go for each version in the matrix. + # Setup Go. - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: @@ -96,34 +110,32 @@ jobs: run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" - # Go vet every Go module. + # Go vet the module. - name: go vet - run: - find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go vet ./..." + working-directory: ${{ matrix.module }} + run: go vet ./... # Install go-junit-report to format test results. - name: Install go-junit-report run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - # Run unit test for evet Go module. + # Run unit tests for the module. - name: go test - run: - find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..." - | go-junit-report -set-exit-code > junit_report.xml || true + working-directory: ${{ matrix.module }} + run: go test -coverprofile=coverage.txt --race -v ./... 2>&1 | go-junit-report -set-exit-code > junit_report.xml || true - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Test Report - path: junit_report.xml + name: Test Report (${{ matrix.module }}) + path: ${{ matrix.module }}/junit_report.xml reporter: java-junit - uses: codecov/test-results-action@v1 with: fail_ci_if_error: true # optional (default = false) - files: ./junit_report.xml - name: junit-report + files: ${{ matrix.module }}/junit_report.xml + name: junit-report-${{ strategy.job-index }} token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test coverage results to Codecov uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ matrix.module }}/coverage.txt \ No newline at end of file diff --git a/.github/workflows/go_lib_push_main.yml b/.github/workflows/go_lib_push_main.yml index 4112b7d..b311c70 100644 --- a/.github/workflows/go_lib_push_main.yml +++ b/.github/workflows/go_lib_push_main.yml @@ -21,24 +21,38 @@ on: env: GOPRIVATE: ${{ inputs.GOPRIVATE }} jobs: + discover-modules: + # + # finds all go modules in the repository + # + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.set-modules.outputs.modules }} + steps: + - uses: actions/checkout@v4 + - name: Find Go modules + id: set-modules + run: | + MODS=$(find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | jq -R . | jq -sc .) + echo "modules=$MODS" >> $GITHUB_OUTPUT test: # # ensure go standards and tests pass # + needs: discover-modules runs-on: ubuntu-latest strategy: matrix: - # List of go versions to test on. - go: ["^1"] + module: ${{ fromJson(needs.discover-modules.outputs.modules) }} steps: # Checkout go code to test. - name: Checkout repo uses: actions/checkout@v4 - # Setup Go for each version in the matrix. + # Setup Go. - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: @@ -47,37 +61,35 @@ jobs: run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" - # Go vet every Go module. + # Go vet the module. - name: go vet - run: - find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go vet ./..." + working-directory: ${{ matrix.module }} + run: go vet ./... # Install go-junit-report to format test results. - name: Install go-junit-report run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - # Run unit test for evet Go module. + # Run unit tests for the module. - name: go test - run: - find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname - | xargs -n1 -I{} bash -c "pushd {}; go test -coverprofile=coverage.txt --race -v ./..." - | go-junit-report -set-exit-code > junit_report.xml || true + working-directory: ${{ matrix.module }} + run: go test -coverprofile=coverage.txt --race -v ./... 2>&1 | go-junit-report -set-exit-code > junit_report.xml || true - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Test Report - path: junit_report.xml + name: Test Report (${{ matrix.module }}) + path: ${{ matrix.module }}/junit_report.xml reporter: java-junit - uses: codecov/test-results-action@v1 with: fail_ci_if_error: true # optional (default = false) - files: ./junit_report.xml - name: junit-report + files: ${{ matrix.module }}/junit_report.xml + name: junit-report-${{ strategy.job-index }} token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test coverage results to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ matrix.module }}/coverage.txt release: # # Create a GitHub Release based on conventional commits.