Skip to content

Commit

Permalink
Added a GitHub action for running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carloscarnero committed Nov 15, 2024
1 parent 00add66 commit 38df57f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test and coverage report

on:
push:

jobs:
test:
runs-on: ubuntu-24.04

steps:
- name: Distribution source checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Retrieve Go dependencies
run: |
go mod download
- name: Run tests and generate coverage report
run: |
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage.txt
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
> there is probably no reason why you should actually use this 🤷
![License](https://img.shields.io/badge/License-MIT-blue.svg)
[![codecov](https://codecov.io/github/carloscarnero/go-logger/graph/badge.svg?token=Bg1xghG6HS)](https://codecov.io/github/carloscarnero/go-logger)

Retrieve the package with:

Expand All @@ -24,8 +25,8 @@ import (
)

func main() {
// l will be a pointer to a slog.Logger instance, from the standard
// library. Note that no error handling is included in this example.
// l will be a pointer to a standard library slog.Logger instance. Note
// that no error handling is included in this example.
l, _ := logger.New(os.Stdout, "TEXT", "INFO", false)

l.Info("Hello, world!")
Expand All @@ -38,10 +39,9 @@ Running the above program will send `Hello, world!` to the standard output:
level=INFO msg="Hello, world!"
```

> Note that the module path is `go.carloscarnero.stream/go-logger`,
> however, the package is called `logger`. This is not very elegant but it
> is an artifact of having to name the [source code repository][REPO] in
> that particular way.
> [!NOTE]
> While the module path is `go.carloscarnero.stream/go-logger`, the package
> is called `logger`. This is not very elegant but results from having to
> name the source code repository in that particular way.
[LOGGER]: https://pkg.go.dev/log/slog#Logger
[REPO]: https://github.com/carloscarnero/go-logger
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.carloscarnero.stream/go-logger

go 1.23.2
go 1.23.3

require github.com/stretchr/testify v1.9.0

Expand Down

0 comments on commit 38df57f

Please sign in to comment.