Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5e46be8

Browse files
committed
feat(githubaction): add -c for codecov
1 parent2e57947 commit5e46be8

File tree

9 files changed

+51
-18
lines changed

9 files changed

+51
-18
lines changed

‎.vscode/launch.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
"version":"0.2.0",
66
"configurations": [
77
{
8-
"name":"Launch Package",
8+
"name":"update",
99
"type":"go",
1010
"request":"launch",
1111
"mode":"auto",
1212
"program":"${workspaceFolder}/main.go",
1313
"env": {},
1414
"args": [
1515
"--folder",
16-
"test",
16+
"_example",
1717
"add",
1818
"ga",
19-
"-s"
19+
"-s",
20+
"-c"
2021
]
2122
}
2223
]

‎_example/.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
with:
2020
go-version:${{ matrix.go-version }}
2121
-name:Run unit tests
22-
run:go test -v ./...
22+
go test -v -race -cover -coverprofile coverage.txt -covermode=atomic ./...
23+
-name:update codecov
24+
run:|
25+
CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}" bash <(curl -s https://codecov.io/bash)
2326
-name:Parse Event
2427
run:|
2528
echo "tag=$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)" >> $GITHUB_ENV
@@ -37,8 +40,8 @@ jobs:
3740
-name:Build and pack
3841
run:|
3942
# build package
40-
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o exe_amd64
41-
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o exe_arm64
43+
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X github.com/xxx/ak-test/cmd.EnabledAutoUpdate=false" -o exe_amd64
44+
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X github.com/xxx/ak-test/cmd.EnabledAutoUpdate=false" -o exe_arm64
4245
lipo -create -output .workflow/exe exe_amd64 exe_arm64
4346
rm exe_amd64
4447
rm exe_arm64

‎_example/.github/workflows/release_auto_update.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name:Release
1+
name:Release_auto_update
22
on:
33
release:
44
types:
@@ -19,7 +19,10 @@ jobs:
1919
with:
2020
go-version:${{ matrix.go-version }}
2121
-name:Run unit tests
22-
run:go test -v ./...
22+
go test -v -race -cover -coverprofile coverage.txt -covermode=atomic ./...
23+
-name:update codecov
24+
run:|
25+
CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}" bash <(curl -s https://codecov.io/bash)
2326
-name:Parse Event
2427
run:|
2528
echo "tag=$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)" >> $GITHUB_ENV

‎_example/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ else
1010
go generate ./...
1111
endif
1212

13+
.PHONY: test
14+
test:## run tests
15+
gotest -v -race -cover -coverprofile coverage.txt -covermode=atomic ./..
16+
1317
.PHONY: build
1418
build: generate## build the binary
1519
ak alfred build -l"$(LDFLAGS)"

‎cmd/githubAction.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ var githubActionCmd = &cobra.Command{
1717
Aliases: []string{"ga"},
1818
Run:func(cmd*cobra.Command,args []string) {
1919
s,_:=cmd.Flags().GetBool("sign")
20-
iferr:=generator.NewGithubActionGenerator(generator.WithEnabled_Code_Sign_Notarize(s)).Generate();err!=nil {
20+
c,_:=cmd.Flags().GetBool("codecov")
21+
22+
iferr:=generator.NewGithubActionGenerator(
23+
generator.WithEnabled_Code_Sign_Notarize(s),
24+
generator.WithEnabled_Codecov(c),
25+
).Generate();err!=nil {
2126
logrus.Fatal(err)
2227
}
2328
},
@@ -26,4 +31,5 @@ var githubActionCmd = &cobra.Command{
2631
funcinit() {
2732
addCmd.AddCommand(githubActionCmd)
2833
githubActionCmd.PersistentFlags().BoolP("sign","s",false,"enable code sign and notarize")
34+
githubActionCmd.PersistentFlags().BoolP("codecov","c",false,"enable codecov")
2935
}

‎generator/githubactions.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
typeGithubActionGeneratorstruct {
1919
Enabled_Code_Sign_Notarizebool
20+
Enabled_Codecovbool
2021
}
2122

2223
funcWithEnabled_Code_Sign_Notarize(enabledbool)func(*GithubActionGenerator) {
@@ -25,6 +26,12 @@ func WithEnabled_Code_Sign_Notarize(enabled bool) func(*GithubActionGenerator) {
2526
}
2627
}
2728

29+
funcWithEnabled_Codecov(enabledbool)func(*GithubActionGenerator) {
30+
returnfunc(g*GithubActionGenerator) {
31+
g.Enabled_Codecov=enabled
32+
}
33+
}
34+
2835
func (gg*GithubActionGenerator)Generate()error {
2936
te:=template.NewEngine()
3037
defaultFs:=fs.Get()
@@ -40,6 +47,7 @@ func (gg *GithubActionGenerator) Generate() error {
4047
m,err:=te.Execute("release.yml",map[string]interface{}{
4148
"ReleaseName":"Release",
4249
"EnabledCodeSign":gg.Enabled_Code_Sign_Notarize,
50+
"EnabledCodecov":gg.Enabled_Codecov,
4351
"WorkflowName":strings.ReplaceAll(viper.GetString("workflow.name")," ",""),
4452
"Ldflags":fmt.Sprintf("-X %s/cmd.EnabledAutoUpdate=false",viper.GetString("go_mod_package")),
4553
"BundleID":viper.GetString("workflow.bundle_id"),
@@ -62,6 +70,7 @@ func (gg *GithubActionGenerator) Generate() error {
6270
m,err:=te.Execute("release.yml",map[string]interface{}{
6371
"ReleaseName":"Release_auto_update",
6472
"EnabledCodeSign":gg.Enabled_Code_Sign_Notarize,
73+
"EnabledCodecov":gg.Enabled_Codecov,
6574
"WorkflowName":fmt.Sprintf("%s_auto_update",strings.ReplaceAll(viper.GetString("workflow.name")," ","")),
6675
"Ldflags":fmt.Sprintf("-X %s/cmd.EnabledAutoUpdate=true",viper.GetString("go_mod_package")),
6776
"BundleID":viper.GetString("workflow.bundle_id"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp