From 5ed2bafa2ba4ee8d307cc2210f9fd0021f18ccd1 Mon Sep 17 00:00:00 2001 From: Masala Date: Sun, 12 Jan 2025 11:04:19 +0000 Subject: [PATCH 1/2] add unit test coverage to CI --- .github/workflows/go.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 852263d..d78fa78 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,20 @@ name: build on: [push] jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + arch: [amd64] + go-version: [ "1.22.x"] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: run unit tests + run: go test -coverprofile=coverage.out -race -v -failfast -timeout 30m ./... + build_linux: runs-on: ubuntu-22.04 steps: From 42f2440c8ee8921633202f193f60a339c53bb25b Mon Sep 17 00:00:00 2001 From: Masala Date: Sun, 12 Jan 2025 11:15:02 +0000 Subject: [PATCH 2/2] add Make target docker-test to run unit tests --- .github/workflows/go.yml | 3 ++- Makefile | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d78fa78..91ac3f8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,8 +12,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: run unit tests - run: go test -coverprofile=coverage.out -race -v -failfast -timeout 30m ./... + run: make docker-test build_linux: runs-on: ubuntu-22.04 diff --git a/Makefile b/Makefile index c9abda8..766c6c1 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,10 @@ $(cache_dir): $(cache_dir)/go $(cache_dir)/go: mkdir -p $(cache_dir)/go +docker-test: docker-$(distro)-base + $(docker) $(docker_run_cmd) --rm katzen/$(distro)_base \ + go test -coverprofile=coverage.out -race -v -failfast -timeout 30m ./... + docker-build-linux: docker-$(distro)-base @([ "$(distro)" = "debian" ] || [ "$(distro)" = "alpine" ]) || \ (echo "can only docker-build-linux for debian or alpine, not $(distro)" && false)