Skip to content

Commit

Permalink
Use GitHub Actions (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatseykanets authored Jan 19, 2021
1 parent 19e6116 commit 48da771
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 30 deletions.
12 changes: 0 additions & 12 deletions .circleci/config.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: build

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- go: 1.12
build-with: true
- go: 1.13
build-with: false
- go: 1.14
build-with: false
- go: 1.15
build-with: false
continue-on-error: ${{ matrix.build-with == false }}
name: Build with ${{ matrix.go }}
defaults:
run:
working-directory: src/github.com/${{ github.repository }}
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off

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

- name: Checkout code
uses: actions/checkout@v2
with:
path: src/github.com/${{ github.repository }}

- name: Install dep
run: curl -s -L -o dep https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 && chmod +x dep && sudo mv dep /usr/local/bin/

- run: dep ensure -v -vendor-only

- name: Vet
run: go vet ./...

- name: Test
run: go test -vet=off -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload code coverage report
if: matrix.build-with == true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://raw.githubusercontent.com/VividCortex/codecov-bash/master/codecov)
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
## Robustly
# robustly

Robustly runs code resiliently, recovering from occasional errors.
It also gives you the ability to probabilistically inject panics into
your application, configuring them at runtime at crash sites of your
choosing. We use it at [VividCortex](https://vividcortex.com/blog/2013/07/30/writing-resilient-programs-with-go-and-robustly-run/)
to ensure that unexpected problems don't disable our agent programs.

![Build Status](https://circleci.com/gh/VividCortex/robustly.png?circle-token=75e143a154914d6ecf50376b0d93b5401739c52e)
![build](https://github.com/VividCortex/robustly/workflows/build/badge.svg)

### Getting Started
## Getting Started

```
```sh
go get github.com/VividCortex/robustly
```

Now import the following in your code:

```go
import (
"github.com/VividCortex/robustly"
"github.com/VividCortex/robustly"
)

func main() {
go robustly.Run(func() { somefunc() })
go robustly.Run(func() { somefunc() })
}

func somefunc() {
for {
// do something here that may panic
}
for {
// do something here that may panic
}
}
```

### API Documentation
## API Documentation

View the GoDoc generated documentation [here](http://godoc.org/github.com/VividCortex/robustly).

Expand Down Expand Up @@ -79,21 +79,21 @@ To use the optional settings of Run, pass Run a pointer to a RunOptions struct.
```go
// RunOptions is a struct to hold the optional arguments to Run.
type RunOptions struct {
RateLimit float64 // the rate limit in crashes per second
Timeout time.Duration // the timeout (after which Run will stop trying)
PrintStack bool // whether to print the panic stacktrace or not
RetryDelay time.Duration // inject a delay before retrying the run
RateLimit float64 // the rate limit in crashes per second
Timeout time.Duration // the timeout (after which Run will stop trying)
PrintStack bool // whether to print the panic stacktrace or not
RetryDelay time.Duration // inject a delay before retrying the run
}
```

Default options are shown below:

```go
robustly.Run(func() { /* your code here */ }, &robustly.RunOptions{
RateLimit: 1.0,
Timeout: time.Second,
PrintStack: false,
RetryDelay: 0 * time.Nanosecond,
RateLimit: 1.0,
Timeout: time.Second,
PrintStack: false,
RetryDelay: 0 * time.Nanosecond,
})
```

Expand All @@ -116,7 +116,9 @@ The idea is to match the crash sites configured in the setup with those actually
present in your code. For example, if you have added a crash site in the code at
line 53 of client.go, and you'd like to crash there, as well as at line 18 of server.go:

```txt
client.go:53:.003,server.go:18:.02
```

That will cause a crash .003 of the time at client.go line 53, and .02 of the time
at server.go line 18.
Expand Down
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
status:
project:
default:
threshold: 15%
patch: off

0 comments on commit 48da771

Please sign in to comment.