Skip to content

Commit

Permalink
test: fix for linting failures and using the proper PR branch (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino authored Aug 10, 2022
1 parent 3465396 commit 90bd0b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,13 @@ on:
branches: [ '*' ]
tags: [ '*' ]
pull_request:
branches: [ main ]
branches: [ '1.0.0-rc' ]
schedule:
# Run automatically at 8AM PST Monday-Friday
- cron: '0 15 * * 1-5'
workflow_dispatch:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
only-new-issues: true

test:
name: Build & Test
runs-on: ubuntu-latest
Expand All @@ -43,6 +29,12 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
only-new-issues: true

- name: Build
run: make install

Expand Down Expand Up @@ -73,7 +65,7 @@ jobs:
deploy:
name: Deploy
if: success() && github.ref_type == 'tag'
needs: [ lint, test ]
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout twilio-go
Expand Down Expand Up @@ -107,14 +99,14 @@ jobs:
notify-on-failure:
name: Slack notify on failure
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
needs: [ lint, test, deploy ]
needs: [ test, deploy ]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_ICON_EMOJI: ':github:'
SLACK_MESSAGE: ${{ format('Lint *{0}*, Tests *{1}*, Deploy *{2}*, {3}/{4}/actions/runs/{5}', needs.lint.result, needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
SLACK_TITLE: Action Failure - ${{ github.repository }}
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
Expand Down
6 changes: 3 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client_test

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestClient_UnicodeResponse(t *testing.T) {
c := NewClient("user", "pass")
resp, _ := c.SendRequest("GET", unicodeServer.URL, nil, nil) //nolint:bodyclose
assert.Equal(t, 200, resp.StatusCode)
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
assert.Equal(t, "{\"testing-unicode\":\"Ω≈ç√, 💩\"}\n", string(body))
}

Expand All @@ -272,7 +272,7 @@ func TestClient_SetAccountSid(t *testing.T) {
func TestClient_DefaultUserAgentHeaders(t *testing.T) {
headerServer := httptest.NewServer(http.HandlerFunc(
func(writer http.ResponseWriter, request *http.Request) {
assert.Regexp(t, regexp.MustCompile(`^twilio-go\/[0-9.]+(-rc\.[0-9]+)?\s\(\w+\s\w+\)\sgo\/[^\s]+$`), request.Header.Get("User-Agent"))
assert.Regexp(t, regexp.MustCompile(`^twilio-go/[0-9.]+(-rc\.[0-9]+)?\s\(\w+\s\w+\)\sgo/\S+$`), request.Header.Get("User-Agent"))
}))

resp, _ := testClient.SendRequest("GET", headerServer.URL, nil, nil)
Expand Down
4 changes: 2 additions & 2 deletions client/page_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/url"
"testing"
Expand Down Expand Up @@ -107,7 +107,7 @@ func getTestClient(t *testing.T) *MockBaseClient {
resp, _ := json.Marshal(response)

return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader(resp)),
Body: io.NopCloser(bytes.NewReader(resp)),
}, nil
},
)
Expand Down

0 comments on commit 90bd0b1

Please sign in to comment.