diff options
author | 2020-11-06 14:14:26 +0100 | |
---|---|---|
committer | 2020-11-06 14:14:26 +0100 | |
commit | cd5ee7d1f08d18d922da08191a9987e3ee622411 (patch) | |
tree | 7ed98a3a375036881a84d82151ec819551ed27ac | |
parent | 049369583bec9c6f3ab751cd68bcfc4224e7df45 (diff) | |
download | coredns-cd5ee7d1f08d18d922da08191a9987e3ee622411.tar.gz coredns-cd5ee7d1f08d18d922da08191a9987e3ee622411.tar.zst coredns-cd5ee7d1f08d18d922da08191a9987e3ee622411.zip |
Remove travis and move to github workflow (#4267)
Add github testing workflow, simplify the Makefile because that was
complex because of Travis. Remove the fuzzing, needs to be re-added when
that works properly with go modules (it has been disabled for quite some
time). Multiple builds and files have been added so these tests can all
run in parallel. Our testing now tests a couple of minutes, the codeql
is by far the more expensive.
Move metric's naming test to test/presubmit_test.go
Add longer sleep in the TestAutoAXFR.
Bye bye travis!
Closes: #4266
Signed-off-by: Miek Gieben <miek@miek.nl>
-rw-r--r-- | .github/workflows/codeql-analysis.yml | 28 | ||||
-rw-r--r-- | .github/workflows/go.coverage.yml | 28 | ||||
-rw-r--r-- | .github/workflows/go.test.yml | 67 | ||||
-rw-r--r-- | .github/workflows/go.tidy.yml | 2 | ||||
-rw-r--r-- | .github/workflows/make.doc.yml | 2 | ||||
-rw-r--r-- | .travis.yml | 51 | ||||
-rw-r--r-- | Makefile | 48 | ||||
-rw-r--r-- | test/auto_test.go | 2 | ||||
-rw-r--r-- | test/presubmit_test.go | 19 |
9 files changed, 117 insertions, 130 deletions
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index aafc5f70d..524161be8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,16 +1,9 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. - name: "CodeQL" on: push: branches: [ master ] pull_request: - # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '22 10 * * 4' @@ -24,39 +17,18 @@ jobs: fail-fast: false matrix: language: [ 'go' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - name: Checkout repository uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v1 - # âšī¸ Command-line programs to run using the OS shell. - # đ https://git.io/JvXDl - - # âī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/go.coverage.yml b/.github/workflows/go.coverage.yml new file mode 100644 index 000000000..63101d774 --- /dev/null +++ b/.github/workflows/go.coverage.yml @@ -0,0 +1,28 @@ +name: Go Coverage +on: [push, pull_request] +jobs: + test: + name: Coverage + runs-on: ubuntu-latest + steps: + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: go build -v ./... + + - name: Test With Coverage + run: | + for d in request core coremain plugin test; do \ + ( cd $d; go test -coverprofile=cover.out -covermode=atomic -race ./...; [ -f cover.out ] && cat cover.out >> ../coverage.txt ); \ + done + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 diff --git a/.github/workflows/go.test.yml b/.github/workflows/go.test.yml new file mode 100644 index 000000000..f38a5762f --- /dev/null +++ b/.github/workflows/go.test.yml @@ -0,0 +1,67 @@ +name: Go Tests +on: [push, pull_request] +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: go build -v ./... + + - name: Test + run: | + ( cd request; go test -race ./... ) + ( cd core; go test -race ./... ) + ( cd coremain; go test -race ./... ) + + test-plugins: + name: Test Plugins + runs-on: ubuntu-latest + steps: + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: go build -v ./... + + - name: Test + run: ( cd plugin; go test -race ./... ) + + test-e2e: + name: Test e2e + runs-on: ubuntu-latest + steps: + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + id: go + + - name: Check out code + uses: actions/checkout@v2 + + - name: Build + run: go build -v ./... + + - name: Test + run: | + go install github.com/fatih/faillint + ( cd test; go test -race ./... ) diff --git a/.github/workflows/go.tidy.yml b/.github/workflows/go.tidy.yml index 060b6d108..a0175f5a0 100644 --- a/.github/workflows/go.tidy.yml +++ b/.github/workflows/go.tidy.yml @@ -1,4 +1,4 @@ -name: go tidy +name: Go Tidy on: push: diff --git a/.github/workflows/make.doc.yml b/.github/workflows/make.doc.yml index 509381163..0c29194bc 100644 --- a/.github/workflows/make.doc.yml +++ b/.github/workflows/make.doc.yml @@ -1,4 +1,4 @@ -name: make doc +name: Make Doc on: push: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4420cb324..000000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -dist: xenial -services: - - docker -language: go -go: - - "1.15.x" - -cache: - directories: - - $GOPATH/pkg/mod - -go_import_path: github.com/coredns/coredns - -git: - depth: 1 - -branches: - only: - - master - -env: - global: - # This is FUZZIT_API_KEY - - secure: "IGpZAyt1e5BZ1C4LeJG+GrgFZzaBQkJ3BX/+MwWN85aJSDk5gwThS53OCr/7RFgBKBgP9xBv9i9hAv0PxVaRE0ETIzjc0rQzceJIWiYKfFYQyscFahKfSiGsWP32rMlU3K67tA7yITS+Z8mMyVH9Ndr1Fg9AmLL+WfATdrd6dP8hzsUpaghKlnJee9TycrfamDpISzecdOY9xzxcwRyphZxuCc/n236Nt7f7Ccz0zx/Qa5igX6mjKZpUyBpS2u02GmNJTfc3W5SbTRP5bSJ+ozSkZZyG3tTpYmeN87AQJ/oG7rUEzqGLt78i7jSYAXghJZT06H/fHFsOKssCj1m0hYiarnGoGzXScLDqp2fpkyzilsUT+W0VgXTy2Nq+88Sideiy6UwDwpqHr5ktyoYFeSVB/aCTJl5oxDxBqs9dfeJSEAy7/AYy8kJoIE/yPYsBnGw10CAED4Rf5mfDgstkZRBdAO0xLBihkPsgza2975DVf27YSjJZ4eKrnR+G/aNCKycLQvWD/5c2bcLCJqyz0uMLQC/4LspS9b5bAKurzqFRdrD5q78NDcbodHelc7zBlFrRwGFCUjXTbQoU6r+1FA8y2Z+n1bd7mIF1JBVHurYAygyYXOcry870hyucGojonvdgBvHp6txeYyPU14VvTNwkF2mddpBCvoSTSPZ5X64=" - matrix: - - TEST_TYPE=coverage - - TEST_TYPE=integration - - TEST_TYPE=core - - TEST_TYPE=plugin - - TEST_TYPE=fmt - - TEST_TYPE=metrics -# - TEST_TYPE=fuzzit FUZZIT_TYPE=local-regression -# - TEST_TYPE=fuzzit FUZZIT_TYPE=fuzzing - -# In the Travis VM-based build environment, IPv6 networking is not -# enabled by default. The sysctl operations below enable IPv6. -# IPv6 is needed by some of the CoreDNS test cases. - -before_install: - - cat /proc/net/if_inet6 - - uname -a - - sudo bash -c 'if [ `cat /proc/net/if_inet6 | wc -l` = "0" ]; then echo "Enabling IPv6" ; sysctl net.ipv6.conf.all.disable_ipv6=0 ; sysctl net.ipv6.conf.default.disable_ipv6=0 ; sysctl net.ipv6.conf.lo.disable_ipv6=0 ; fi' - - cat /proc/net/if_inet6 - - env - -script: - - make TEST_TYPE=$TEST_TYPE travis - -after_success: - - bash <(curl -s https://codecov.io/bash) - - bash .benchmark.sh @@ -18,54 +18,6 @@ coredns: $(CHECKS) .PHONY: check check: core/plugin/zplugin.go core/dnsserver/zdirectives.go -.PHONY: travis -travis: -ifeq ($(TEST_TYPE),core) - ( cd request; go test -race ./... ) - ( cd core; go test -race ./... ) - ( cd coremain; go test -race ./... ) -endif -ifeq ($(TEST_TYPE),integration) - ( cd test; go test -race ./... ) -endif -ifeq ($(TEST_TYPE),fmt) - ( echo "fmt"; gofmt -w -s . | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi ) -endif -ifeq ($(TEST_TYPE),metrics) - ( echo "metrics"; go get github.com/fatih/faillint) - ( faillint -paths "github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,\ - NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,\ - NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}" ./...) -endif -ifeq ($(TEST_TYPE),plugin) - ( cd plugin; go test -race ./... ) -endif -ifeq ($(TEST_TYPE),coverage) - for d in `go list ./... | grep -v vendor`; do \ - t=$$(date +%s); \ - go test -i -coverprofile=cover.out -covermode=atomic $$d || exit 1; \ - go test -coverprofile=cover.out -covermode=atomic $$d || exit 1; \ - if [ -f cover.out ]; then \ - cat cover.out >> coverage.txt && rm cover.out; \ - fi; \ - done -endif -ifeq ($(TEST_TYPE),fuzzit) - # skip fuzzing for PR - if [ "$(TRAVIS_PULL_REQUEST)" = "false" ] || [ "$(FUZZIT_TYPE)" = "local-regression" ] ; then \ - export GO111MODULE=off; \ - go get -u github.com/dvyukov/go-fuzz/go-fuzz-build; \ - go get -u -v .; \ - cd ../../go-acme/lego && git checkout v2.5.0; \ - cd ../../coredns/coredns; \ - LIBFUZZER=YES $(MAKE) -f Makefile.fuzz all; \ - $(MAKE) -sf Makefile.fuzz fuzzit; \ - for i in `$(MAKE) -sf Makefile.fuzz echo`; do echo $$i; \ - ./fuzzit create job --type $(FUZZIT_TYPE) coredns/$$i ./$$i; \ - done; \ - fi; -endif - core/plugin/zplugin.go core/dnsserver/zdirectives.go: plugin.cfg go generate coredns.go diff --git a/test/auto_test.go b/test/auto_test.go index f7502172f..906f5223e 100644 --- a/test/auto_test.go +++ b/test/auto_test.go @@ -142,7 +142,7 @@ func TestAutoAXFR(t *testing.T) { t.Fatal(err) } - time.Sleep(10 * time.Millisecond) // wait for it to be picked up + time.Sleep(50 * time.Millisecond) // wait for it to be picked up tr := new(dns.Transfer) m := new(dns.Msg) diff --git a/test/presubmit_test.go b/test/presubmit_test.go index 44692b160..f2b4c8bea 100644 --- a/test/presubmit_test.go +++ b/test/presubmit_test.go @@ -9,6 +9,7 @@ import ( "go/parser" "go/token" "os" + "os/exec" "path/filepath" "strings" "testing" @@ -400,3 +401,21 @@ func importtype(s string) string { } return "std" } + +// TestMetricNaming tests the imports path used for metrics. It depends on faillint to be installed: go install github.com/fatih/faillint +func TestPrometheusImports(t *testing.T) { + if _, err := exec.LookPath("faillint"); err != nil { + fmt.Fprintf(os.Stderr, "Not executing TestPrometheusImports: faillint not found\n") + return + } + + // make this multiline? + p := `github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}` + + cmd := exec.Command("faillint", "-paths", p, "./...") + cmd.Dir = ".." + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("Failed: %s\n%s", err, out) + } +} |