diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7277786e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build and run test + +on: + pull_request: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.19', '1.20', '1.21', '1.22' ] + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Install dependencies + run: go get ./... + - name: Run gofmt + run: | + if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then + echo "Some files are not correctly formatted. Run 'gofmt -l -w'." + exit 1 + fi + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60.3 + - name: Build + run: go build -v ./... + - name: Test with Go + run: go test -json ./... > TestResults-${{ matrix.go-version }}.json + - name: Upload Go test results + uses: actions/upload-artifact@v4 + with: + name: Go-results-${{ matrix.go-version }} + path: TestResults-${{ matrix.go-version }}.json diff --git a/.golangci.yml b/.golangci.yml index 2366c111..d725e6a9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,7 +2,7 @@ linters: enable: - bodyclose - durationcheck - - exportloopref + - copyloopvar - gomoddirectives - prealloc - reassign diff --git a/internal/compose/fetch.go b/internal/compose/fetch.go index a1190370..b9359671 100644 --- a/internal/compose/fetch.go +++ b/internal/compose/fetch.go @@ -6,7 +6,7 @@ package compose import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httputil" "strings" @@ -44,7 +44,7 @@ func Fetch[T any](ctx Context, url string) (*T, error) { return nil, fmt.Errorf("request failed: %s ", res.Status) } defer res.Body.Close() - buf, err := ioutil.ReadAll(res.Body) + buf, err := io.ReadAll(res.Body) if err != nil { return nil, err }