55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Build and Test
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- fix-*
|
|
- feat-*
|
|
- update-*
|
|
paths:
|
|
- '**.go'
|
|
- go.mod
|
|
- go.sum
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
paths:
|
|
- '**.go'
|
|
- go.mod
|
|
- go.sum
|
|
jobs:
|
|
build-test-publish-coverage:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22'
|
|
- run: go build
|
|
- run: |
|
|
docker compose -p coredns-netbox-plugin-dns -f ${{ github.workspace }}/.testing/docker-compose.yml up -d && \
|
|
until [[ "`docker inspect -f {{.State.Health.Status}} coredns-netbox-plugin-dns-netbox-1`" == "healthy" ]]; do
|
|
echo "Waiting for Netbox to come online..."
|
|
sleep 5
|
|
done && \
|
|
go run ${{ github.workspace }}/.testing/init/init.go
|
|
- run: go test -coverprofile='coverage.out'
|
|
- uses: sonarsource/sonarcloud-github-action@master
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
with:
|
|
args: >
|
|
-Dsonar.organization=doubleu-labs
|
|
-Dsonar.projectKey=doubleu-labs_coredns-netbox-plugin-dns
|
|
-Dsonar.go.coverage.reportPaths=coverage.out
|
|
-Dsonar.verbose=true
|
|
-Dsonar.sources=.
|
|
-Dsonar.exclusions=**/*_test.go,.testing/*
|
|
-Dsonar.tests=.
|
|
-Dsonar.test.inclusions=**/*_test.go
|