Skip to content

chore(regression): improve coverage with testing tag matrix #3501

chore(regression): improve coverage with testing tag matrix

chore(regression): improve coverage with testing tag matrix #3501

Workflow file for this run

name: Regression Tests
on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "LICENSE"
pull_request:
paths-ignore:
- "**/*.md"
- "LICENSE"
jobs:
# Generate matrix of tags for all permutations of the tests
generate-matrix:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.generate.outputs.tags }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate tag combinations
id: generate
run: |
go run mage.go tagsmatrix > tags.json
echo "::set-output name=tags::$(cat tags.json)"
shell: bash
test:
needs: generate-matrix
strategy:
matrix:
go-version: [1.22.x, 1.23.x]
os: [ubuntu-latest]
build-flag: ${{ fromJson(needs.generate-matrix.outputs.tags) }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Tests and coverage
run: |
mkdir build
echo
go test -race -coverprofile=build/${{ matrix.build-flag }}.txt -covermode=atomic -coverpkg=./... -tags=${{ matrix.build-flag }} ./...
go test -race -coverprofile=build/${{ matrix.build-flag }}-examples.txt -covermode=atomic -coverpkg=./... ${{ matrix.build-flag }} ./examples/http-server
go test -coverprofile=build/${{ matrix.build-flag }}-ftw.txt -covermode=atomic -coverpkg=./... ${{ matrix.build-flag }} ./testing/coreruleset
go test -race -tags=tinygo -coverprofile=build/${{ matrix.build-flag }}-tinygo.txt -covermode=atomic -coverpkg=./... ./...
go tool cover -html=build/${{ matrix.build-flag }}.txt -o build/${{ matrix.build-flag }}.html
- name: "Codecov: General"
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
if: ${{ matrix.go-version == '1.22.x' }}
with:
files: build/${{ matrix.build-flag }}.txt
flags: default
- name: "Codecov: Examples"
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
if: ${{ matrix.go-version == '1.22.x' }}
with:
files: build/${{ matrix.build-flag }}-examples.txt
flags: examples
- name: "Codecov: FTW"
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
if: ${{ matrix.go-version == '1.22.x' }}
with:
files: build/${{ matrix.build-flag }}-ftw.txt
flags: ftw
- name: "Codecov: Tinygo"
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
if: ${{ matrix.go-version == '1.22.x' }}
with:
files: build/${{ matrix.build-flag }}-tinygo.txt
flags: tinygo