Skip to content

Commit 7b466bc

Browse files
authored
feat: register extra information during build (#390)
* feat: register extra information during build * update github action go version * update action
1 parent ba7372a commit 7b466bc

File tree

12 files changed

+43
-23
lines changed

12 files changed

+43
-23
lines changed

.github/workflows/e2e-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install Go
2222
uses: actions/setup-go@v2
2323
with:
24-
go-version: 1.16.x
24+
go-version: 1.22.x
2525
- name: Checkout code
2626
uses: actions/checkout@v2
2727
- name: Go build
@@ -33,5 +33,5 @@ jobs:
3333
./goc build -o ./gocc .
3434
- name: run e2e test
3535
run: |
36-
go get github.com/onsi/ginkgo/ginkgo
36+
go install github.com/onsi/ginkgo/ginkgo
3737
make e2e

.github/workflows/e2e-wins.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install Go
2222
uses: actions/setup-go@v2
2323
with:
24-
go-version: 1.16.x
24+
go-version: 1.22.x
2525
- name: Checkout code
2626
uses: actions/checkout@v2
2727
- name: Go build
@@ -33,5 +33,5 @@ jobs:
3333
.\goc.exe build -o gocc .
3434
- name: run e2e test
3535
run: |
36-
go get github.com/onsi/ginkgo/ginkgo
36+
go install github.com/onsi/ginkgo/ginkgo
3737
ginkgo tests/e2e/...

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Install Go
1212
uses: actions/setup-go@v2
1313
with:
14-
go-version: 1.16.x
14+
go-version: 1.22.x
1515
- name: compile and release
1616
run: |
1717
./hack/release.sh
@@ -28,7 +28,7 @@ jobs:
2828
- name: Install Go
2929
uses: actions/setup-go@v2
3030
with:
31-
go-version: 1.16.x
31+
go-version: 1.22.x
3232
- name: compile and release
3333
run: |
3434
./hack/release.sh
@@ -45,7 +45,7 @@ jobs:
4545
- name: Install Go
4646
uses: actions/setup-go@v2
4747
with:
48-
go-version: 1.16.x
48+
go-version: 1.22.x
4949
- name: compile and release
5050
run: |
5151
./hack/release.sh
@@ -62,7 +62,7 @@ jobs:
6262
- name: Install Go
6363
uses: actions/setup-go@v2
6464
with:
65-
go-version: 1.16.x
65+
go-version: 1.22.x
6666
- name: compile and release
6767
run: |
6868
./hack/release.sh

.github/workflows/style_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: vet and gofmt
1616
strategy:
1717
matrix:
18-
go-version: [1.16.x]
18+
go-version: [1.22.x]
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Install Go

.github/workflows/ut-check-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: go test on windows
1616
strategy:
1717
matrix:
18-
go-version: [1.16.x]
18+
go-version: [1.22.x]
1919
runs-on: windows-latest
2020
steps:
2121
- name: Install Go

.github/workflows/ut-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: go test on linux
1616
strategy:
1717
matrix:
18-
go-version: [1.16.x]
18+
go-version: [1.22.x]
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Install Go

cmd/build.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ var buildCmd = &cobra.Command{
2626
}
2727

2828
var (
29-
gocmode string
30-
gochost string
29+
gocmode string
30+
gochost string
31+
gocextra string
3132
)
3233

3334
func init() {
3435
buildCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
3536
buildCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
37+
buildCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build")
3638
rootCmd.AddCommand(buildCmd)
3739
}
3840

@@ -47,6 +49,7 @@ func buildAction(cmd *cobra.Command, args []string) {
4749
build.WithArgs(args),
4850
build.WithBuild(),
4951
build.WithDebug(globalDebug),
52+
build.WithExtra(gocextra),
5053
)
5154
b.Build()
5255

cmd/install.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var installCmd = &cobra.Command{
2828
func init() {
2929
installCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
3030
installCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
31+
installCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build")
3132
rootCmd.AddCommand(installCmd)
3233
}
3334

@@ -42,6 +43,7 @@ func installAction(cmd *cobra.Command, args []string) {
4243
build.WithArgs(args),
4344
build.WithInstall(),
4445
build.WithDebug(globalDebug),
46+
build.WithExtra(gocextra),
4547
)
4648
b.Install()
4749

pkg/build/agent.tpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var (
4545
token string
4646
id string
4747
cond = sync.NewCond(&sync.Mutex{})
48-
register_extra = os.Getenv("GOC_REGISTER_EXTRA")
48+
register_extra = "{{.Extra}}"
4949
)
5050

5151
func init() {
@@ -55,6 +55,11 @@ func init() {
5555
host = host_env
5656
}
5757

58+
// init extra information
59+
if os.Getenv("GOC_REGISTER_EXTRA") != "" {
60+
register_extra = os.Getenv("GOC_REGISTER_EXTRA")
61+
}
62+
5863
var dialer = websocket.DefaultDialer
5964

6065
go func() {

pkg/build/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Build struct {
3131
Debug bool
3232
Host string
3333
Mode string // cover mode
34+
Extra string
3435

3536
GOPATH string
3637
GOBIN string
@@ -53,7 +54,6 @@ type Build struct {
5354
}
5455

5556
// NewBuild creates a Build struct
56-
//
5757
func NewBuild(opts ...gocOption) *Build {
5858
b := &Build{}
5959

0 commit comments

Comments
 (0)