.github/workflows/codeclimate.yml
name: Codeclimate
on:
push:
branches: [ master ]
jobs:
build:
name: coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Go Mod Tidy
run: |
go mod tidy
- name: Codeclimate
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./test-reporter
chmod +x ./test-reporter
./test-reporter before-build
go test -coverprofile c.out `go list ./... | grep -v /vendor/` -count=1 -coverpkg=`go list ./... | grep -v /vendor/`
sed -i "s/github.com\/xyser\/dnsx\///g" c.out
./test-reporter format-coverage -t gocov
./test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: Codecov
run: |
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
bash <(curl -s https://codecov.io/bash)