Skip to content

Commit 0f8d403

Browse files
authored
Merge pull request #81 from willnorris/actions
migrate CI to GitHub Actions
2 parents 8746277 + 792e7a3 commit 0f8d403

File tree

7 files changed

+84
-19
lines changed

7 files changed

+84
-19
lines changed

.github/workflows/linter.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on: [push, pull_request]
2+
name: linter
3+
4+
jobs:
5+
lint:
6+
strategy:
7+
matrix:
8+
go-version: [1.x]
9+
platform: [ubuntu-latest]
10+
runs-on: ${{ matrix.platform }}
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: golangci-lint
16+
uses: golangci/golangci-lint-action@v2
17+
with:
18+
version: v1.41

.github/workflows/tests.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on: [push, pull_request]
2+
name: tests
3+
4+
jobs:
5+
test:
6+
strategy:
7+
matrix:
8+
go-version: [1.x, 1.15.x]
9+
platform: [ubuntu-latest]
10+
include:
11+
# only update test coverage stats with the most recent go version on linux
12+
- go-version: 1.x
13+
platform: ubuntu-latest
14+
update-coverage: true
15+
runs-on: ${{ matrix.platform }}
16+
17+
permissions:
18+
# styfle/cancel-workflow-action needs to be able to cancel existing action workflows
19+
actions: write
20+
21+
steps:
22+
- name: Cancel previous
23+
uses: styfle/cancel-workflow-action@89f242ee29e10c53a841bfe71cc0ce7b2f065abc #0.9.0
24+
with:
25+
access_token: ${{ github.token }}
26+
27+
- uses: actions/setup-go@v2
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
- uses: actions/checkout@v2
31+
32+
- name: Cache go modules
33+
uses: actions/cache@v2
34+
with:
35+
path: |
36+
~/.cache/go-build
37+
~/go/pkg/mod
38+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
39+
restore-keys: ${{ runner.os }}-go-
40+
41+
- name: Run go test
42+
run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
43+
44+
- name: Upload coverage to Codecov
45+
if: ${{ matrix.update-coverage }}
46+
uses: codecov/codecov-action@v2

.golangci.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
linters:
2+
enable:
3+
- dogsled
4+
- dupl
5+
- gofmt
6+
- goimports
7+
- misspell
8+
- nakedret
9+
- stylecheck
10+
- unconvert
11+
- unparam
12+
- whitespace

.travis.yml

-13
This file was deleted.

main.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ func main() {
178178
}()
179179

180180
for _, d := range flag.Args() {
181-
walk(ch, d)
181+
if err := walk(ch, d); err != nil {
182+
log.Fatal(err)
183+
}
182184
}
183185
close(ch)
184186
<-done
@@ -189,8 +191,8 @@ type file struct {
189191
mode os.FileMode
190192
}
191193

192-
func walk(ch chan<- *file, start string) {
193-
filepath.Walk(start, func(path string, fi os.FileInfo, err error) error {
194+
func walk(ch chan<- *file, start string) error {
195+
return filepath.Walk(start, func(path string, fi os.FileInfo, err error) error {
194196
if err != nil {
195197
log.Printf("%s error: %v", path, err)
196198
return nil

tmpl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func fetchTemplate(license string, templateFile string, spdx spdxFlag) (string,
6868
// unknown license, but SPDX headers requested
6969
t = tmplSPDX
7070
} else {
71-
return "", fmt.Errorf("unknown license: %q. Include the '-s' flag to request SPDX style headers using this license.", license)
71+
return "", fmt.Errorf("unknown license: %q. Include the '-s' flag to request SPDX style headers using this license", license)
7272
}
7373
} else if spdx == spdxOn {
7474
// append spdx headers to recognized license

tmpl_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestFetchTemplate(t *testing.T) {
4040
}{
4141
// custom template files
4242
{
43-
"non-existant template file",
43+
"non-existent template file",
4444
"",
4545
"/does/not/exist",
4646
spdxOff,
@@ -62,7 +62,7 @@ func TestFetchTemplate(t *testing.T) {
6262
"",
6363
spdxOff,
6464
"",
65-
errors.New(`unknown license: "unknown". Include the '-s' flag to request SPDX style headers using this license.`),
65+
errors.New(`unknown license: "unknown". Include the '-s' flag to request SPDX style headers using this license`),
6666
},
6767

6868
// pre-defined license templates, no SPDX

0 commit comments

Comments
 (0)