Skip to content

Commit

Permalink
Merge pull request #52 from JenswBE/jw/use-common-linting-config
Browse files Browse the repository at this point in the history
Use common linting config
  • Loading branch information
JenswBE committed Feb 2, 2023
2 parents 6f4bd3d + a626496 commit dcd7f41
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ jobs:
check-latest: true
go-version: ${{ env.GO_VERSION }}

- name: Pull common linter configs
run: wget -O .golangci.yml https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest

- name: Run exhaustive
run: |
go install github.com/nishanths/exhaustive/...@latest
exhaustive ./...
- name: Start E2E services
working-directory: e2e
run: |
Expand Down
21 changes: 0 additions & 21 deletions .golangci.yml

This file was deleted.

41 changes: 22 additions & 19 deletions internal/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,30 @@ func (m *Manager) Run(ctx context.Context, c *config.Config) map[string]report.R
}

func pingHealthCheckURL(ctx context.Context, u *url.URL) {
if u != nil {
// Create request
logger := log.With().Str("health_check_url", u.String()).Logger()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
logger.Error().Err(err).Msg("Failed to create request for health check URL")
return
}
// Skip if URL is nil
if u == nil {
return
}

// Call health check
resp, err := http.DefaultClient.Do(req)
if err != nil {
logger.Error().Err(err).Msg("Failed to send GET request to health check URL")
return
}
// Create request
logger := log.With().Str("health_check_url", u.String()).Logger()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
logger.Error().Err(err).Msg("Failed to create request for health check URL")
return
}

// Close body
if resp != nil {
if err = resp.Body.Close(); err != nil {
log.Error().Err(err).Msg("Failed to close response body after calling health check URL")
}
// Call health check
resp, err := http.DefaultClient.Do(req)
if err != nil {
logger.Error().Err(err).Msg("Failed to send GET request to health check URL")
return
}

// Close body
if resp != nil {
if err = resp.Body.Close(); err != nil {
log.Error().Err(err).Msg("Failed to close response body after calling health check URL")
}
}
}
3 changes: 3 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This script is intended to be sourced like "source lint.sh" or ". lint.sh".
# Config is available at https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml
golangci-lint run -c ../setup/programming_configs/golang/.golangci.yml

0 comments on commit dcd7f41

Please sign in to comment.