-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 16248a3
Showing
51 changed files
with
2,946 additions
and
0 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,31 @@ | ||
--- | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
workflow_dispatch: | ||
inputs: {} | ||
|
||
jobs: | ||
build: | ||
name: Tests with Go ${{ matrix.golang }} | ||
runs-on: "ubuntu-latest" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
golang: ["1.21.x"] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.golang }} | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Run tests | ||
run: ./bin/test |
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,2 @@ | ||
/coverage | ||
/build |
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,74 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, gender identity and expression, level of | ||
experience, nationality, personal appearance, race, religion, or sexual identity | ||
and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
- Using welcoming and inclusive language | ||
- Being respectful of differing viewpoints and experiences | ||
- Gracefully accepting constructive criticism | ||
- Focusing on what is best for the community | ||
- Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
- The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
- Trolling, insulting/derogatory comments, and personal or political attacks | ||
- Public or private harassment | ||
- Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
- Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject | ||
comments, commits, code, wiki edits, issues, and other contributions that are | ||
not aligned to this Code of Conduct, or to ban temporarily or permanently any | ||
contributor for other behaviors that they deem inappropriate, threatening, | ||
offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [email protected]. All complaints will be | ||
reviewed and investigated and will result in a response that is deemed necessary | ||
and appropriate to the circumstances. The project team is obligated to maintain | ||
confidentiality with regard to the reporter of an incident. Further details of | ||
specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], | ||
version 1.4, available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Nando Vieira | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,142 @@ | ||
# bolt | ||
|
||
[![Latest release](https://img.shields.io/github/v/release/fnando/bolt?label=version)](https://github.com/fnando/bolt/releases/latest) | ||
[![Tests](https://github.com/fnando/bolt/actions/workflows/tests.yml/badge.svg)](https://github.com/fnando/bolt/actions/workflows/tests.yml) | ||
|
||
A better format output for golang's tests. | ||
|
||
We've all been there... a bunch of tests failing and you have no idea where to | ||
start, because everything looks the same. And that one test failing in the sea | ||
of passing tests? So frustrating. Not anymore! | ||
|
||
With `bolt` you'll see a progress output while tests are being executed. Once | ||
tests are done, you'll see an output with only the tests that failed. Simple and | ||
easy! | ||
|
||
Here's the before and after: | ||
|
||
![An image showing the comparison between the native output versus bolt's](https://github.com/fnando/bolt/raw/main/bolt.png) | ||
|
||
Features: | ||
|
||
- Colored output | ||
- Dotenv files support | ||
- Coverage output | ||
- Slowest tests output | ||
- Benchmark output | ||
|
||
## Install | ||
|
||
Download the binary for your system from the | ||
[latest release](https://github.com/fnando/bolt/releases/latest) and place it | ||
anywhere on your path. | ||
|
||
## Usage | ||
|
||
bolt wraps `go test`. You can run it with: | ||
|
||
```shell | ||
$ bolt run ./... | ||
``` | ||
|
||
Options: | ||
|
||
```shell | ||
$ bolt -h | ||
|
||
bolt is a golang test runner that has a nicer output. | ||
|
||
Usage: bolt [command] [options] | ||
|
||
Commands: | ||
|
||
bolt version Show bolt version | ||
bolt run Run tests | ||
bolt update Update to the latest released version | ||
bolt [command] --help Display help on [command] | ||
|
||
|
||
Further information: | ||
https://github.com/fnando/bolt | ||
``` | ||
|
||
To get the latest download url for your binary, you can use `bolt download-url`. | ||
|
||
### Reporters | ||
|
||
bolt comes with two different reporters: | ||
|
||
### JSON | ||
|
||
The JSON reporter outputs a nicer JSON format that can be used to do things that | ||
require structured data. | ||
|
||
```shell | ||
$ bolt run ./... --reporter json | ||
``` | ||
|
||
### Progress | ||
|
||
The progress reporter outputs a sequence of characters that represent the test's | ||
status (fail, pass, skip). Once all tests have been executed, a summary with the | ||
failing and skipped tests, plus a coverage list is printed. | ||
|
||
```shell | ||
$ bolt run ./... --reporter progress | ||
``` | ||
|
||
#### Overriding colors | ||
|
||
You can override the colors by setting the following env vars: | ||
|
||
```bash | ||
export bolt_TEXT_COLOR="30" | ||
export bolt_FAIL_COLOR="31" | ||
export bolt_PASS_COLOR="32" | ||
export bolt_SKIP_COLOR="33" | ||
export bolt_DETAIL_COLOR="34" | ||
``` | ||
|
||
To disable color output completely, just set `NO_COLOR=1`. | ||
|
||
#### Overriding symbols | ||
|
||
To override the characters, you can set some env vars. The following example | ||
shows how to use emojis instead: | ||
|
||
```shell | ||
export bolt_FAIL_SYMBOL=❌ | ||
export bolt_PASS_SYMBOL=⚡️ | ||
export bolt_SKIP_SYMBOL=😴 | ||
``` | ||
|
||
## Code of Conduct | ||
|
||
Everyone interacting in the bolt project’s codebases, issue trackers, chat rooms | ||
and mailing lists is expected to follow the | ||
[code of conduct](https://github.com/fnando/bolt/blob/main/CODE_OF_CONDUCT.md). | ||
|
||
## Developing | ||
|
||
To generate new test replay files, you can use | ||
`go test -cover -json -tags=reference ./test/reference/package > test/replays/[case].txt`. | ||
|
||
To generate new benchmark replay files, you can use | ||
`go test -json -fullpath -tags=reference -bench . ./test/reference/bench &> test/replays/benchmark.txt`. | ||
|
||
Once files are exported, make sure you replace all paths to use `/home/test` as | ||
the home directory, and `/home/test/bolt` as the working directory. | ||
|
||
You can run tests with `./bin/test`. | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at | ||
https://github.com/fnando/bolt. This project is intended to be a safe, welcoming | ||
space for collaboration, and contributors are expected to adhere to the | ||
[Contributor Covenant](http://contributor-covenant.org) code of conduct. | ||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the | ||
[MIT License](https://opensource.org/licenses/MIT). |
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
build() { | ||
os=$1 | ||
arch=$2 | ||
commit=$(git rev-parse --short HEAD 2>/dev/null || echo -n '0000000') | ||
|
||
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build \ | ||
-o build/bolt-$os-$arch \ | ||
-ldflags "-X github.com/fnando/bolt/common.Arch=$os-$arch -X github.com/fnando/bolt/common.Commit=$commit" \ | ||
cmd/bolt.go | ||
} | ||
|
||
rm -rf build | ||
mkdir -p build | ||
|
||
build linux amd64 | ||
build linux arm64 | ||
build darwin arm64 | ||
build darwin amd64 | ||
build windows 386 | ||
build windows amd64 | ||
|
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,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
mkdir -p coverage | ||
rm -rf coverage/*.* | ||
go test -coverprofile=coverage/coverage.out -cover -v ./... $@ | ||
go tool cover -html=coverage/coverage.out -o=coverage/index.html |
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,21 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/fnando/bolt/common" | ||
bolt "github.com/fnando/bolt/internal" | ||
) | ||
|
||
func main() { | ||
workingDir, _ := os.Getwd() | ||
homeDir, _ := os.UserHomeDir() | ||
|
||
exitcode := bolt.Run( | ||
workingDir, | ||
homeDir, | ||
common.Output{Stdout: os.Stdout, Stderr: os.Stderr}, | ||
) | ||
|
||
os.Exit(exitcode) | ||
} |
Oops, something went wrong.