Skip to content

IND-2481 test-and-build.yml updated with unit test coverage #129

IND-2481 test-and-build.yml updated with unit test coverage

IND-2481 test-and-build.yml updated with unit test coverage #129

name: Test and Build
on:
push:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version-file: go.mod
- name: Download go modules
run: go mod download
- name: Check Formatting
run: |-
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- name: Vet code
run: go vet ./...
go-test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- '1.13' # oldest supported; named in go.mod
- 'oldstable'
- 'stable'
env:
TEST_RESULTS_PATH: '/tmp/test-results'
steps:
- name: Checkout Code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Install gotestsum
uses: autero1/action-gotestsum@7263b9d73912eec65f46337689e59fac865c425f # v2.0.0
with:
gotestsum_version: 1.9.0
- name: Create test directory
run: mkdir -p "$TEST_RESULTS_PATH"
- name: Run go tests
run: |
gotestsum --format=short-verbose --junitfile "$TEST_RESULTS_PATH/gotestsum-report.xml" -- -p 2 -cover -coverprofile=coverage.out ./...
- name: Upload and save artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
path: ${{ env.TEST_RESULTS_PATH }}
name: tests-linux-${{matrix.go-version}}
- name: Upload coverage report
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
path: coverage.out
name: Coverage-report-${{matrix.go-version}}
- name: Display coverage report
run: go tool cover -func=coverage.out