diff --git a/.github/e2e-linux.yml b/.github/e2e-linux.yml index c7e19ab..f5a7298 100644 --- a/.github/e2e-linux.yml +++ b/.github/e2e-linux.yml @@ -21,7 +21,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.16.x + go-version: 1.22.x - name: Checkout code uses: actions/checkout@v2 - name: Go build @@ -33,5 +33,5 @@ jobs: ./goc build -o ./gocc . - name: run e2e test run: | - go get github.com/onsi/ginkgo/ginkgo + go install github.com/onsi/ginkgo/ginkgo make e2e \ No newline at end of file diff --git a/.github/e2e-wins.yml b/.github/e2e-wins.yml index 35002a0..4ef9f36 100644 --- a/.github/e2e-wins.yml +++ b/.github/e2e-wins.yml @@ -21,7 +21,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.16.x + go-version: 1.22.x - name: Checkout code uses: actions/checkout@v2 - name: Go build @@ -33,5 +33,5 @@ jobs: .\goc.exe build -o gocc . - name: run e2e test run: | - go get github.com/onsi/ginkgo/ginkgo + go install github.com/onsi/ginkgo/ginkgo ginkgo tests/e2e/... \ No newline at end of file diff --git a/.github/style_check.yml b/.github/style_check.yml index f04af15..d4a8454 100644 --- a/.github/style_check.yml +++ b/.github/style_check.yml @@ -15,7 +15,7 @@ jobs: name: vet and gofmt strategy: matrix: - go-version: [1.16.x] + go-version: [1.22.x] runs-on: ubuntu-latest steps: - name: Install Go diff --git a/.github/ut-check-win.yml b/.github/ut-check-win.yml index 57dd40b..6765d8b 100644 --- a/.github/ut-check-win.yml +++ b/.github/ut-check-win.yml @@ -15,7 +15,7 @@ jobs: name: go test on windows strategy: matrix: - go-version: [1.16.x] + go-version: [1.22.x] runs-on: windows-latest steps: - name: Install Go diff --git a/.github/ut-check.yml b/.github/ut-check.yml index 63376dc..6d36c04 100644 --- a/.github/ut-check.yml +++ b/.github/ut-check.yml @@ -15,7 +15,7 @@ jobs: name: go test on linux strategy: matrix: - go-version: [1.16.x] + go-version: [1.22.x] runs-on: ubuntu-latest steps: - name: Install Go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7927750..73a1439 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,19 +57,19 @@ jobs: GOARCH: amd64 GOOS: darwin -# release-windows-amd64: -# name: release windows/amd64 -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@master -# - name: Install Go -# uses: actions/setup-go@v2 -# with: -# go-version: 1.19.x -# - name: compile and release -# run: | -# ./hack/release.sh -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# GOARCH: amd64 -# GOOS: windows \ No newline at end of file + release-windows-amd64: + name: release windows/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.22.x + - name: compile and release + run: | + ./hack/release.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GOARCH: amd64 + GOOS: windows \ No newline at end of file diff --git a/cmd/build.go b/cmd/build.go index 9bd4c0b..a7329de 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -26,13 +26,15 @@ var buildCmd = &cobra.Command{ } var ( - gocmode string - gochost string + gocmode string + gochost string + gocextra string ) func init() { buildCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch") buildCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever") + buildCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build") rootCmd.AddCommand(buildCmd) } @@ -47,6 +49,7 @@ func buildAction(cmd *cobra.Command, args []string) { build.WithArgs(args), build.WithBuild(), build.WithDebug(globalDebug), + build.WithExtra(gocextra), ) b.Build() diff --git a/cmd/install.go b/cmd/install.go index 0db5a08..50749e7 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -28,6 +28,7 @@ var installCmd = &cobra.Command{ func init() { installCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch") installCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever") + installCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build") rootCmd.AddCommand(installCmd) } @@ -42,6 +43,7 @@ func installAction(cmd *cobra.Command, args []string) { build.WithArgs(args), build.WithInstall(), build.WithDebug(globalDebug), + build.WithExtra(gocextra), ) b.Install() diff --git a/pkg/build/agent.tpl b/pkg/build/agent.tpl index bf34ea8..fcf327b 100644 --- a/pkg/build/agent.tpl +++ b/pkg/build/agent.tpl @@ -45,9 +45,9 @@ var ( token string id string cond = sync.NewCond(&sync.Mutex{}) - register_extra = "" commitID string = "{{.CommitID}}" branch string = "{{.Branch}}" + register_extra = "{{.Extra}}" ) func init() { @@ -57,6 +57,11 @@ func init() { host = host_env } + // init extra information + if os.Getenv("GOC_REGISTER_EXTRA") != "" { + register_extra = os.Getenv("GOC_REGISTER_EXTRA") + } + var dialer = websocket.DefaultDialer go func() { diff --git a/pkg/build/build.go b/pkg/build/build.go index 3e184c8..c781ab9 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -31,6 +31,7 @@ type Build struct { Debug bool Host string Mode string // cover mode + Extra string GOPATH string GOBIN string diff --git a/pkg/build/config.go b/pkg/build/config.go index bb052a8..91344e2 100644 --- a/pkg/build/config.go +++ b/pkg/build/config.go @@ -14,6 +14,8 @@ package build import ( + "strings" + "github.com/spf13/pflag" ) @@ -60,3 +62,9 @@ func WithDebug(enable bool) gocOption { b.Debug = enable } } + +func WithExtra(extra string) gocOption { + return func(b *Build) { + b.Extra = strings.TrimSpace(extra) + } +} diff --git a/pkg/build/inject.go b/pkg/build/inject.go index 1dfacb3..0b07734 100644 --- a/pkg/build/inject.go +++ b/pkg/build/inject.go @@ -216,6 +216,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) { Mode string CommitID string Branch string + Extra string }{ Covers: covers, GlobalCoverVarImportPath: b.GlobalCoverVarImportPath, @@ -224,6 +225,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) { Mode: _coverMode, Branch: branch, CommitID: commitID, + Extra: b.Extra, } if err := coverMainTmpl.Execute(f2, tmplData); err != nil {