From 68fb2939abed55d5d576efd1911f3f31df9e5bd9 Mon Sep 17 00:00:00 2001 From: Michael Peters Jr Date: Fri, 23 May 2025 09:07:27 -0700 Subject: [PATCH] fix: preserve test output in actions console for go app/lib --- .github/workflows/go_app_pull_requests.yml | 33 +++++++++++++--------- .github/workflows/go_app_push_main.yml | 21 ++++++++------ .github/workflows/go_lib_pull_requests.yml | 12 ++++---- .github/workflows/go_lib_push_main.yml | 14 ++++----- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/.github/workflows/go_app_pull_requests.yml b/.github/workflows/go_app_pull_requests.yml index 7d2e77d..5b3f94a 100644 --- a/.github/workflows/go_app_pull_requests.yml +++ b/.github/workflows/go_app_pull_requests.yml @@ -3,19 +3,19 @@ on: workflow_call: inputs: GH_CI_USER: - description: 'User for GitHub auth' + description: "User for GitHub auth" required: true type: string GOPRIVATE: - description: 'GOPRIVATE env for go commands' + description: "GOPRIVATE env for go commands" required: false type: string secrets: GH_CI_PAT: - description: 'Token password for GitHub auth' + description: "Token password for GitHub auth" required: true CODECOV_TOKEN: - description: 'Token for Codecov' + description: "Token for Codecov" required: true env: GOPRIVATE: ${{ inputs.GOPRIVATE }} @@ -51,13 +51,14 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '^1' + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: TOKEN: ${{ secrets.GH_CI_PAT }} GITHUB_USERNAME: kochava-ci - run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf + run: + git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 @@ -72,7 +73,7 @@ jobs: strategy: matrix: # List of go versions to test on. - go: ['^1'] + go: ["^1"] steps: # Checkout go code to test. - name: Checkout repo @@ -87,20 +88,23 @@ jobs: env: TOKEN: ${{ secrets.GH_CI_PAT }} GITHUB_USERNAME: ${{ inputs.GH_CI_USER }} - run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf + run: + git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" # Go vet every Go module. - name: go vet - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname + run: + find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; 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. - 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 + 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 ./..." \ + | tee >(go-junit-report -set-exit-code > junit_report.xml) - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() @@ -132,13 +136,14 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '^1' + go-version: "^1" # Use auth to get access to private Git repos for Go code dependencies. - name: Configure git for private modules env: TOKEN: ${{ secrets.GH_CI_PAT }} GITHUB_USERNAME: ${{ inputs.GH_CI_USER }} - run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf + run: + git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" # Vendor Go code needed to build app. - name: go mod vendor diff --git a/.github/workflows/go_app_push_main.yml b/.github/workflows/go_app_push_main.yml index a0a69fb..4868e14 100644 --- a/.github/workflows/go_app_push_main.yml +++ b/.github/workflows/go_app_push_main.yml @@ -13,10 +13,10 @@ on: type: string secrets: GH_CI_PAT: - description: 'Token password for GitHub auth' + description: "Token password for GitHub auth" required: true CODECOV_TOKEN: - description: 'Token for Codecov' + description: "Token for Codecov" required: true env: GOPRIVATE: ${{ inputs.GOPRIVATE }} @@ -29,7 +29,7 @@ jobs: strategy: matrix: # List of go versions to test on. - go: ['^1'] + go: ["^1"] steps: # Checkout go code to test. - name: Checkout repo @@ -44,20 +44,23 @@ jobs: env: TOKEN: ${{ secrets.GH_CI_PAT }} GITHUB_USERNAME: ${{ inputs.GH_CI_USER }} - run: git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf + run: + git config --global url."https://${GITHUB_USERNAME}:${TOKEN}@github.com".insteadOf "https://github.com" # Go vet every Go module. - name: go vet - run: find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname + run: + find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; 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. - 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 + 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 ./..." \ + | tee >(go-junit-report -set-exit-code > junit_report.xml) - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() @@ -79,7 +82,7 @@ jobs: # # Create a GitHub Release based on conventional commits. # - name: 'Release to GitHub' + name: "Release to GitHub" # needs: test runs-on: ubuntu-latest needs: test diff --git a/.github/workflows/go_lib_pull_requests.yml b/.github/workflows/go_lib_pull_requests.yml index 5c475f1..1db8b88 100644 --- a/.github/workflows/go_lib_pull_requests.yml +++ b/.github/workflows/go_lib_pull_requests.yml @@ -19,7 +19,7 @@ on: description: "Token password for GitHub auth" required: true CODECOV_TOKEN: - description: 'Token for Codecov' + description: "Token for Codecov" required: true env: GOPRIVATE: ${{ inputs.GOPRIVATE }} @@ -106,10 +106,10 @@ jobs: run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 # Run unit test for evet Go 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 + 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 ./..." \ + | tee >(go-junit-report -set-exit-code > junit_report.xml) - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() @@ -126,4 +126,4 @@ jobs: - 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 }} diff --git a/.github/workflows/go_lib_push_main.yml b/.github/workflows/go_lib_push_main.yml index 4112b7d..8fa9b77 100644 --- a/.github/workflows/go_lib_push_main.yml +++ b/.github/workflows/go_lib_push_main.yml @@ -13,10 +13,10 @@ on: type: string secrets: GH_CI_PAT: - description: 'Token password for GitHub auth' + description: "Token password for GitHub auth" required: true CODECOV_TOKEN: - description: 'Token for Codecov' + description: "Token for Codecov" required: true env: GOPRIVATE: ${{ inputs.GOPRIVATE }} @@ -57,10 +57,10 @@ jobs: run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 # Run unit test for evet Go 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 + 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 ./..." \ + | tee >(go-junit-report -set-exit-code > junit_report.xml) - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() @@ -82,7 +82,7 @@ jobs: # # Create a GitHub Release based on conventional commits. # - name: 'Release to GitHub' + name: "Release to GitHub" # needs: test runs-on: ubuntu-latest steps: