Workflow changes (#857)

* 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
This commit is contained in:
Kwitsch 2023-02-07 14:00:53 +01:00 committed by GitHub
parent 6e69d46c6a
commit 101e2c554b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 89 additions and 94 deletions

View File

@ -1,35 +0,0 @@
name: CI Build
on: [push, pull_request]
jobs:
make:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
make: [build, test, race, docker-build, goreleaser]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
id: go
- name: Get dependencies
run: go mod download
- name: make ${{ matrix.make }}
run: make ${{ matrix.make }}
if: matrix.make != 'goreleaser'
- 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

View File

@ -1,27 +0,0 @@
name: Run e2e tests
on:
push:
pull_request:
jobs:
e2e-test:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
id: go
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Run e2e
run: make e2e-test

View File

@ -1,20 +0,0 @@
name: golangci-lint
on:
push:
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- uses: actions/checkout@v3
- name: golangci-lint
run: make lint

73
.github/workflows/makefile.yml vendored Normal file
View File

@ -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

View File

@ -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)
@ -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))
@ -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} \

View File

@ -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")))

View File

@ -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"))
})
})

View File

@ -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"),
@ -81,7 +81,7 @@ 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() {
@ -89,7 +89,7 @@ var _ = Describe("Redis configuration tests", func() {
})
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"),
@ -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"),
@ -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"),

View File

@ -2,6 +2,7 @@ package redis
import (
"encoding/json"
"time"
"github.com/0xERR0R/blocky/config"
"github.com/0xERR0R/blocky/util"
@ -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))

View File

@ -1,4 +1,3 @@
//go:generate go run github.com/abice/go-enum -f=$GOFILE --marshal --names
package resolver
import (