Skip to content

Commit f8a14ab

Browse files
authored
ci: update GitHub Actions (#296)
1 parent 5e97220 commit f8a14ab

File tree

6 files changed

+72
-37
lines changed

6 files changed

+72
-37
lines changed

.github/workflows/go.yml

+27-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
name: Go
22
on:
33
push:
4-
branches: [master]
4+
branches: [ main ]
5+
paths:
6+
- '**.go'
7+
- 'go.mod'
8+
- '.golangci.yml'
9+
- '.github/workflows/go.yml'
510
pull_request:
11+
paths:
12+
- '**.go'
13+
- 'go.mod'
14+
- '.golangci.yml'
15+
- '.github/workflows/go.yml'
616
env:
717
GOPROXY: "https://proxy.golang.org"
818

@@ -11,39 +21,39 @@ jobs:
1121
name: Lint
1222
runs-on: ubuntu-latest
1323
steps:
14-
- uses: actions/checkout@v2
15-
- name: Init Go modules
16-
run: go mod init gopkg.in/ini.v1
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
- name: Init Go Modules
27+
run: |
28+
go mod init gopkg.in/ini.v1
29+
go mod tidy
1730
- name: Run golangci-lint
18-
uses: actions-contrib/golangci-lint@v1
31+
uses: golangci/golangci-lint-action@v2
32+
with:
33+
version: latest
34+
args: --timeout=30m
1935

2036
test:
2137
name: Test
2238
strategy:
2339
matrix:
24-
go-version: [1.13.x, 1.14.x, 1.15.x]
25-
platform: [ubuntu-latest, macos-latest, windows-latest]
40+
go-version: [ 1.15.x, 1.16.x, 1.17.x ]
41+
platform: [ ubuntu-latest, macos-latest, windows-latest ]
2642
runs-on: ${{ matrix.platform }}
2743
steps:
2844
- name: Install Go
29-
uses: actions/setup-go@v1
45+
uses: actions/setup-go@v2
3046
with:
3147
go-version: ${{ matrix.go-version }}
3248
- name: Checkout code
3349
uses: actions/checkout@v2
34-
- name: Run unit tests
50+
- name: Run tests with coverage
3551
run: |
3652
go mod init gopkg.in/ini.v1
53+
go mod tidy
3754
go test -v -race -coverprofile=coverage -covermode=atomic ./...
3855
- name: Upload coverage report to Codecov
39-
uses: codecov/codecov-action@v1.0.6
56+
uses: codecov/codecov-action@v1.5.0
4057
with:
4158
file: ./coverage
4259
flags: unittests
43-
- name: Cache downloaded modules
44-
uses: actions/cache@v1
45-
with:
46-
path: ~/go/pkg/mod
47-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
48-
restore-keys: |
49-
${{ runner.os }}-go-

.github/workflows/lsif.yml

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
name: LSIF
2-
on: [push]
2+
on:
3+
push:
4+
paths:
5+
- '**.go'
6+
- 'go.mod'
7+
- '.github/workflows/lsif.yml'
8+
env:
9+
GOPROXY: "https://proxy.golang.org"
10+
311
jobs:
4-
build:
12+
lsif-go:
13+
if: github.repository == 'go-ini/ini'
514
runs-on: ubuntu-latest
615
steps:
7-
- uses: actions/checkout@v1
16+
- uses: actions/checkout@v2
817
- name: Generate LSIF data
918
uses: sourcegraph/lsif-go-action@master
19+
- name: Upload LSIF data to sourcegraph.com
20+
continue-on-error: true
21+
uses: docker://sourcegraph/src-cli:latest
1022
with:
11-
verbose: 'true'
12-
- name: Upload LSIF data
13-
uses: sourcegraph/lsif-upload-action@master
23+
args: lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}
24+
- name: Upload LSIF data to sourcegraph.unknwon.cn
1425
continue-on-error: true
26+
uses: docker://sourcegraph/src-cli:latest
1527
with:
16-
endpoint: https://sourcegraph.com
17-
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
args: -endpoint=https://sourcegraph.unknwon.cn lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}

.golangci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
linters-settings:
2+
nakedret:
3+
max-func-lines: 0 # Disallow any unnamed return statement
4+
5+
linters:
6+
enable:
7+
- deadcode
8+
- errcheck
9+
- gosimple
10+
- govet
11+
- ineffassign
12+
- staticcheck
13+
- structcheck
14+
- typecheck
15+
- unused
16+
- varcheck
17+
- nakedret
18+
- gofmt
19+
- rowserrcheck
20+
- unconvert
21+
- goimports

codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ coverage:
66
threshold: 1%
77

88
comment:
9-
layout: 'diff, files'
9+
layout: 'diff'

key.go

-3
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,8 @@ func (k *Key) parseUint64s(strs []string, addInvalid, returnOnInvalid bool) ([]u
781781
return vals, err
782782
}
783783

784-
785784
type Parser func(str string) (interface{}, error)
786785

787-
788786
// parseTimesFormat transforms strings to times in given format.
789787
func (k *Key) parseTimesFormat(format string, strs []string, addInvalid, returnOnInvalid bool) ([]time.Time, error) {
790788
vals := make([]time.Time, 0, len(strs))
@@ -801,7 +799,6 @@ func (k *Key) parseTimesFormat(format string, strs []string, addInvalid, returnO
801799
return vals, err
802800
}
803801

804-
805802
// doParse transforms strings to different types
806803
func (k *Key) doParse(strs []string, addInvalid, returnOnInvalid bool, parser Parser) ([]interface{}, error) {
807804
vals := make([]interface{}, 0, len(strs))

parser.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func readKeyName(delimiters string, in []byte) (string, int, error) {
131131
// Check if key name surrounded by quotes.
132132
var keyQuote string
133133
if line[0] == '"' {
134-
if len(line) > 6 && string(line[0:3]) == `"""` {
134+
if len(line) > 6 && line[0:3] == `"""` {
135135
keyQuote = `"""`
136136
} else {
137137
keyQuote = `"`
@@ -232,7 +232,7 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
232232
}
233233

234234
var valQuote string
235-
if len(line) > 3 && string(line[0:3]) == `"""` {
235+
if len(line) > 3 && line[0:3] == `"""` {
236236
valQuote = `"""`
237237
} else if line[0] == '`' {
238238
valQuote = "`"
@@ -289,12 +289,8 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
289289
hasSurroundedQuote(line, '"')) && !p.options.PreserveSurroundedQuote {
290290
line = line[1 : len(line)-1]
291291
} else if len(valQuote) == 0 && p.options.UnescapeValueCommentSymbols {
292-
if strings.Contains(line, `\;`) {
293-
line = strings.Replace(line, `\;`, ";", -1)
294-
}
295-
if strings.Contains(line, `\#`) {
296-
line = strings.Replace(line, `\#`, "#", -1)
297-
}
292+
line = strings.ReplaceAll(line, `\;`, ";")
293+
line = strings.ReplaceAll(line, `\#`, "#")
298294
} else if p.options.AllowPythonMultilineValues && lastChar == '\n' {
299295
return p.readPythonMultilines(line, bufferSize)
300296
}

0 commit comments

Comments
 (0)