test: improve test coverage (#114) #276
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 }} | |
# 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.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) \n" | |
echo "πΉ GitHub workspace: ${{ github.workspace }} \n" | |
echo "πΉ COVERAGE_OUTPUT: $COVERAGE_OUTPUT \n" | |
- 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 output | |
run: \ | |
echo "πΈ listing workspace....\n" | |
ls -la ${{ github.workspace }} | |
echo "πΈ listing coverage output....\n" | |
ls -la ${{env.COVERAGE_OUTPUT}} | |
# 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: list .out files | |
run: \ | |
echo "πΊ listing out files....\n" | |
ls -la ${{ github.workspace }}/*.out | |
####### | |
# - 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=${{ env.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: ${{ env.COVERAGE_OUTPUT }} |