ci: test newly added tag
We run test with the tag set (to make sure nothing is broken), and also the check-binary-size target (for informational purposes only). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
49e43beba3
commit
b8cb475418
6
.github/workflows/cli.yml
vendored
6
.github/workflows/cli.yml
vendored
@ -37,12 +37,18 @@ jobs:
|
|||||||
- name: vet
|
- name: vet
|
||||||
run: go run internal/build/build.go vet
|
run: go run internal/build/build.go vet
|
||||||
|
|
||||||
|
- name: test with tags
|
||||||
|
run: go run internal/build/build.go -tags urfave_cli_no_docs test
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: go run internal/build/build.go test
|
run: go run internal/build/build.go test
|
||||||
|
|
||||||
- name: check-binary-size
|
- name: check-binary-size
|
||||||
run: go run internal/build/build.go check-binary-size
|
run: go run internal/build/build.go check-binary-size
|
||||||
|
|
||||||
|
- name: check-binary-size with tags (informational only)
|
||||||
|
run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size || true
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
if: success() && matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest'
|
if: success() && matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest'
|
||||||
uses: codecov/codecov-action@v2
|
uses: codecov/codecov-action@v2
|
||||||
|
@ -46,6 +46,12 @@ func main() {
|
|||||||
Action: checkBinarySizeActionFunc,
|
Action: checkBinarySizeActionFunc,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "tags",
|
||||||
|
Usage: "set build tags",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
err := app.Run(os.Args)
|
err := app.Run(os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -68,6 +74,8 @@ func VetActionFunc(_ *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestActionFunc(c *cli.Context) error {
|
func TestActionFunc(c *cli.Context) error {
|
||||||
|
tags := c.String("tags")
|
||||||
|
|
||||||
for _, pkg := range packages {
|
for _, pkg := range packages {
|
||||||
var packageName string
|
var packageName string
|
||||||
|
|
||||||
@ -79,7 +87,7 @@ func TestActionFunc(c *cli.Context) error {
|
|||||||
|
|
||||||
coverProfile := fmt.Sprintf("--coverprofile=%s.coverprofile", pkg)
|
coverProfile := fmt.Sprintf("--coverprofile=%s.coverprofile", pkg)
|
||||||
|
|
||||||
err := runCmd("go", "test", "-v", coverProfile, packageName)
|
err := runCmd("go", "test", "-tags", tags, "-v", coverProfile, packageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -201,14 +209,16 @@ func checkBinarySizeActionFunc(c *cli.Context) (err error) {
|
|||||||
mbStringFormatter = "%.1fMB"
|
mbStringFormatter = "%.1fMB"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tags := c.String("tags")
|
||||||
|
|
||||||
// get cli example size
|
// get cli example size
|
||||||
cliSize, err := getSize(cliSourceFilePath, cliBuiltFilePath)
|
cliSize, err := getSize(cliSourceFilePath, cliBuiltFilePath, tags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// get hello world size
|
// get hello world size
|
||||||
helloSize, err := getSize(helloSourceFilePath, helloBuiltFilePath)
|
helloSize, err := getSize(helloSourceFilePath, helloBuiltFilePath, tags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -270,9 +280,9 @@ func checkBinarySizeActionFunc(c *cli.Context) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSize(sourcePath string, builtPath string) (size int64, err error) {
|
func getSize(sourcePath string, builtPath string, tags string) (size int64, err error) {
|
||||||
// build example binary
|
// build example binary
|
||||||
err = runCmd("go", "build", "-o", builtPath, "-ldflags", "-s -w", sourcePath)
|
err = runCmd("go", "build", "-tags", tags, "-o", builtPath, "-ldflags", "-s -w", sourcePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("issue getting size for example binary")
|
fmt.Println("issue getting size for example binary")
|
||||||
return 0, err
|
return 0, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user