Skip to content

Commit

Permalink
Add CI flow
Browse files Browse the repository at this point in the history
Rename codegeneration.go -> main.go
  • Loading branch information
anatoly32322 committed Mar 19, 2024
1 parent 887609f commit f3318fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/check-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Build
run: |
go install ./internal/cmd/gtrace
go build ./internal/cmd/gstack
go install go.uber.org/mock/[email protected]
- name: Clean and re-generate *_gtrace.go files
Expand All @@ -40,5 +41,10 @@ jobs:
go generate ./trace
go generate ./...
- name: Re-generate stack.FunctionID calls
run: |
go run ./gstack .
rm ./gstack
- name: Check repository diff
run: bash ./.github/scripts/check-work-copy-equals-to-committed.sh "code-generation not equal with committed"
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Added query pool metrics
* Fixed logic of query session pool
* Changed initialization of internal driver clients to lazy
* Disabled the logic of background grpc-connection parking
* Disabled the logic of background grpc-connection parking
* Added codegarator for filling FunctionID with value from call stack

## v3.58.2
* Added `trace.Query.OnSessionBegin` event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func getCallExpressionsFromExpr(expr ast.Expr) (listOfCalls []*ast.CallExpr) {
case *ast.FuncLit:
listOfCalls = append(listOfCalls, getListOfCallExpressionsFromBlockStmt(expr.Body)...)
}

return listOfCalls
}

Expand All @@ -57,11 +58,10 @@ func getExprFromDeclStmt(statement *ast.DeclStmt) (listOfExpressions []ast.Expr)
}
for _, spec := range decl.Specs {
if spec, ok := spec.(*ast.ValueSpec); ok {
for _, expr := range spec.Values {
listOfExpressions = append(listOfExpressions, expr)
}
listOfExpressions = append(listOfExpressions, spec.Values...)
}
}

return listOfExpressions
}

Expand Down Expand Up @@ -93,6 +93,7 @@ func getCallExpressionsFromStmt(statement ast.Stmt) (listOfCallExpressions []*as
getListOfCallExpressionsFromBlockStmt(body)...,
)
}

return listOfCallExpressions
}

Expand All @@ -113,6 +114,7 @@ func getListOfCallExpressionsFromBlockStmt(block *ast.BlockStmt) (listOfCallExpr
listOfCallExpressions = append(listOfCallExpressions, getCallExpressionsFromStmt(statement)...)
}
}

return listOfCallExpressions
}

Expand Down Expand Up @@ -145,8 +147,10 @@ func format(src []byte, fset *token.FileSet, file ast.File) ([]byte, error) {
if err != nil {
return nil, err
}

return fixed, nil
}

return src, nil
}

Expand All @@ -157,6 +161,7 @@ func main() {

if len(args) != 1 {
flag.Usage()

return
}
_, err := os.Stat(args[0])
Expand Down Expand Up @@ -197,8 +202,10 @@ func main() {
if err != nil {
return err
}

return nil
}

return nil
})
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/gstack/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func ReadFile(filename string, info fs.FileInfo) ([]byte, error) {
} else if n > size {
return nil, fmt.Errorf("error: size of %s changed during reading (from %d to >=%d bytes)", filename, size, len(src))
}

return src, nil
}

Expand All @@ -48,6 +49,7 @@ func FixSource(src []byte, listOfArgs []FunctionIDArg) ([]byte, error) {
previousArgEnd = args.ArgEnd
}
fixed = append(fixed, src[previousArgEnd:]...)

return fixed, nil
}

Expand All @@ -63,5 +65,6 @@ func WriteFile(filename string, formatted []byte, perm fs.FileMode) error {
if err != nil {
return err
}

return nil
}

0 comments on commit f3318fb

Please sign in to comment.