Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actions for test and release #1

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Upload release binaries

on:
push:
tags:
- '*'

jobs:
build:
name: Build Binaries
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Build Binary
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ngtop-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }} .

- name: Release
uses: softprops/action-gh-release@v1
with:
files: "ngtop-*"
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Test project

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

- name: Vet
run: go vet -v ./...

- name: install staticcheck
run: go install "honnef.co/go/tools/cmd/staticcheck@latest"

- name: staticcheck
run: staticcheck ./...
4 changes: 2 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (dbs *dbSession) PrepareForUpdate(columns []string) (*time.Time, error) {
return nil, err
}

t, err := timeFromDBFormat(lastSeenTimeStr)
t, _ := timeFromDBFormat(lastSeenTimeStr)
lastSeemTime = &t
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (dbs *dbSession) QueryTop(spec *RequestCountSpec) ([]string, [][]string, er
}
strValues := make([]string, len(values))
for i, value := range values {
strValues[i] = fmt.Sprintf("%s", *value.(*sql.RawBytes))
strValues[i] = string(*value.(*sql.RawBytes))
}
results = append(results, strValues)
}
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ func resolveWhereConditions(clauses []string) (map[string][]string, error) {
}
if column, found := FIELD_NAMES[keyvalue[0]]; !found {
return nil, fmt.Errorf("unknown field name %s", keyvalue[0])
} else if _, found := conditions[column]; found {
conditions[column] = append(conditions[column], keyvalue[1])
} else {
conditions[column] = []string{keyvalue[1]}
conditions[column] = append(conditions[column], keyvalue[1])
}
}

Expand Down
Loading