-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github workflow, meeting the awesome-go quality guidelines
- Loading branch information
Showing
25 changed files
with
663 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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: Go | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Build | ||
run: go build -v ./cmd/... | ||
|
||
- name: Test | ||
run: go run ./script/run-test -v -cover -coverpkg github.com/xhd2015/xgo/runtime/... -coverprofile cover.out | ||
|
||
- name: Print coverage | ||
run: cd runtime && go tool cover --func ../cover-runtime.out | ||
|
||
- name: Build Release | ||
run: go run ./script/build-release | ||
|
||
# - name: Check Version | ||
# run: ~/.xgo/bin/xgo revision | ||
|
||
# - name: Check Go Version | ||
# run: ~/.xgo/bin/xgo exec go version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,8 @@ | |
|
||
# generated traces | ||
/runtime/test/**/*.json | ||
/test/**/*.json | ||
/test/**/*.json | ||
|
||
# coverage | ||
/covers | ||
cover*.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ import ( | |
"net/http" | ||
"os" | ||
"os/exec" | ||
"runtime/debug" | ||
"runtime" | ||
"runtime/debug" | ||
"strings" | ||
"time" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
|
||
.trace-list-root { | ||
height: 100%; | ||
overflow-y: scroll; | ||
border: 1px solid grey; | ||
list-style: none; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,102 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"runtime" | ||
"strings" | ||
"time" | ||
|
||
"github.com/xhd2015/xgo/support/osinfo" | ||
) | ||
|
||
var logDebugFile *os.File | ||
|
||
func setupDebugLog(logDebugOption *string) (func(), error) { | ||
var logDebugFileName string | ||
if logDebugOption != nil { | ||
logDebugFileName = *logDebugOption | ||
if logDebugFileName == "" { | ||
logDebugFileName = "debug.log" | ||
} | ||
} | ||
if logDebugFileName == "" { | ||
return nil, nil | ||
} | ||
return initLog(logDebugFileName) | ||
} | ||
|
||
func initLog(logDebugFileName string) (func(), error) { | ||
if logDebugFileName == "stdout" { | ||
logDebugFile = os.Stdout | ||
return nil, nil | ||
} | ||
if logDebugFileName == "stderr" { | ||
logDebugFile = os.Stderr | ||
return nil, nil | ||
} | ||
var err error | ||
logDebugFile, err = os.Create(logDebugFileName) | ||
if err != nil { | ||
return nil, fmt.Errorf("create log: %s %w", logDebugFileName, err) | ||
} | ||
return func() { | ||
logDebugFile.Close() | ||
}, nil | ||
} | ||
|
||
func logDebug(format string, args ...interface{}) { | ||
if logDebugFile == nil { | ||
return | ||
} | ||
fmt.Fprint(logDebugFile, time.Now().Format("2006-01-02 15:04:05"), " ") | ||
fmt.Fprintf(logDebugFile, format, args...) | ||
if !strings.HasSuffix(format, "\n") { | ||
fmt.Fprintln(logDebugFile) | ||
} | ||
logDebugFile.Sync() | ||
} | ||
|
||
func logStartup() { | ||
logDebug("start: %v", os.Args) | ||
logDebug("runtime.GOOS=%s", runtime.GOOS) | ||
logDebug("runtime.GOARCH=%s", runtime.GOARCH) | ||
logDebug("runtime.Version()=%s", runtime.Version()) | ||
logDebug("runtime.GOROOT()=%s", runtime.GOROOT()) | ||
logDebug("os exe suffix: %s", osinfo.EXE_SUFFIX) | ||
logDebug("os force copy unsym: %v", osinfo.FORCE_COPY_UNSYM) | ||
} | ||
|
||
// if [[ $verbose = true ]];then | ||
// | ||
// tail -fn1 "$shdir/compile.log" & | ||
// trap "kill -9 $!" EXIT | ||
// fi | ||
func tailLog(logFile string) { | ||
file, err := os.OpenFile(logFile, os.O_RDONLY|os.O_CREATE, 0755) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "open compile log: %v\n", err) | ||
return | ||
} | ||
_, err = file.Seek(0, io.SeekEnd) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "seek tail compile log: %v\n", err) | ||
return | ||
} | ||
buf := make([]byte, 1024) | ||
for { | ||
n, err := file.Read(buf) | ||
if n > 0 { | ||
os.Stdout.Write(buf[:n]) | ||
} | ||
if err != nil { | ||
if err == io.EOF { | ||
time.Sleep(50 * time.Millisecond) | ||
continue | ||
} | ||
fmt.Fprintf(os.Stderr, "tail compile log: %v\n", err) | ||
return | ||
} | ||
} | ||
} | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"runtime" | ||
"strings" | ||
"time" | ||
|
||
"github.com/xhd2015/xgo/support/osinfo" | ||
) | ||
|
||
var logDebugFile *os.File | ||
|
||
func setupDebugLog(logDebugOption *string) (func(), error) { | ||
var logDebugFileName string | ||
if logDebugOption != nil { | ||
logDebugFileName = *logDebugOption | ||
if logDebugFileName == "" { | ||
logDebugFileName = "debug.log" | ||
} | ||
} | ||
if logDebugFileName == "" { | ||
return nil, nil | ||
} | ||
return initLog(logDebugFileName) | ||
} | ||
|
||
func initLog(logDebugFileName string) (func(), error) { | ||
if logDebugFileName == "stdout" { | ||
logDebugFile = os.Stdout | ||
return nil, nil | ||
} | ||
if logDebugFileName == "stderr" { | ||
logDebugFile = os.Stderr | ||
return nil, nil | ||
} | ||
var err error | ||
logDebugFile, err = os.Create(logDebugFileName) | ||
if err != nil { | ||
return nil, fmt.Errorf("create log: %s %w", logDebugFileName, err) | ||
} | ||
return func() { | ||
logDebugFile.Close() | ||
}, nil | ||
} | ||
|
||
func logDebug(format string, args ...interface{}) { | ||
if logDebugFile == nil { | ||
return | ||
} | ||
fmt.Fprint(logDebugFile, time.Now().Format("2006-01-02 15:04:05"), " ") | ||
fmt.Fprintf(logDebugFile, format, args...) | ||
if !strings.HasSuffix(format, "\n") { | ||
fmt.Fprintln(logDebugFile) | ||
} | ||
logDebugFile.Sync() | ||
} | ||
|
||
func logStartup() { | ||
logDebug("start: %v", os.Args) | ||
logDebug("runtime.GOOS=%s", runtime.GOOS) | ||
logDebug("runtime.GOARCH=%s", runtime.GOARCH) | ||
logDebug("runtime.Version()=%s", runtime.Version()) | ||
logDebug("runtime.GOROOT()=%s", runtime.GOROOT()) | ||
logDebug("os exe suffix: %s", osinfo.EXE_SUFFIX) | ||
logDebug("os force copy unsym: %v", osinfo.FORCE_COPY_UNSYM) | ||
} | ||
|
||
// if [[ $verbose = true ]];then | ||
// | ||
// tail -fn1 "$shdir/compile.log" & | ||
// trap "kill -9 $!" EXIT | ||
// fi | ||
func tailLog(logFile string) { | ||
file, err := os.OpenFile(logFile, os.O_RDONLY|os.O_CREATE, 0755) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "open compile log: %v\n", err) | ||
return | ||
} | ||
_, err = file.Seek(0, io.SeekEnd) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "seek tail compile log: %v\n", err) | ||
return | ||
} | ||
buf := make([]byte, 1024) | ||
for { | ||
n, err := file.Read(buf) | ||
if n > 0 { | ||
os.Stdout.Write(buf[:n]) | ||
} | ||
if err != nil { | ||
if err == io.EOF { | ||
time.Sleep(50 * time.Millisecond) | ||
continue | ||
} | ||
fmt.Fprintf(os.Stderr, "tail compile log: %v\n", err) | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.