Skip to content

Commit

Permalink
test: adding unit test pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
daithihearn committed Nov 5, 2023
1 parent 0551add commit 5f5e8e4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run unit tests

on:
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
unit-tests:
name: Run unit tests
runs-on: self-hosted

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.18' # Use the version of Go you need for your project

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

- name: Get dependencies
run: make dependencies # Assuming you have a make target for fetching dependencies

- name: Test
run: make test

- name: Upload test coverage (optional)
uses: actions/upload-artifact@v3
if: always()
with:
name: test-coverage
path: coverage.out
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

build/

.idea
.idea

coverage.out
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ help:
docs: #@ Generate docs
swag init -g cmd/api/main.go
.PHONY:docs
test: fmt #@ Run tests
go test -v ./...
test: fmt vet #@ Run tests
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html

fmt: #@ Format the code
go fmt ./...
vet: fmt #@ VET the code
Expand Down

0 comments on commit 5f5e8e4

Please sign in to comment.