-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coverall CI pipeline, add doc about testing approach, replace md …
…file formatter (#54) * Use prettier instead of mdox, re-format docs, respect 2 space indents
- Loading branch information
Showing
23 changed files
with
323 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- ignore-for-release | ||
categories: | ||
- title: Breaking Changes 🛠 | ||
labels: | ||
- Semver-Major | ||
- breaking-change | ||
- title: Enhancements 🚀 | ||
labels: | ||
- Semver-Minor | ||
- enhancement | ||
- title: Fixed Bugs 🐛 | ||
labels: | ||
- bug | ||
- title: Other Changes ✨ | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Coverall | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
|
||
jobs: | ||
test: | ||
name: Test with Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Set git to use LF" | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global core.eol lf | ||
- name: "Checkout code" | ||
uses: actions/checkout@v3 | ||
- name: "Set up Go" | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.19.1' # must be hardcoded as it's expected in tests | ||
cache: true | ||
- uses: szenius/set-timezone@a5c1676bd4e141779a42a699cc086f3c5ddd1a6c | ||
with: | ||
timezoneLinux: "Europe/Warsaw" | ||
timezoneMacos: "Europe/Warsaw" | ||
timezoneWindows: "Central European Standard Time" | ||
- name: "Unit tests" | ||
uses: magefile/mage-action@5f7a9a23cfef763949ca41834b868167adbd1b59 # v2.0.0 | ||
with: | ||
version: latest | ||
args: test:unit | ||
|
||
- name: "Install goveralls" | ||
run: go install github.com/mattn/goveralls@latest | ||
- name: "Send coverage" | ||
env: | ||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: goveralls -coverprofile=coverage.out -service=github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Package testing | ||
|
||
The `version` package is tested both via unit and e2e tests. | ||
|
||
## Unit tests | ||
|
||
Unit tests focus more on the corner cases that are hard to reproduce using e2e testing. Unit tests are executed on CI via [**Testing**](https://github.com/mszostok/version/actions/workflows/testing.yml) workflow. | ||
|
||
- All tests are executed with the latest Go version on all platforms, using GitHub Action job strategy: | ||
```yaml | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
``` | ||
- All tests are run both on pull-requests and the `main` branch | ||
- The tests' coverage is uploaded to [coveralls.io/github/mszostok/version](https://coveralls.io/github/mszostok/version) | ||
|
||
## E2E tests | ||
|
||
The e2e tests build a Go binary, run it, and compare with [golden files](https://github.com/mszostok/version/tree/main/tests/e2e/testdata). E2E tests are executed on CI via [**Testing**](https://github.com/mszostok/version/actions/workflows/testing.yml) workflow. | ||
|
||
As a result, e2e test focus on: | ||
|
||
- Building Go binaries | ||
- Overriding version information via `ldflags` | ||
- Running binary on operating system | ||
- Testing if color output for non-tty output streams is disabled automatically | ||
- Ensuring that all [examples](https://github.com/mszostok/version/tree/main/examples) are runnable | ||
- Executing a real call against GitHub API | ||
- Executing binaries on all platforms, using GitHub Action job strategy: | ||
```yaml | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
``` | ||
|
||
Each time a new functionality is implemented, a dedicated [test case](https://github.com/mszostok/version/blob/main/tests/e2e/e2e_test.go#L31) is added. | ||
|
||
!!! note | ||
|
||
Currently, there is no easy way to calculate the coverage based on the e2e tests (built and executed binaries). However, this will be enabled once the [golang#51430](https://github.com/golang/go/issues/51430) issue will be implemented. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.