Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/songmu/gotesplit
Splits the testing in Go into a subset and run it. It is useful for the CI environment.
https://github.com/songmu/gotesplit
ci go golang testing
Last synced: 4 days ago
JSON representation
Splits the testing in Go into a subset and run it. It is useful for the CI environment.
- Host: GitHub
- URL: https://github.com/songmu/gotesplit
- Owner: Songmu
- License: mit
- Created: 2020-10-13T13:56:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-22T17:56:49.000Z (4 months ago)
- Last Synced: 2025-01-10T05:12:44.601Z (11 days ago)
- Topics: ci, go, golang, testing
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 72
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
gotesplit
=======[![Test Status](https://github.com/Songmu/gotesplit/workflows/test/badge.svg?branch=main)][actions]
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]
[![PkgGoDev](https://pkg.go.dev/badge/github.com/Songmu/gotesplit)][PkgGoDev][actions]: https://github.com/Songmu/gotesplit/actions?workflow=test
[license]: https://github.com/Songmu/gotesplit/blob/main/LICENSE
[PkgGoDev]: https://pkg.go.dev/github.com/Songmu/gotesplitgotesplit splits the testng in Go into a subset and run it
## Usage
```console
% gotesplit [options] [pkgs...] [-- go-test-arguments...]
```### Options
```
-total uint
total number of test splits (CIRCLE_NODE_TOTAL is used if set) (default 1)
-index uint
zero-based index number of test splits (CIRCLE_NODE_INDEX is used if set) (default 0)
-junit-dir
directory to store test result as a JUnit format (optional)
```### Synopsis
```console
% gotesplit -total=10 -index=0 -- -v -short
go test -v -short -run ^(?:TestAA|TestBB)$
```## Description
The gotesplit splits the testng in Go into a subset and run it.
It is very useful when you want to run tests in parallel in a CI environment.
## Installation
```console
# Install the latest version. (Install it into ./bin/ by default).
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s# Specify installation directory ($(go env GOPATH)/bin/) and version.
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]# In alpine linux (as it does not come with curl by default)
% wget -O - -q https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s [vX.Y.Z]# go get
% go get github.com/Songmu/gotesplit/cmd/gotesplit# aqua https://aquaproj.github.io/
% aqua g -i Songmu/gotesplit
```## Example
### CircleCI
We don't need to specify the -total and -index flag on CircleCI because gotesplit reads the `CIRCLE_NODE_TOTAL` and `CIRCLE_NODE_INDEX` environment variables automatically.
```yaml
parallelism: 5
docker:
- image: circleci/golang:1.15.3
steps:
- checkout
- run:
command: |
curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit ./... -- -v
```### GitHub Actions
```yaml
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallelism: [3]
index: [0,1,2]
steps:
- uses: actions/setup-go@v4
- uses: actions/checkout@v3
- name: Run tests parallelly
run: |
curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit -total ${{ matrix.parallelism }} -index ${{ matrix.index }} ./... -- -v
```## Author
[Songmu](https://github.com/Songmu)