Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d47f144
feat: add integration tests steps for go library pull requests
otternq Feb 14, 2025
15488a1
chore: try coverdir for integration tests
otternq Feb 14, 2025
a72de06
chore: attempt another format
otternq Feb 14, 2025
a7666d2
chore: correct workflow format
otternq Feb 14, 2025
5fd8986
chore: attempt another path
otternq Feb 14, 2025
5515458
chore: correct quotes
otternq Feb 14, 2025
02f082a
chore: vendor since docker is now involved
otternq Feb 15, 2025
157b0a7
chore: vendor with workspace as well
otternq Feb 17, 2025
d2cc4dd
chore: support integration tests for go_app_pull_requests.yml
otternq Mar 12, 2025
bb9f953
chore: support integration tests for go_app_pull_requests.yml
otternq Mar 12, 2025
af13502
fix: have go app push_main run integration tests
otternq Mar 14, 2025
d7f1e06
chore: correct indentation
otternq Mar 14, 2025
90bd2f2
feat: add junit report
cri0ll0 May 20, 2025
25d1fe0
feat: add junit test report
cri0ll0 May 20, 2025
313711b
fix: use proper version
cri0ll0 May 21, 2025
2fbc0ea
Merge pull request #50 from Kochava/go-integration-tests-b
otternq May 22, 2025
3ccc4e9
fix: show test output
otternq Jun 4, 2025
e4bbecc
fix: report junit results for integration tests during prs
otternq Jun 4, 2025
670a807
Merge pull request #52 from Kochava/go-integration-tests-docker-cache
otternq Jun 4, 2025
08a397a
chore: merge main into branch
otternq Jun 30, 2025
d5deb60
Merge pull request #53 from Kochava/go-integration-tests-v2
otternq Jun 30, 2025
a3743ee
Merge branch 'main' of github.com:Kochava/github-workflows into go-in…
otternq Jun 30, 2025
b2e279f
chore: skip more integration test steps if disabled
otternq Jul 1, 2025
e3131b0
fix: add integration test timeout
otternq Jul 16, 2025
7999a48
chore: add verbose mode, push integration test report to codecov
cri0ll0 Nov 28, 2025
48fb213
Merge pull request #56 from Kochava/go-integration-tests-v2
cri0ll0 Dec 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 85 additions & 10 deletions .github/workflows/go_app_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,35 @@ on:
description: 'GOPRIVATE env for go commands'
required: false
type: string
GO_TEST_UNIT_TAGS:
description: "The tags flag for the unit test go test call. Include -tags flag. Example -tags=unit"
type: string
required: false
default: ""
GO_TEST_INTEGRATION_ENABLED:
type: boolean
default: false
GO_TEST_INTEGRATION_TAGS:
description: "The tags flag for the integration test go test call. Include -tags flag. Example -tags=integration"
type: string
default: "-tags=integration"
GO_TEST_INTEGRATION_TIMEOUT:
description: "The duration before tests are stopped"
type: string
default: "10m"
secrets:
GH_CI_PAT:
description: 'Token password for GitHub auth'
required: true
CODECOV_TOKEN:
description: 'Token for Codecov'
required: true
ARTIFACT_REGISTRY:
description: 'Artifact Registry address to which to publish (leave blank to not publish)'
required: false
ARTIFACT_REGISTRY_JSON_KEY:
description: 'Key for publishing to Artifact Registry'
required: false
env:
GOPRIVATE: ${{ inputs.GOPRIVATE }}
jobs:
Expand Down Expand Up @@ -82,42 +104,95 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
# Use auth to get access to private Git repos for Go code dependencies.
- name: Login to Artifact Registry
env:
ARTIFACT_REGISTRY_JSON_KEY: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
if: ${{ env.ARTIFACT_REGISTRY_JSON_KEY }}
uses: docker/login-action@v2
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
- 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
run: go mod vendor
# Go vet every Go 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 ./..."
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: build coverage output directories
run: |
mkdir -p coverage/unit
mkdir -p coverage/int
- 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
- name: Test Report
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; go test -cover --race -v ${{ inputs.GO_TEST_UNIT_TAGS }} ./... -args -test.gocoverdir=\"${{ github.workspace }}/coverage/unit\""
| tee unit_test_output.txt
- name: Build Unit Test Junit report
run:
go-junit-report -in unit_test_output.txt -set-exit-code > junit_report.xml || true
- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Report
name: Unit Test Report
path: junit_report.xml
reporter: java-junit
- uses: codecov/test-results-action@v1
- name: Upload unit test coverage results to Codecov
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_report.xml
name: junit-report
token: ${{ secrets.CODECOV_TOKEN }}
# relies on the tests themselves compiling the binary with `-cover` and setting GOCOVERDIR to /coverage/int
# to seperate out any integration tests
- name: integration tests
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
run: go test -v ${{ inputs.GO_TEST_INTEGRATION_TAGS }} -timeout ${{ inputs.GO_TEST_INTEGRATION_TIMEOUT }} ./...
| tee integration_test_output.txt
- name: Build Integration Test Junit report
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
run: go-junit-report -in integration_test_output.txt -set-exit-code > junit_integration_report.xml || true
- name: Integration Test Report
uses: dorny/test-reporter@v1
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
with:
name: Integration Test Report
path: junit_integration_report.xml
reporter: java-junit
- name: Upload integration test results to Codecov
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_integration_report.xml
name: junit-integration-report
token: ${{ secrets.CODECOV_TOKEN }}
- name: show coverage output directories
run: |
ls ./coverage/unit
ls ./coverage/int
- name: build coverage.txt
run: go tool covdata textfmt -i=./coverage/int,./coverage/unit -o coverage.txt
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
verbose: true
fail_ci_if_error: true # optional (default = false)
docker-build:
#
# ensures the docker image will build without pushing to the registry
Expand Down
84 changes: 75 additions & 9 deletions .github/workflows/go_app_push_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,31 @@ on:
description: "GOPRIVATE env for go commands"
required: false
type: string
GO_TEST_UNIT_TAGS:
description: "The tags flag for the unit test go test call. Include -tags flag. Example -tags=unit"
type: string
required: false
default: ""
GO_TEST_INTEGRATION_ENABLED:
type: boolean
default: false
GO_TEST_INTEGRATION_TAGS:
description: "The tags flag for the integration test go test call. Include -tags flag. Example -tags=integration"
type: string
default: "-tags=integration"
secrets:
GH_CI_PAT:
description: 'Token password for GitHub auth'
required: true
CODECOV_TOKEN:
description: 'Token for Codecov'
required: true
ARTIFACT_REGISTRY:
description: 'Artifact Registry address to which to publish (leave blank to not publish)'
required: false
ARTIFACT_REGISTRY_JSON_KEY:
description: 'Key for publishing to Artifact Registry'
required: false
env:
GOPRIVATE: ${{ inputs.GOPRIVATE }}
jobs:
Expand All @@ -39,42 +57,90 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Login to Artifact Registry
env:
ARTIFACT_REGISTRY_JSON_KEY: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
if: ${{ env.ARTIFACT_REGISTRY_JSON_KEY }}
uses: docker/login-action@v2
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
# 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
"https://github.com"
# Vendor Go code needed to build app.
- name: go mod vendor
run: go mod vendor
# Go vet every Go 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 ./..."
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: build coverage output directories
run: |
mkdir -p coverage/unit
mkdir -p coverage/int
- 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
- name: Test Report
run:
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; go test -cover --race -v ${{ inputs.GO_TEST_UNIT_TAGS }} ./... -args -test.gocoverdir=\"${{ github.workspace }}/coverage/unit\""
| tee unit_test_output.txt
- name: Build Unit Test Junit report
run:
go-junit-report -in unit_test_output.txt -set-exit-code > junit_report.xml || true
- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Report
name: Unit Test Report
path: junit_report.xml
reporter: java-junit
- uses: codecov/test-results-action@v1
- name: Upload unit test results to Codecov
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_report.xml
name: junit-report
token: ${{ secrets.CODECOV_TOKEN }}
# relies on the tests themselves compiling the binary with `-cover` and setting GOCOVERDIR to /coverage/int
# to seperate out any integration tests
- name: integration tests
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
run: go test -v ${{ inputs.GO_TEST_INTEGRATION_TAGS }} ./...
| tee integration_test_output.txt
- name: Build Integration Test Junit report
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
run: go-junit-report -in integration_test_output.txt -set-exit-code > junit_integration_report.xml || true
- name: show coverage output directories
run: |
ls ./coverage/unit
ls ./coverage/int
- name: build coverage.txt
run: go tool covdata textfmt -i=./coverage/int,./coverage/unit -o coverage.txt
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Integration Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Integration Test Report
path: junit_integration_report.xml
reporter: java-junit
- name: Upload integration test results to Codecov
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_report.xml
name: junit-report
token: ${{ secrets.CODECOV_TOKEN }}
release:
#
# Create a GitHub Release based on conventional commits.
Expand Down
76 changes: 69 additions & 7 deletions .github/workflows/go_lib_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,31 @@ on:
description: "Go workspace mode"
required: false
type: string
GO_TEST_UNIT_TAGS:
description: "The tags flag for the unit test go test call. Include -tags flag. Example -tags=unit"
type: string
required: false
default: ""
GO_TEST_INTEGRATION_ENABLED:
type: boolean
default: false
GO_TEST_INTEGRATION_TAGS:
description: "The tags flag for the integration test go test call. Include -tags flag. Example -tags=integration"
type: string
default: "-tags=integration"
secrets:
GH_CI_PAT:
description: "Token password for GitHub auth"
required: true
CODECOV_TOKEN:
description: 'Token for Codecov'
required: true
ARTIFACT_REGISTRY:
description: 'Artifact Registry address to which to publish (leave blank to not publish)'
required: false
ARTIFACT_REGISTRY_JSON_KEY:
description: 'Key for publishing to Artifact Registry'
required: false
env:
GOPRIVATE: ${{ inputs.GOPRIVATE }}
jobs:
Expand Down Expand Up @@ -89,41 +107,85 @@ jobs:
with:
go-version: ${{ matrix.go }}
# Use auth to get access to private Git repos for Go code dependencies.
# Login to Artifact Registry if we're pushing to it.
- name: Login to Artifact Registry
env:
ARTIFACT_REGISTRY_JSON_KEY: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
if: ${{ env.ARTIFACT_REGISTRY_JSON_KEY }}
uses: docker/login-action@v2
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.ARTIFACT_REGISTRY_JSON_KEY }}
- 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
"https://github.com"
# Vendor Go code needed to build app.
- name: go mod vendor
run: go mod vendor | go work vendor
# Go vet every Go 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 ./..."
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; go vet ./..."
| go-junit-report -set-exit-code > junit_report.xml || true
# 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: build coverage output directories
run: |
mkdir -p coverage/unit
mkdir -p coverage/int
- 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 ./..."
find . -name vendor -prune -o -name go.mod -print | xargs -n1 dirname | xargs -n1 -I{} bash -c "pushd {}; go test -cover --race -v ${{ inputs.GO_TEST_UNIT_TAGS }} ./... -args -test.gocoverdir=\"${{ github.workspace }}/coverage/unit\""
| go-junit-report -set-exit-code > junit_report.xml || true
- name: Test Report
- name: Unit Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Report
name: Unit Test Report
path: junit_report.xml
reporter: java-junit
- uses: codecov/test-results-action@v1
- name: Upload unit test coverage results to Codecov
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_report.xml
name: junit-report
token: ${{ secrets.CODECOV_TOKEN }}
# relies on the tests themselves compiling the binary with `-cover` and setting GOCOVERDIR to /coverage/int
# to seperate out any integration tests
- name: integration tests
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
run: go test -v ${{ inputs.GO_TEST_INTEGRATION_TAGS }} ./...
| go-junit-report -set-exit-code > junit_integration_report.xml || true
- name: show coverage output directories
run: |
ls ./coverage/unit
ls ./coverage/int
- name: build coverage.txt
run: go tool covdata textfmt -i=./coverage/int,./coverage/unit -o coverage.txt
- name: Upload test coverage results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Integration Test Report
uses: dorny/test-reporter@v1
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
with:
name: Integration Test Report
path: junit_integration_report.xml
reporter: java-junit
- name: Upload integration test coverage results to Codecov
if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }}
uses: codecov/test-results-action@v1
with:
fail_ci_if_error: true # optional (default = false)
files: ./junit_report.xml
name: junit-report
token: ${{ secrets.CODECOV_TOKEN }}
Loading