Skip to content

dns parser: set RCODE only in DNS responses #1943

dns parser: set RCODE only in DNS responses

dns parser: set RCODE only in DNS responses #1943

Workflow file for this run

name: Go Tests
on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
branches:
- main
permissions:
contents: read
env:
PROM_VERSION: "2.55.0"
GENTAP: "0.8.0"
PYTHON_VERSION: '3.13'
GO_VERSION: '1.23'
jobs:
build_bin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
- name: Build Binary
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
- name: Upload Binary Artifact
uses: actions/upload-artifact@v4
with:
name: go-dnscollector
path: go-dnscollector
testunit:
strategy:
matrix:
os-version: [ 'ubuntu-24.04' ]
go-version: [ '1.21', '1.22', '1.23' ]
package:
- '.'
- 'pkgconfig'
- 'pkginit'
- 'dnsutils'
- 'workers'
- 'transformers'
- 'telemetry'
runs-on: "${{ matrix.os-version }}"
steps:
- uses: actions/checkout@v4
- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Show Go version
run: |
go version
- name: Test ${{ matrix.package }}
run: go test -timeout 240s -exec sudo ./${{ matrix.package }}/ -race -cover -v
config:
needs: build_bin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Binary Artifact
uses: actions/download-artifact@v4
with:
name: go-dnscollector
- name: Make Binary Executable
run: chmod +x go-dnscollector
- uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Test config
run: |
python3 -m unittest tests.config -v
metrics:
needs: build_bin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Binary Artifact
uses: actions/download-artifact@v4
with:
name: go-dnscollector
- name: Make Binary Executable
run: chmod +x go-dnscollector
- name: run collector
run: ./go-dnscollector -config ./tests/testsdata/config_prom.yml &
- name: download dnstap generator
run: |
wget -nv https://github.com/dmachard/go-dnstap-generator/releases/download/v${{ env.GENTAP }}/go-dnstap-generator_${{ env.GENTAP }}_linux_amd64.tar.gz
tar xf go-dnstap-generator_${{ env.GENTAP }}_linux_amd64.tar.gz
./go-dnstap-generator -i 127.0.0.1 -p 6000 -n 1
- name: check prometheus format metrics
run: |
wget -nv https://github.com/prometheus/prometheus/releases/download/v$PROM_VERSION/prometheus-$PROM_VERSION.linux-amd64.tar.gz
tar xf prometheus-$PROM_VERSION.linux-amd64.tar.gz
cd prometheus-$PROM_VERSION.linux-amd64/
curl -u admin:changeme http://127.0.0.1:8081/metrics | ./promtool check metrics
count:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- id: count_tests
run: |
data=$(sudo go test -timeout 360s -v -exec sudo ./workers ./dnsutils ./transformers ./pkgconfig ./pkginit ./telemetry ././ 2>&1 | grep -c RUN)
echo "Count of Tests: $data"
echo "data=$data" >> $GITHUB_OUTPUT
- id: count_lines
run: |
data=$(find . -name "*.go" -exec grep -v "^$" {} \; -exec grep -v "//" {} \; | wc -l)
echo "Count of Lines: $data"
echo "data=$data" >> $GITHUB_OUTPUT
- id: count_lines_tests
run: |
data=$(find . -name "*_test.go" -exec grep -v "^$" {} \; -exec grep -v "//" {} \; | wc -l)
echo "Count of Lines in tests file: $data"
echo "data=$data" >> $GITHUB_OUTPUT