Skip to content

Commit

Permalink
Run tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dansimau committed Dec 4, 2024
1 parent 3ae2e71 commit 4319b35
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Checks

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

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
permissions: write-all
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Run tests
run: go test -json ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... > test-results.json

- name: Annotate
if: always()
uses: guyarb/[email protected]
with:
test-results: test-results.json

- name: Check coverage
uses: vladopajic/go-test-coverage@v2
with:
config: ./.testcoverage.yml
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }}
git-branch: badges
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cover.out
2 changes: 2 additions & 0 deletions .testcoverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
profile: cover.out
local-prefix: github.com/dansimau/hal
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

.PHONY: lint
lint:
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.62.2
golangci-lint run

.PHONY: test
test:
go test -v ./...
which go-test-coverage || go install github.com/vladopajic/go-test-coverage/v2@latest
go test -v ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
go-test-coverage --config=./.testcoverage.yaml
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Home Automation Logic (HAL) Framework

![coverage](https://raw.githubusercontent.com/dansimau/hal/badges/.badges/main/coverage.svg)

HAL is a framework for programming home automation logic in Golang using Home
Assistant.

Expand Down

0 comments on commit 4319b35

Please sign in to comment.