diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..0e91e60 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Default owner +* @MolotovTv/backend \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..d70ab6b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ +## Description +> A clear and concise description of what changes you did. + +## Jira issue +> Link to the Jira issue. + +## Depends on +> Link to other pull requests. + +## Jira Story +> Description from Jira diff --git a/.github/workflows/ci_pr_checks.yml b/.github/workflows/ci_pr_checks.yml new file mode 100644 index 0000000..fa982bc --- /dev/null +++ b/.github/workflows/ci_pr_checks.yml @@ -0,0 +1,42 @@ +name: PR checks + +on: + pull_request: + branches: + - master + types: + - opened + - reopened + - synchronize + - ready_for_review + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + if: always() && !github.event.pull_request.draft + env: + GOPRIVATE: github.com/molotovtv + GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }} + + steps: + - name: ⭐️ Checkout + uses: actions/checkout@v4 + + - name: Setup Go 1.21 + uses: actions/setup-go@v5 + with: + go-version: 1.21 + + - run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ + + - name: Install dependencies + run: go get ./... + + - name: ✅ Tests + run: | + go test ./... diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5a16d97 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/molotovtv/go-slack + +go 1.21 + +require github.com/stretchr/testify v1.9.0 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..60ce688 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/http.go b/http.go index 21b70d0..ce5f72d 100644 --- a/http.go +++ b/http.go @@ -3,13 +3,13 @@ package slack import ( "bytes" "fmt" - "io/ioutil" + "io" "net" "net/http" "time" ) -// Send sends an http request with a timeout +// Send sends a http request with a timeout var Send = func(req *http.Request, httpClient *http.Client) (*http.Response, error) { return httpClient.Do(req) } @@ -53,7 +53,7 @@ func (s *Slack) SendWithMaxRetries(hostname string, pattern string, method strin // Get body if resp != nil { defer resp.Body.Close() - if _, err = ioutil.ReadAll(resp.Body); err != nil { + if _, err = io.ReadAll(resp.Body); err != nil { return } } @@ -70,14 +70,14 @@ func (s *Slack) SendWithMaxRetries(hostname string, pattern string, method strin } // Max retries limit reached - err = fmt.Errorf("Max retries %d reached for request to %s", s.RetryMax, req.URL) + err = fmt.Errorf("max retries %d reached for request to %s", s.RetryMax, req.URL) return } // ProcessResponse processes an HTTP response var ProcessResponse = func(req *http.Request, resp *http.Response) error { if resp.StatusCode < 200 || resp.StatusCode > 299 { - return fmt.Errorf("Invalid status code %v on %v", resp.StatusCode, req.URL) + return fmt.Errorf("invalid status code %v on %v", resp.StatusCode, req.URL) } return nil }