From 8f29f9048828735ad1e410dce9de6bcc9df4bffa Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Wed, 7 Sep 2022 16:04:25 +0300 Subject: [PATCH 1/2] Add 'go test' Makefile target Signed-off-by: Ionut Balutoiu --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8df31f61..f069fe2e 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,21 @@ SHELL := bash -.PHONY : build-static - IMAGE_TAG = garm-build USER_ID=$(shell ((docker --version | grep -q podman) && echo "0" || id -u)) USER_GROUP=$(shell ((docker --version | grep -q podman) && echo "0" || id -g)) +GO_PACKAGES?=$(shell (go list ./... | grep -v 'vendor')) + +default: build-static + +.PHONY : build-static build-static: @echo Building garm docker build --tag $(IMAGE_TAG) . docker run --rm -e USER_ID=$(USER_ID) -e USER_GROUP=$(USER_GROUP) -v $(PWD):/build/garm:z $(IMAGE_TAG) /build-static.sh @echo Binaries are available in $(PWD)/bin + +.PHONY: test +test: + go test $(GO_PACKAGES) -v $(TEST_ARGS) -timeout=15m -parallel=4 From 30c15109679a03fc27189ae582897dbfb5c51a4f Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Wed, 7 Sep 2022 16:14:54 +0300 Subject: [PATCH 2/2] Add Go Tests GitHub workflow Signed-off-by: Ionut Balutoiu --- .github/workflows/go-tests.yml | 27 +++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/go-tests.yml diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml new file mode 100644 index 00000000..1ed634be --- /dev/null +++ b/.github/workflows/go-tests.yml @@ -0,0 +1,27 @@ +name: Go Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + go-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Golang + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + + - run: go version + + - name: Run GARM Go Tests + run: make test diff --git a/README.md b/README.md index f36a20e9..f5d8f8ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # GitHub Actions Runners Manager (garm) +![Go Tests](https://github.com/cloudbase/garm/actions/workflows/go-tests.yml/badge.svg) + Welcome to garm! Garm enables you to create and automatically maintain pools of [self-hosted GitHub runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners), with autoscaling that can be used inside your github workflow runs.