Skip to content

Commit

Permalink
Workflow changes (#857)
Browse files Browse the repository at this point in the history
* fix linter errors

* fix for flaky redis unit test

* timeout adjustment

* e2e-test -> ci-build

* setup docker buildx

* added concurrency cancelation

* changed job name

* Test comment out problematic eventually

* added comment

* workflow file rename

* workflow name changed

* skip go generate

* added make generate

* removed unused go generate

* setup golang with caches if needed

* matrix revamp

* activate gofor e2e

* fix matrix

* test

* eventually timing

* removed linter workflow in favor of make matrix

* expect -> Eventually

* renamed workflow
  • Loading branch information
kwitsch committed Feb 7, 2023
1 parent 6e69d46 commit 101e2c5
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 94 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/ci-build.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/e2e-tests.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/golangci-lint.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/makefile.yml
@@ -0,0 +1,73 @@
name: Makefile

on:
push:
pull_request:

permissions:
security-events: write
actions: read
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
make:
name: make
runs-on: ubuntu-latest
strategy:
matrix:
include:
- make: build
go: true
docker: false
- make: test
go: true
docker: false
- make: race
go: true
docker: false
- make: docker-build
go: false
docker: true
- make: e2e-test
go: true
docker: true
- make: goreleaser
go: false
docker: false
- make: lint
go: true
docker: false

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
if: matrix.go == true
with:
go-version-file: go.mod

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: matrix.docker == true

- name: make ${{ matrix.make }}
run: make ${{ matrix.make }}
if: matrix.make != 'goreleaser'
env:
GO_SKIP_GENERATE: 1

- name: Upload results to codecov
uses: codecov/codecov-action@v3
if: matrix.make == 'test'

- name: Check GoReleaser configuration
uses: goreleaser/goreleaser-action@v4
if: matrix.make == 'goreleaser'
with:
args: check
9 changes: 5 additions & 4 deletions Makefile
@@ -1,4 +1,4 @@
.PHONY: all clean build swagger test e2e-test lint run fmt docker-build help
.PHONY: all clean generate build swagger test e2e-test lint run fmt docker-build help
.DEFAULT_GOAL:=help

VERSION?=$(shell git describe --always --tags)
Expand Down Expand Up @@ -41,12 +41,14 @@ serve_docs: ## serves online docs
pip install mkdocs-material
mkdocs serve

build: ## Build binary
generate: ## Go generate
ifdef GO_SKIP_GENERATE
$(info skipping go generate)
else
go generate ./...
endif

build: generate ## Build binary
go build $(GO_BUILD_FLAGS) -ldflags="$(GO_BUILD_LD_FLAGS)" -o $(GO_BUILD_OUTPUT)
ifdef BIN_USER
$(info setting owner of $(GO_BUILD_OUTPUT) to $(BIN_USER))
Expand Down Expand Up @@ -82,8 +84,7 @@ fmt: ## gofmt and goimports all go files
go run mvdan.cc/gofumpt -l -w -extra .
find . -name '*.go' -exec goimports -w {} +

docker-build: ## Build docker image
go generate ./...
docker-build: generate ## Build docker image
docker buildx build \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_TIME=${BUILD_TIME} \
Expand Down
2 changes: 1 addition & 1 deletion e2e/blocking_test.go
Expand Up @@ -77,7 +77,7 @@ var _ = Describe("External lists and query blocking", func() {
})

It("should fail to start", func() {
Eventually(blocky.IsRunning, "30s").Should(BeFalse())
Eventually(blocky.IsRunning, "5s", "2ms").Should(BeFalse())

Expect(getContainerLogs(blocky)).
Should(ContainElement(ContainSubstring("Error: can't start server: 1 error occurred")))
Expand Down
3 changes: 2 additions & 1 deletion e2e/metrics_test.go
Expand Up @@ -67,7 +67,8 @@ var _ = Describe("Metrics functional tests", func() {
})

It("Should provide 'blocky_blocking_enabled' prometheus metrics", func() {
Eventually(fetchBlockyMetrics).WithArguments(metricsURL).Should(ContainElement("blocky_blocking_enabled 1"))
Eventually(fetchBlockyMetrics, "30s", "2ms").WithArguments(metricsURL).
Should(ContainElement("blocky_blocking_enabled 1"))
})
})

Expand Down
10 changes: 5 additions & 5 deletions e2e/redis_test.go
Expand Up @@ -72,7 +72,7 @@ var _ = Describe("Redis configuration tests", func() {
It("2nd instance of blocky should use cache from redis", func() {
msg := util.NewMsgWithQuestion("google.de.", A)
By("Query first blocky instance, should store cache in redis", func() {
Expect(doDNSRequest(blocky1, msg)).
Eventually(doDNSRequest, "5s", "2ms").WithArguments(blocky1, msg).
Should(
SatisfyAll(
BeDNSRecord("google.de.", A, "1.2.3.4"),
Expand All @@ -81,15 +81,15 @@ var _ = Describe("Redis configuration tests", func() {
})

By("Check redis, must contain one cache entry", func() {
Eventually(dbSize).WithArguments(redisClient).Should(BeNumerically("==", 1))
Eventually(dbSize, "5s", "2ms").WithArguments(redisClient).Should(BeNumerically("==", 1))
})

By("Shutdown the upstream DNS server", func() {
Expect(moka.Terminate(context.Background())).Should(Succeed())
})

By("Query second blocky instance, should use cache from redis", func() {
Expect(doDNSRequest(blocky2, msg)).
Eventually(doDNSRequest, "5s", "2ms").WithArguments(blocky2, msg).
Should(
SatisfyAll(
BeDNSRecord("google.de.", A, "1.2.3.4"),
Expand Down Expand Up @@ -124,7 +124,7 @@ var _ = Describe("Redis configuration tests", func() {
It("should load cache from redis after start", func() {
msg := util.NewMsgWithQuestion("google.de.", A)
By("Query first blocky instance, should store cache in redis\"", func() {
Expect(doDNSRequest(blocky1, msg)).
Eventually(doDNSRequest, "5s", "2ms").WithArguments(blocky1, msg).
Should(
SatisfyAll(
BeDNSRecord("google.de.", A, "1.2.3.4"),
Expand Down Expand Up @@ -156,7 +156,7 @@ var _ = Describe("Redis configuration tests", func() {
})

By("Query second blocky instance", func() {
Expect(doDNSRequest(blocky2, msg)).
Eventually(doDNSRequest, "5s", "2ms").WithArguments(blocky2, msg).
Should(
SatisfyAll(
BeDNSRecord("google.de.", A, "1.2.3.4"),
Expand Down
3 changes: 3 additions & 0 deletions redis/redis_test.go
Expand Up @@ -2,6 +2,7 @@ package redis

import (
"encoding/json"
"time"

"github.com/0xERR0R/blocky/config"
"github.com/0xERR0R/blocky/util"
Expand Down Expand Up @@ -255,6 +256,8 @@ var _ = Describe("Redis client", func() {
rec := redisServer.Publish(SyncChannelName, string(binMsg))
Expect(rec).Should(Equal(1))

time.Sleep(2 * time.Second)

Eventually(func() chan *EnabledMessage {
return redisClient.EnabledChannel
}).Should(HaveLen(lenE))
Expand Down
1 change: 0 additions & 1 deletion resolver/resolver.go
@@ -1,4 +1,3 @@
//go:generate go run github.com/abice/go-enum -f=$GOFILE --marshal --names
package resolver

import (
Expand Down

0 comments on commit 101e2c5

Please sign in to comment.