Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelopsio committed Nov 22, 2024
1 parent 4ed0d67 commit d8add01
Show file tree
Hide file tree
Showing 7 changed files with 1,303 additions and 7 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests

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

jobs:
test:
strategy:
matrix:
go-version: [1.21.x]
platform: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install Task
uses: arduino/setup-task@v1

- name: Run Tests
run: |
task test
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage/coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true

# integration:
# runs-on: ubuntu-latest
# needs: test
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: "1.21"
#
# - name: Run Integration Tests
# run: |
# task test-integration
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_REGION: us-west-2
18 changes: 17 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,28 @@ tasks:
- golangci-lint run --config=.golangci.yml

test:
desc: Run tests
desc: Run unit tests
cmds:
- mkdir -p {{.COVERAGE_DIR}}
- go test -race -coverprofile={{.COVERAGE_DIR}}/coverage.out -covermode=atomic ./...
- go tool cover -html={{.COVERAGE_DIR}}/coverage.out -o {{.COVERAGE_DIR}}/coverage.html

test-integration:
desc: Run integration tests
cmds:
- go test -tags=integration ./... -v

test-coverage:
desc: Show test coverage in browser
deps: [test]
cmds:
- go tool cover -html={{.COVERAGE_DIR}}/coverage.out

test-race:
desc: Run tests with race detector
cmds:
- go test -race ./...

build:
desc: Build binary
cmds:
Expand Down
Loading

0 comments on commit d8add01

Please sign in to comment.