fix test pipeline #155
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: Unit tests | |
on: | |
workflow_call: | |
pull_request: | |
push: | |
paths: | |
- "**.go" | |
- "go.mod" | |
- "go.sum" | |
- ".github/workflows/*.yaml" | |
env: | |
GO_VERSION: 1.23 | |
jobs: | |
detect-modules: | |
runs-on: ubuntu-latest | |
outputs: | |
modules: ${{ steps.set-modules.outputs.modules }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- id: set-modules | |
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT | |
golangci-lint: | |
needs: detect-modules | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: golangci-lint ${{ matrix.modules }} | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
args: --timeout=5m | |
working-directory: ${{ matrix.modules }} | |
test-go: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
needs: golangci-lint | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Format | |
run: | | |
diff -u <(echo -n) <(gofmt -d -s .) | |
cd ndc-rest-schema && diff -u <(echo -n) <(gofmt -d -s .) | |
- name: Run Go unit tests | |
run: | | |
go test -v -coverpkg=./... -race -timeout 3m -coverprofile=coverage.out.tmp ./... | |
cat coverage.out.tmp | grep -v "main.go" > coverage.out | |
- name: Run integration tests | |
run: | | |
./scripts/test.sh | |
- name: Go coverage format | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
go get github.com/boumenot/gocover-cobertura | |
go install github.com/boumenot/gocover-cobertura | |
gocover-cobertura < coverage.out > coverage.xml | |
- name: Code Coverage Summary Report | |
uses: irongut/[email protected] | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
filename: coverage.xml | |
badge: true | |
fail_below_min: true | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: true | |
indicators: true | |
output: both | |
thresholds: "50 70" | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
path: code-coverage-results.md | |
- name: Dump docker logs on failure | |
if: failure() | |
uses: jwalton/gh-docker-logs@v2 |