Skip to content

Commit

Permalink
chore: add ci for go build and lint (#3)
Browse files Browse the repository at this point in the history
* chore: add ci for go build and lint

* chore: lint
  • Loading branch information
WenyXu authored Nov 25, 2024
1 parent 08e5e5b commit 8b4bae1
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 9 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Go Build and Lint

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.21'
cache: true

- name: Install dependencies
run: go mod download

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

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

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

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

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --timeout=5m
45 changes: 36 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,42 @@ func writeTable(tableCfg TableConfig, cfg config, client *greptime.Client, wg *s
}

// Define table schema
tbl.AddFieldColumn("ip", types.STRING)
tbl.AddFieldColumn("http_method", types.STRING)
tbl.AddFieldColumn("path", types.STRING)
tbl.AddFieldColumn("http_version", types.STRING)
tbl.AddFieldColumn("status_code", types.INT32)
tbl.AddFieldColumn("body_bytes_sent", types.INT32)
tbl.AddFieldColumn("referrer", types.STRING)
tbl.AddFieldColumn("user_agent", types.STRING)
tbl.AddTimestampColumn("time_local", types.TIMESTAMP_MILLISECOND)
err = tbl.AddFieldColumn("ip", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("http_method", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("path", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("http_version", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("status_code", types.INT32)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("body_bytes_sent", types.INT32)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("referrer", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddFieldColumn("user_agent", types.STRING)
if err != nil {
log.Panic(err)
}
err = tbl.AddTimestampColumn("time_local", types.TIMESTAMP_MILLISECOND)
if err != nil {
log.Panic(err)
}

// Generate random data
rows := gofakeit.Number(cfg.MinRow, maxRow)
Expand Down

0 comments on commit 8b4bae1

Please sign in to comment.