Skip to content

test: improve test coverage (#114) #270

test: improve test coverage (#114)

test: improve test coverage (#114) #270

Workflow file for this run

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 }}
# Defining variables is awkward in gh-actions, they can't just be declared
# anywhere; in particular they can't be declared at the top of this file,
# nor can they be declared inside steps.
#
# see: GitHub Actions/Write workflows/Choose what workflows do/
# Store information in variables
#
env:
COVERAGE_OUTPUT: ${{ github.workspace }}/coverage/coverage.out
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 }}"
echo "COVERAGE_OUTPUT: $COVERAGE_OUTPUT"
- name: Ensure coverage directory exists
run: |
mkdir -p ${{ github.workspace }}/coverage
mkdir -p ${{ github.workspace }}/collections/coverage
mkdir -p ${{ github.workspace }}/core/coverage/
mkdir -p ${{ github.workspace }}/cycle/coverage
mkdir -p ${{ github.workspace }}/enums/coverage
mkdir -p ${{ github.workspace }}/internal/feat/filter/coverage
mkdir -p ${{ github.workspace }}/internal/feat/hiber/coverage
mkdir -p ${{ github.workspace }}/internal/feat/resume/coverage
mkdir -p ${{ github.workspace }}/internal/feat/sampling/coverage
mkdir -p ${{ github.workspace }}/internal/filtering/coverage
mkdir -p ${{ github.workspace }}/internal/kernel/coverage
mkdir -p ${{ github.workspace }}/internal/level/coverage
mkdir -p ${{ github.workspace }}/internal/measure/coverage
mkdir -p ${{ github.workspace }}/internal/services/coverage
mkdir -p ${{ github.workspace }}/internal/level/coverage
mkdir -p ${{ github.workspace }}/internal/third/bus/coverage
mkdir -p ${{ github.workspace }}/internal/third/lo/coverage
mkdir -p ${{ github.workspace }}/internal/types/coverage
mkdir -p ${{ github.workspace }}/locale/coverage
mkdir -p ${{ github.workspace }}/nfs/coverage
mkdir -p ${{ github.workspace }}/pref/coverage
mkdir -p ${{ github.workspace }}/tapable/coverage
- name: list coverage directory
run: ls -la ${{ github.workspace }}/coverage
# This should be ginko
# This works, but produces bad results (too many incorrect 0% coverage),
# so we need to get ginkgo working.
#
# - name: Run tests and generate coverage profile with Go test
# run: |
# go test ./... -coverprofile=${{ github.workspace }}/coverage/coverage.out
# - name: Run tests and generate coverage profile with Ginkgo
# run: ginkgo ./... --json-report ./ginkgo.report \
# -coverpkg=$(go list github.com/snivilised/traverse/...) \
# -coverprofile=${{ github.workspace }}/coverage/coverage.out -r
# onsi:
- name: Run tests and generate coverage profile with Ginkgo
run: ginkgo ./... --json-report ./ginkgo.report \
-coverpkg=$(go list github.com/snivilised/traverse/...) \
-coverprofile=${{ env.COVERAGE_OUTPUT }} -r
#######
# - name: Check if coverage file exists
# run: |
# if [ -f "${{ env.COVERAGE_OUTPUT }}" ]; then
# echo "Coverage file generated successfully"
# else
# echo "Coverage file not found"
# exit 1
# fi
- name: Generate HTML coverage report
run: |
if [ -f ${{ env.COVERAGE_OUTPUT }} ]; then
go tool cover -html=$COVERAGE_OUTPUT -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: $COVERAGE_OUTPUT