From 777810dc361bb802e97b5e7dfe5c02a63dbcd4dc Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sat, 12 Feb 2022 11:11:21 +0900 Subject: [PATCH 1/4] Use octocov --- .github/workflows/ci.yml | 3 +++ .gitignore | 4 ++-- .octocov.yml | 20 ++++++++++++++++++++ Makefile | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .octocov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1752a10..80f62c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,3 +30,6 @@ jobs: run: codecov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - name: Run octocov + uses: k1LoW/octocov-action@v0 diff --git a/.gitignore b/.gitignore index ccd8a2d..e822a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .go-version dist/ -coverage.txt -/frgm \ No newline at end of file +coverage.out +/frgm diff --git a/.octocov.yml b/.octocov.yml new file mode 100644 index 0000000..998edeb --- /dev/null +++ b/.octocov.yml @@ -0,0 +1,20 @@ +# generated by octocov init +coverage: + if: true +codeToTestRatio: + code: + - '**/*.go' + - '!**/*_test.go' + test: + - '**/*_test.go' +testExecutionTime: + if: true +diff: + datastores: + - artifact://${GITHUB_REPOSITORY} +comment: + if: is_pull_request +report: + if: is_default_branch + datastores: + - artifact://${GITHUB_REPOSITORY} diff --git a/Makefile b/Makefile index 7bf2050..1c648b3 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ default: test ci: depsdev test sec test: - go test ./... -coverprofile=coverage.txt -covermode=count + go test ./... -coverprofile=coverage.out -covermode=count sec: gosec ./... From 606fcf9d32babfa46175a96a42239f3181b77bcc Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sat, 12 Feb 2022 11:14:36 +0900 Subject: [PATCH 2/4] Fix CI --- .github/workflows/ci.yml | 16 +++++++++------- Makefile | 11 ++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80f62c3..140e3fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: build -on: push +on: + push: + branches: + - main + pull_request: jobs: job-test: @@ -8,10 +12,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: [1.14] + go_version: [1.17] steps: - name: Set up Go ${{ matrix.go_version }} - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: ${{ matrix.go_version }} @@ -21,10 +25,8 @@ jobs: - name: Check out source code uses: actions/checkout@v2 - - name: Test - run: env PATH=`go env GOPATH`/bin:$PATH make ci - env: - GOPROXY: "https://proxy.golang.org" + - name: Run test + run: make ci - name: Run codecov run: codecov diff --git a/Makefile b/Makefile index 1c648b3..9954236 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ build: packr2 clean depsdev: - go get github.com/gobuffalo/packr/v2/packr2 - go get github.com/Songmu/ghch/cmd/ghch - go get github.com/Songmu/gocredits/cmd/gocredits - go get github.com/securego/gosec/cmd/gosec + go install github.com/Songmu/ghch/cmd/ghch@v0.10.2 + go install github.com/Songmu/gocredits/cmd/gocredits@v0.2.0 + go install github.com/securego/gosec/v2/cmd/gosec@v2.8.1 + go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 prerelease: - git pull origin --tag + git push origin main --tag ghch -w -N ${VER} gocredits -skip-missing . > CREDITS cat _EXTRA_CREDITS >> CREDITS @@ -42,6 +42,7 @@ prerelease: git tag ${VER} release: + git push origin main --tag goreleaser --rm-dist .PHONY: default test From fd74238f67ecb969fa203ab0a8b0f3d9f0850383 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sat, 12 Feb 2022 11:18:47 +0900 Subject: [PATCH 3/4] Fix gosec warn --- format/alfred/alfred.go | 2 +- format/frgm/frgm.go | 2 +- format/md/md.go | 2 +- format/pet/pet.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/format/alfred/alfred.go b/format/alfred/alfred.go index 7550495..32e94e9 100644 --- a/format/alfred/alfred.go +++ b/format/alfred/alfred.go @@ -142,7 +142,7 @@ func (a *Alfred) Export(snippets snippet.Snippets, dest string) error { if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { return err } - file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + file, err := os.OpenFile(filepath.Clean(path), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } diff --git a/format/frgm/frgm.go b/format/frgm/frgm.go index 1f97cce..98d3ae8 100644 --- a/format/frgm/frgm.go +++ b/format/frgm/frgm.go @@ -246,7 +246,7 @@ L: // export for _, set := range sets { path := set.LoadPath - file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + file, err := os.OpenFile(filepath.Clean(path), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } diff --git a/format/md/md.go b/format/md/md.go index 486bbc4..a711a43 100644 --- a/format/md/md.go +++ b/format/md/md.go @@ -54,7 +54,7 @@ func (m *Md) Export(snippets snippet.Snippets, dest string) error { } path := dest - file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + file, err := os.OpenFile(filepath.Clean(path), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } diff --git a/format/pet/pet.go b/format/pet/pet.go index 2cb5486..d895be8 100644 --- a/format/pet/pet.go +++ b/format/pet/pet.go @@ -109,7 +109,7 @@ func (p *Pet) Export(snippets snippet.Snippets, dest string) error { Tag: s.Labels, }) } - file, err := os.OpenFile(dest, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + file, err := os.OpenFile(filepath.Clean(dest), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } From 7e93d80a88ea9fed38250a2dfc703920a5cea41b Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sat, 12 Feb 2022 11:49:52 +0900 Subject: [PATCH 4/4] Thank you Codecov --- .github/workflows/ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 140e3fa..a9109a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,19 +19,11 @@ jobs: with: go-version: ${{ matrix.go_version }} - - name: Install codecov - run: sudo pip install codecov - - name: Check out source code uses: actions/checkout@v2 - name: Run test run: make ci - - name: Run codecov - run: codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - name: Run octocov uses: k1LoW/octocov-action@v0