test: improve test coverage (#114) #260
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Traverse Continuous Integration | |
on: | |
push: | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.23 | |
- uses: actions/checkout@v3 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.60.3 | |
args: --verbose | |
test: | |
strategy: | |
matrix: | |
go-version: [1.23] | |
platform: [ubuntu-latest, macos-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install goveralls | |
run: go install github.com/mattn/goveralls@latest | |
- name: Install ginkgo | |
run: go install github.com/onsi/ginkgo/v2/[email protected] | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Print current directory and workspace | |
run: | | |
echo "Current directory: $(pwd)" | |
echo "GitHub workspace: ${{ github.workspace }}" | |
- name: Ensure coverage directory exists | |
run: mkdir -p ${{ github.workspace }}/coverage | |
- name: Ensure coverage directory exists | |
run: mkdir -p ${{ github.workspace }}/coverage | |
- name: Run tests and generate coverage profile | |
run: | | |
go test ./... -coverprofile=${{ github.workspace }}/coverage/coverage.out | |
- name: Check if coverage file exists | |
run: | | |
if [ -f "${{ github.workspace }}/coverage/coverage.out" ]; then | |
echo "Coverage file generated successfully" | |
else | |
echo "Coverage file not found" | |
exit 1 | |
fi | |
- name: Generate HTML coverage report | |
run: | | |
if [ -f "${{ github.workspace }}/coverage/coverage.out" ]; then | |
go tool cover -html=${{ github.workspace }}/coverage/coverage.out -o ${{ github.workspace }}/coverage/coverage.html | |
else | |
echo "coverage.out file not found" | |
exit 1 | |
fi | |
- name: Upload coverage to Coveralls | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: ${{ github.workspace }}/coverage/coverage.out |