Skip to content

Commit

Permalink
Merge pull request #69 from Luzilla/tests-on-actions
Browse files Browse the repository at this point in the history
Chore: move tests to actions
  • Loading branch information
till authored Apr 3, 2021
2 parents e98dfd5 + 4d3147a commit 1180cd1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 13 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,37 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --snapshot
args: release --config ./.goreleaser.ci.yml --rm-dist --snapshot
- name: Copy .ini files
run: cp targets.ini rbls.ini ./dist/dnsbl_exporter_linux_amd64
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: dnsbl_exporter
path: dist/dnsbl_exporter_linux_amd64

integration:
runs-on: ubuntu-latest
needs:
- snapshot
services:
unbound:
image: klutchell/unbound:latest
ports:
- 5053:5053
- 5053:5053/udp
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: dnsbl_exporter
- name: Allow running exporter
run: chmod +x ./dnsbl-exporter
- name: Start dnsbl_exporter
run: ./dnsbl-exporter --config.dns-resolver=unbound:5053 &
- name: Test "/" exists
run: curl -I http://127.0.0.1:9211/
- name: Test "/metrics" exists
run: curl -I http://127.0.0.1:9211/metrics
- name: Test "/metrics" with targets
run: curl -i http://127.0.0.1:9211/metrics
32 changes: 32 additions & 0 deletions .goreleaser.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
project_name: dnsbl_exporter

before:
hooks:
- go mod tidy
- go generate ./...
builds:
- main: ./dnsbl_exporter.go
binary: dnsbl-exporter
ldflags: -s -w -X main.exporterVersion={{.Version}}
goos:
- linux
env:
- CGO_ENABLED=0
archives:
- files:
- none*
replacements:
linux: Linux
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
5 changes: 1 addition & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
---
project_name: dnsbl_exporter

before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- main: ./dnsbl_exporter.go
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ $ sudo unbound -d -vvvv

(This is for myself, since I tend to forget things.)

1. Create a release on Github
1. Assemble changelog based on PR merges, etc.
1. Tag must be `v1.0.0` (semantic versioning, prefixed by `v`)
1. CircleCI will pick it up and build the binaries
1. `git tag -a x.y.z`
1. `git push --tags`
1. GitHub Actions/GoReleaser will build a pretty release
10 changes: 8 additions & 2 deletions collector/rbl.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ func (rbl *Rbl) createQuestion(target string, record uint16) *dns.Msg {
}

func (rbl *Rbl) makeQuery(msg *dns.Msg) (*dns.Msg, error) {
// fixme: we should inject the port as well
result, rt, err := rbl.DNSClient.Exchange(msg, net.JoinHostPort(rbl.Resolver, "53"))
host, port, err := net.SplitHostPort(rbl.Resolver)
if err != nil {
if err.Error() == "missing port in address" {
port = "53"
}
}

result, rt, err := rbl.DNSClient.Exchange(msg, net.JoinHostPort(host, port))
log.Debugln("Roundtrip", rt) // fixme -> histogram

return result, err
Expand Down
4 changes: 2 additions & 2 deletions dnsbl_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func main() {
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config.dns-resolver",
Value: "127.0.0.1",
Usage: "IP address of the resolver to use.",
Value: "127.0.0.1:53",
Usage: "IP address[:port] of the resolver to use.",
},
cli.StringFlag{
Name: "config.rbls",
Expand Down

0 comments on commit 1180cd1

Please sign in to comment.