Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use octocov #31

Merged
merged 4 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
name: build

on: push
on:
push:
branches:
- main
pull_request:

jobs:
job-test:
name: Test
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 }}

- name: Install codecov
run: sudo pip install codecov

- 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
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run octocov
uses: k1LoW/octocov-action@v0
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.go-version
dist/
coverage.txt
/frgm
coverage.out
/frgm
20 changes: 20 additions & 0 deletions .octocov.yml
Original file line number Diff line number Diff line change
@@ -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}
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand All @@ -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
Expand All @@ -42,6 +42,7 @@ prerelease:
git tag ${VER}

release:
git push origin main --tag
goreleaser --rm-dist

.PHONY: default test
2 changes: 1 addition & 1 deletion format/alfred/alfred.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion format/frgm/frgm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion format/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion format/pet/pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down