Skip to content

Commit

Permalink
Fix CI Checks (#153)
Browse files Browse the repository at this point in the history
* fix lint

* revert ci test
  • Loading branch information
y-bruin authored Nov 5, 2024
1 parent 2f712f4 commit 1f648d3
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 26 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 .
35 changes: 35 additions & 0 deletions .github/workflows/bump-version.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
PRERELEASE: true
RELEASE_BRANCHES: ${{ steps.extract_branch.outputs.branch_name }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@ docs/.vitepress/dist
docs/.vitepress/cache
node_modules/
glossary.yaml
.vscode
.vscode

# pixi dev env
.pixi
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 27 additions & 8 deletions pkg/bigquery/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
})
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func TestLoadFromFile(t *testing.T) {
Zendesk: []ZendeskConnection{
{
Name: "conn25",
ApiToken: "zendeskKey",
APIToken: "zendeskKey",
Email: "zendeskemail",
Subdomain: "zendeskUrl",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions pkg/zendesk/config.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 1f648d3

Please sign in to comment.