Skip to content

Commit

Permalink
ci(workflows): initial support for test
Browse files Browse the repository at this point in the history
Add a Makefile task to locally run it
  • Loading branch information
Lujeni committed May 28, 2024
1 parent 9410cd4 commit 26055d3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@

VERSION ?= $(shell ./hack/get-version.sh)

.PHONY:fmt vet build
GO_IMG ?= golang:alpine3.20@sha256:1b455a3f7786e5765dbeb4f7ab32a36cdc0c3f4ddd35406606df612dc6e3269b

.PHONY: fmt vet build unit-test

DOCKER_CMD = docker run --rm -v $(PWD):/app -w /app ${GO_IMG}

## verify: Format code
fmt:
go fmt ./...

## verify: Verify code
vet: fmt
go vet ./...

## build: Build binary
build: vet
go build
go build -v ./...

## unit-test: Run unit tests
unit-test:
ifeq ($(USE_DOCKER), 1)
@${DOCKER_CMD} go test -v ./...
else
go test -v ./..
endif

## build-image: Build image
build-docker: vet
docker build -t numberly/vault-db-injector:${VERSION} .

## build-image: Push image
push-docker: build-docker
docker push numberly/vault-db-injector:${VERSION}

0 comments on commit 26055d3

Please sign in to comment.