diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76e7a1f..3c9509d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,15 +1,46 @@ -name: CI / CD Pipeline +name: CI Pipeline on: push: branches: - - main - - pipeline + - '*' tags: - 'v*.*' + pull_request: + branches: + - '*' workflow_dispatch: jobs: + check-generated-and-lint-code: + name: Check Generated files and lint Code + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Run Make Generate + run: make generate + + - name: Check for Uncommitted Changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "::error::Files were modified after running 'make generate'. Please run 'make generate' locally and commit the changes." + git status + git diff + exit 1 + else + echo "Generated code is up to date!" + fi + + - name: Run Make Prepare + run: make prepare + test-and-resources: name: Test & Resource Management runs-on: ubuntu-latest @@ -28,12 +59,6 @@ jobs: with: go-version-file: 'go.mod' - - name: Make Scripts Executable - run: chmod +x ./scripts/*.sh - - - name: Add Binaries to PATH - run: echo "$PWD/bin" >> $GITHUB_PATH - - name: Load Key from GitHub Secrets run: | echo '${{ secrets.STACKIT_SERVICE_ACCOUNT_KEY }}' > $RUNNER_TEMP/service_account_key.json @@ -56,7 +81,7 @@ jobs: else echo "Profile 'pubsub-qa' not found, skipping deletion." fi - + echo "pubsub-qa should been removed. Creating..." stackit config profile import -c "@$RUNNER_TEMP/qa-env.json" --name pubsub-qa stackit config profile set pubsub-qa diff --git a/bin/golangci-lint b/bin/golangci-lint index cd4ca71..1ac4fda 100755 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1,3 +1,3 @@ #!/usr/bin/env bash -exec mise exec go:github.com/golangci/golangci-lint/v2/cmd/golangci-lint -- golangci-lint "$@" +exec mise exec golangci-lint -- golangci-lint "$@" diff --git a/go.mod b/go.mod index a31b30e..fc9b8e2 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ module github.com/stackitcloud/pubsub-sdk-go -go 1.25.0 +go 1.25.0 // Make sure this matches the version specified in the mise.toml require ( github.com/go-logr/logr v1.4.3 github.com/google/uuid v1.6.0 github.com/joho/godotenv v1.5.1 github.com/kelseyhightower/envconfig v1.4.0 - github.com/oapi-codegen/runtime v1.3.1 + github.com/oapi-codegen/runtime v1.4.0 github.com/onsi/ginkgo/v2 v2.28.1 github.com/onsi/gomega v1.39.1 github.com/stackitcloud/stackit-sdk-go/core v0.22.0 diff --git a/go.sum b/go.sum index ff2bd7e..152b017 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= -github.com/oapi-codegen/runtime v1.3.1 h1:RgDY6J4OGQLbRXhG/Xpt3vSVqYpHQS7hN4m85+5xB9g= -github.com/oapi-codegen/runtime v1.3.1/go.mod h1:kOdeacKy7t40Rclb1je37ZLFboFxh+YLy0zaPCMibPY= +github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4= +github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec= github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= @@ -57,8 +57,8 @@ github.com/stackitcloud/stackit-sdk-go/core v0.22.0 h1:6rViz7GnNwXSh51Lur5xuDzO8 github.com/stackitcloud/stackit-sdk-go/core v0.22.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -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= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= diff --git a/mise.toml b/mise.toml index 1800d13..280e661 100644 --- a/mise.toml +++ b/mise.toml @@ -1,11 +1,11 @@ [tools] -go = "1.26.2" +go = "1.25.0" # Make sure this matches the go.mod "go:gitlab.com/backbone/changelog/cmd/changelog" = "v1.1.0" ginkgo = "2.28.1" "go:github.com/axw/gocov/gocov" = "v1.1.0" "go:github.com/AlekSi/gocov-xml" = "v1.2.0" golangci-lint = "2.8.0" -oapi-codegen = "v2.6.0" +"go:github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen" = "v2.7.0" [settings] # The go backend is experimental diff --git a/pkg/pubsub/api/sdk.gen.go b/pkg/pubsub/api/sdk.gen.go index 07804c7..5f49317 100644 --- a/pkg/pubsub/api/sdk.gen.go +++ b/pkg/pubsub/api/sdk.gen.go @@ -1,6 +1,6 @@ // Package api provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.6.0 DO NOT EDIT. +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.0 DO NOT EDIT. package api import ( @@ -309,7 +309,7 @@ func NewPublishMessagesRequestWithBody(server string, contentType string, body i return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) if err != nil { return nil, err } @@ -338,7 +338,7 @@ func NewPurgeTopicRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), nil) + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) if err != nil { return nil, err } @@ -383,7 +383,7 @@ func NewAckMessagesRequestWithBody(server string, subscriptionId SubscriptionId, return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) if err != nil { return nil, err } @@ -430,7 +430,7 @@ func NewNackMessagesRequestWithBody(server string, subscriptionId SubscriptionId return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) if err != nil { return nil, err } @@ -466,7 +466,7 @@ func NewPullMessagesRequest(server string, subscriptionId SubscriptionId, params return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), nil) + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) if err != nil { return nil, err } @@ -576,6 +576,14 @@ func (r PublishMessagesResponse) StatusCode() int { return 0 } +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PublishMessagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type PurgeTopicResponse struct { Body []byte HTTPResponse *http.Response @@ -597,6 +605,14 @@ func (r PurgeTopicResponse) StatusCode() int { return 0 } +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PurgeTopicResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type AckMessagesResponse struct { Body []byte HTTPResponse *http.Response @@ -618,6 +634,14 @@ func (r AckMessagesResponse) StatusCode() int { return 0 } +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AckMessagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type NackMessagesResponse struct { Body []byte HTTPResponse *http.Response @@ -639,6 +663,14 @@ func (r NackMessagesResponse) StatusCode() int { return 0 } +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r NackMessagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type PullMessagesResponse struct { Body []byte HTTPResponse *http.Response @@ -661,6 +693,14 @@ func (r PullMessagesResponse) StatusCode() int { return 0 } +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PullMessagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + // PublishMessagesWithBodyWithResponse request with arbitrary body returning *PublishMessagesResponse func (c *ClientWithResponses) PublishMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PublishMessagesResponse, error) { rsp, err := c.PublishMessagesWithBody(ctx, contentType, body, reqEditors...) diff --git a/scripts/create-pubsub-resources.sh b/scripts/create-pubsub-resources.sh old mode 100644 new mode 100755 diff --git a/scripts/install_mise.sh b/scripts/install_mise.sh old mode 100644 new mode 100755