diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..a54b2e4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,53 @@ +- With issues: + + - Use the search tool before opening a new issue. + + - Please provide source code and commit sha if you found a bug. + + - Review existing issues and provide feedback or react to them. + +## Description + + + +## How to reproduce + + + +``` +package main + +import ( + "github.com/sinhashubham95/go-actuator" +) + +func main() { + // actuator configuration +} +``` + +## Expectations + + + +``` +$ curl http://localhost:8201/actuator/[endpoint] +Hello world +``` + +## Actual result + + + +``` +$ curl -i http://localhost:8201/actuator/[endpoint] + +``` + +## Environment + +- go version: + +- go-actuator version (or commit ref): + +- operating system: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..3c1cf76 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +- With pull requests: + + - Open your pull request against `master` + + - Your pull request should have no more than two commits, if not you should squash them. + + - It should pass all tests in the available continuous integration GitHub Actions. + + - You should add/modify tests to cover your proposed code changes. + + - If your pull request contains a new feature, please document it on the [README](../README.md). diff --git a/.github/workflows/go.yml b/.github/workflows/release.yml similarity index 73% rename from .github/workflows/go.yml rename to .github/workflows/release.yml index fa33f8f..ead535f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,8 @@ -name: Go +name: Release on: push: branches: [master] - pull_request: - branches: [master] jobs: test: @@ -12,7 +10,7 @@ jobs: strategy: matrix: go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x] - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go @@ -25,12 +23,8 @@ jobs: - name: Get dependencies run: | go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - name: Run tests - run: go test -v -coverprofile=profile.cov ./... + run: go test ./... -coverprofile profile.cov - name: Send coverage uses: shogo82148/actions-goveralls@v1 with: @@ -63,9 +57,5 @@ jobs: - name: Get dependencies run: | go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - name: Build run: go build -v \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fb82e08 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test + +on: + pull_request: + branches: [master] + +jobs: + test: + name: Test + strategy: + matrix: + go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x] + platform: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Get dependencies + run: | + go get -v -t -d ./... + - name: Run tests + run: go test ./... -coverprofile profile.cov \ No newline at end of file diff --git a/.gitignore b/.gitignore index ac536fa..fdadda6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ coverage.out __debug_bin -profile.cov \ No newline at end of file +profile.cov +profile.out \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d722ab5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,21 @@ +## Contributing + +- With issues: + + - Use the search tool before opening a new issue. + + - Please provide source code and commit sha if you found a bug. + + - Review existing issues and provide feedback or react to them. + +- With pull requests: + + - Open your pull request against `master` + + - Your pull request should have no more than two commits, if not you should squash them. + + - It should pass all tests in the available continuous integration systems such as GitHub Actions. + + - You should add/modify tests to cover your proposed code changes. + + - If your pull request contains a new feature, please document it on the README. diff --git a/README.md b/README.md index 8445c26..7ff9808 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,20 @@ Go actuator uses [semantic versioning](http://semver.org/). API should not chang ## Installation +To install Gin package, you need to install Go and set your Go workspace first. + +1. The first need Go installed (version 1.13+ is required), then you can use the below Go command to install Go Actuator. + ```shell go get github.com/sinhashubham95/go-actuator ``` +2. Import it in your code: + +```go +import "github.com/sinhashubham95/go-actuator" +``` + ## How to Use The actuator library is compatible with the most famous web frameworks. This is highly configurable and each endpoint can be enabled or disabled during initialization. You can also specify a prefix path for each of these configured endpoints(with default value `/actuator`). diff --git a/controllers/fasthttp/commons_test.go b/controllers/fasthttp/commons_test.go index de62002..6b54a94 100644 --- a/controllers/fasthttp/commons_test.go +++ b/controllers/fasthttp/commons_test.go @@ -18,7 +18,7 @@ var encodeJSON = commons.EncodeJSON var getThreadDump = core.GetThreadDump var portMu sync.Mutex -var port = 1001 +var port = 1201 func getRandomPortNumber() int { portMu.Lock() diff --git a/core/httptrace_test.go b/core/httptrace_test.go index 94be7a1..b4c955d 100644 --- a/core/httptrace_test.go +++ b/core/httptrace_test.go @@ -10,21 +10,17 @@ import ( "github.com/valyala/fasthttp" "net/http" "net/http/httptest" - "sync" "testing" "github.com/sinhashubham95/go-actuator/core" ) -var portMu sync.Mutex -var port = 2001 - func TestGetHTTPTrace(t *testing.T) { assert.Empty(t, core.GetHTTPTrace()) } func TestWithFastHTTP(t *testing.T) { - port := getRandomPortNumber() + port := 2001 go func(endpoint int) { assert.NoError(t, fasthttp.ListenAndServe(fmt.Sprintf(":%d", port), @@ -106,13 +102,6 @@ func TestForMoreThanThresholdRequests(t *testing.T) { assert.Empty(t, trace.Response.Headers) } -func getRandomPortNumber() int { - portMu.Lock() - defer portMu.Unlock() - port += 10 - return port -} - func setupGINRouter() *gin.Engine { router := gin.Default() router.Use(core.GINTracer())