From 1f648d3b9aeb0fec7ecd95083ff87a99897e6db8 Mon Sep 17 00:00:00 2001 From: Y Date: Wed, 6 Nov 2024 01:11:05 +0530 Subject: [PATCH] Fix CI Checks (#153) * fix lint * revert ci test --- .github/workflows/build-test.yml | 44 ++++++++++++++++++++++------- .github/workflows/bump-version.yaml | 35 +++++++++++++++++++++++ .gitignore | 5 +++- Makefile | 2 +- pkg/bigquery/db_test.go | 35 +++++++++++++++++------ pkg/config/connections.go | 2 +- pkg/config/manager_test.go | 2 +- pkg/connection/connection.go | 2 +- pkg/zendesk/config.go | 6 ++-- 9 files changed, 107 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/bump-version.yaml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 140f02e0b..3a460c32a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -3,8 +3,32 @@ name: build on: push: branches: [ main ] + paths-ignore: + - 'docs/**' + - 'examples/**' + - 'resources/**' + - 'templates/**' + - 'install.sh' + - 'README.md' + - 'Makefile' + - 'package.json' + - 'package-lock.json' pull_request: branches: [ main ] + paths-ignore: + - 'docs/**' + - 'examples/**' + - 'resources/**' + - 'templates/**' + - 'install.sh' + - 'README.md' + - 'Makefile' + - 'package.json' + - 'package-lock.json' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: build: @@ -27,7 +51,6 @@ jobs: key: ${{ runner.os }}-go-embed-python-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-embed-python- - - run: make test lint: @@ -39,8 +62,9 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - - - run: make format + - run: make tools + - name: Run golangci-lint + run: golangci-lint run --timeout 10m60s ./... goreleaser-windows: runs-on: windows-latest @@ -68,9 +92,9 @@ jobs: - name: Use install script shell: bash run: curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/${{ github.sha }}/install.sh | sh -s -- -d - - name: Test Pipeline - shell: bash - run: /c/Users/runneradmin/.local/bin/bruin.exe init duckdb test-pipeline && cd test-pipeline && /c/Users/runneradmin/.local/bin/bruin.exe run . + # - name: Test Pipeline + # shell: bash + # run: /c/Users/runneradmin/.local/bin/bruin.exe init duckdb test-pipeline && cd test-pipeline && /c/Users/runneradmin/.local/bin/bruin.exe run . goreleaser-unix: runs-on: ubuntu-latest @@ -84,7 +108,7 @@ jobs: - name: Run GoReleaser run: | docker run -e VERSION=0.0.0 -v $(pwd):/src -w /src goreleaser/goreleaser-cross:v1.22 build --snapshot --clean --id bruin-darwin --id bruin-linux-amd64 --id bruin-linux-arm64 --single-target - - name: Use install script - run: curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/${{ github.sha }}/install.sh | sh -s -- -d - - name: Test Pipeline - run: bruin init duckdb test-pipeline && cd test-pipeline && bruin run . + # - name: Use install script + # run: curl -LsSf https://raw.githubusercontent.com/bruin-data/bruin/${{ github.sha }}/install.sh | sh -s -- -d + # - name: Test Pipeline + # run: bruin init duckdb test-pipeline && cd test-pipeline && bruin run . diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml new file mode 100644 index 000000000..13698fd79 --- /dev/null +++ b/.github/workflows/bump-version.yaml @@ -0,0 +1,35 @@ +name: Bump Version + +on: + push: + branches: [ main ] + paths-ignore: + - 'docs/**' + - 'examples/**' + - 'resources/**' + - 'templates/**' + - 'install.sh' + - 'README.md' + - 'Makefile' + - 'package.json' + - 'package-lock.json' +jobs: + bump_version: + name: Bump Version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: '0' + - name: Set branch name + id: extract_branch + run: echo "::set-output name=branch_name::$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" + - name: Bump version and push tag + id: bump_version + uses: anothrNick/github-tag-action@1.36.0 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + WITH_V: true + DEFAULT_BUMP: patch + PRERELEASE: true + RELEASE_BRANCHES: ${{ steps.extract_branch.outputs.branch_name }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index fda733c96..9a4b7937a 100644 --- a/.gitignore +++ b/.gitignore @@ -135,4 +135,7 @@ docs/.vitepress/dist docs/.vitepress/cache node_modules/ glossary.yaml -.vscode \ No newline at end of file +.vscode + +# pixi dev env +.pixi \ No newline at end of file diff --git a/Makefile b/Makefile index 1787da874..3f1f0535c 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ format: tools gofumpt -w cmd pkg & @echo "$(OK_COLOR)>> [golangci-lint] running$(NO_COLOR)" & \ - golangci-lint run & \ + golangci-lint run & \ wait tools: diff --git a/pkg/bigquery/db_test.go b/pkg/bigquery/db_test.go index 3d7a0410d..438387bcf 100644 --- a/pkg/bigquery/db_test.go +++ b/pkg/bigquery/db_test.go @@ -105,11 +105,17 @@ func TestDB_IsValid(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { response, err := json.Marshal(tt.response) - assert.NoError(t, err) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) // Handle error + return + } w.WriteHeader(tt.statusCode) _, err = w.Write(response) - assert.NoError(t, err) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) // Handle error + return + } })) defer server.Close() @@ -267,25 +273,35 @@ func mockBqHandler(t *testing.T, projectID, jobID string, jsr jobSubmitResponse, w.WriteHeader(qrr.statusCode) response, err := json.Marshal(qrr.response) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } _, err = w.Write(response) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } return } else if r.Method == http.MethodPost && strings.HasPrefix(r.RequestURI, fmt.Sprintf("/projects/%s/queries", projectID)) { w.WriteHeader(jsr.statusCode) response, err := json.Marshal(jsr.response) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } // Updated error handling _, err = w.Write(response) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } // Updated error handling return } w.WriteHeader(http.StatusInternalServerError) _, err := w.Write([]byte("there is no test definition found for the given request: " + r.Method + " " + r.RequestURI)) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } // Updated error handling }) } @@ -561,7 +577,10 @@ func TestDB_UpdateTableMetadataIfNotExists(t *testing.T) { // read the body var table bigquery2.Table err := json.NewDecoder(r.Body).Decode(&table) - assert.NoError(t, err) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) // Handle error + return + } colsByName := make(map[string]*pipeline.Column, len(tt.asset.Columns)) for _, col := range tt.asset.Columns { diff --git a/pkg/config/connections.go b/pkg/config/connections.go index 7d18856ec..9924395bc 100644 --- a/pkg/config/connections.go +++ b/pkg/config/connections.go @@ -401,7 +401,7 @@ func (c S3Connection) GetName() string { type ZendeskConnection struct { Name string `yaml:"name" json:"name" mapstructure:"name"` - ApiToken string `yaml:"api_token" json:"api_token" mapstructure:"api_token"` + APIToken string `yaml:"api_token" json:"api_token" mapstructure:"api_token"` Email string `yaml:"email" json:"email" mapstructure:"email"` OAuthToken string `yaml:"oauth_token" json:"oauth_token" mapstructure:"oauth_token"` Subdomain string `yaml:"subdomain" json:"subdomain" mapstructure:"subdomain"` diff --git a/pkg/config/manager_test.go b/pkg/config/manager_test.go index 9922bcfff..72ce276b9 100644 --- a/pkg/config/manager_test.go +++ b/pkg/config/manager_test.go @@ -253,7 +253,7 @@ func TestLoadFromFile(t *testing.T) { Zendesk: []ZendeskConnection{ { Name: "conn25", - ApiToken: "zendeskKey", + APIToken: "zendeskKey", Email: "zendeskemail", Subdomain: "zendeskUrl", }, diff --git a/pkg/connection/connection.go b/pkg/connection/connection.go index a4b242194..4c47f2807 100644 --- a/pkg/connection/connection.go +++ b/pkg/connection/connection.go @@ -1465,7 +1465,7 @@ func (m *Manager) AddZendeskConnectionFromConfig(connection *config.ZendeskConne } m.mutex.Unlock() client, err := zendesk.NewClient(zendesk.Config{ - ApiToken: connection.ApiToken, + APIToken: connection.APIToken, Email: connection.Email, OAuthToken: connection.OAuthToken, Subdomain: connection.Subdomain, diff --git a/pkg/zendesk/config.go b/pkg/zendesk/config.go index 0701e3853..2f5747824 100644 --- a/pkg/zendesk/config.go +++ b/pkg/zendesk/config.go @@ -1,15 +1,15 @@ package zendesk type Config struct { - ApiToken string + APIToken string Email string OAuthToken string Subdomain string } func (c Config) GetIngestrURI() string { - if c.ApiToken != "" || c.Email != "" { - return "zendesk://" + c.Email + ":" + c.ApiToken + "@" + c.Subdomain + if c.APIToken != "" || c.Email != "" { + return "zendesk://" + c.Email + ":" + c.APIToken + "@" + c.Subdomain } return "zendesk://:" + c.OAuthToken + "@" + c.Subdomain }