Skip to content

Commit

Permalink
ci: update GitHub Actions (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Sep 4, 2021
1 parent 5e97220 commit f8a14ab
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 37 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
name: Go
on:
push:
branches: [master]
branches: [ main ]
paths:
- '**.go'
- 'go.mod'
- '.golangci.yml'
- '.github/workflows/go.yml'
pull_request:
paths:
- '**.go'
- 'go.mod'
- '.golangci.yml'
- '.github/workflows/go.yml'
env:
GOPROXY: "https://proxy.golang.org"

Expand All @@ -11,39 +21,39 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Init Go modules
run: go mod init gopkg.in/ini.v1
- name: Checkout code
uses: actions/checkout@v2
- name: Init Go Modules
run: |
go mod init gopkg.in/ini.v1
go mod tidy
- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --timeout=30m

test:
name: Test
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
go-version: [ 1.15.x, 1.16.x, 1.17.x ]
platform: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Run unit tests
- name: Run tests with coverage
run: |
go mod init gopkg.in/ini.v1
go mod tidy
go test -v -race -coverprofile=coverage -covermode=atomic ./...
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1.0.6
uses: codecov/codecov-action@v1.5.0
with:
file: ./coverage
flags: unittests
- name: Cache downloaded modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
27 changes: 19 additions & 8 deletions .github/workflows/lsif.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
name: LSIF
on: [push]
on:
push:
paths:
- '**.go'
- 'go.mod'
- '.github/workflows/lsif.yml'
env:
GOPROXY: "https://proxy.golang.org"

jobs:
build:
lsif-go:
if: github.repository == 'go-ini/ini'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Generate LSIF data
uses: sourcegraph/lsif-go-action@master
- name: Upload LSIF data to sourcegraph.com
continue-on-error: true
uses: docker://sourcegraph/src-cli:latest
with:
verbose: 'true'
- name: Upload LSIF data
uses: sourcegraph/lsif-upload-action@master
args: lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}
- name: Upload LSIF data to sourcegraph.unknwon.cn
continue-on-error: true
uses: docker://sourcegraph/src-cli:latest
with:
endpoint: https://sourcegraph.com
github_token: ${{ secrets.GITHUB_TOKEN }}
args: -endpoint=https://sourcegraph.unknwon.cn lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
linters-settings:
nakedret:
max-func-lines: 0 # Disallow any unnamed return statement

linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- nakedret
- gofmt
- rowserrcheck
- unconvert
- goimports
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ coverage:
threshold: 1%

comment:
layout: 'diff, files'
layout: 'diff'
3 changes: 0 additions & 3 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,8 @@ func (k *Key) parseUint64s(strs []string, addInvalid, returnOnInvalid bool) ([]u
return vals, err
}


type Parser func(str string) (interface{}, error)


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


// doParse transforms strings to different types
func (k *Key) doParse(strs []string, addInvalid, returnOnInvalid bool, parser Parser) ([]interface{}, error) {
vals := make([]interface{}, 0, len(strs))
Expand Down
12 changes: 4 additions & 8 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func readKeyName(delimiters string, in []byte) (string, int, error) {
// Check if key name surrounded by quotes.
var keyQuote string
if line[0] == '"' {
if len(line) > 6 && string(line[0:3]) == `"""` {
if len(line) > 6 && line[0:3] == `"""` {
keyQuote = `"""`
} else {
keyQuote = `"`
Expand Down Expand Up @@ -232,7 +232,7 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
}

var valQuote string
if len(line) > 3 && string(line[0:3]) == `"""` {
if len(line) > 3 && line[0:3] == `"""` {
valQuote = `"""`
} else if line[0] == '`' {
valQuote = "`"
Expand Down Expand Up @@ -289,12 +289,8 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
hasSurroundedQuote(line, '"')) && !p.options.PreserveSurroundedQuote {
line = line[1 : len(line)-1]
} else if len(valQuote) == 0 && p.options.UnescapeValueCommentSymbols {
if strings.Contains(line, `\;`) {
line = strings.Replace(line, `\;`, ";", -1)
}
if strings.Contains(line, `\#`) {
line = strings.Replace(line, `\#`, "#", -1)
}
line = strings.ReplaceAll(line, `\;`, ";")

This comment has been minimized.

Copy link
@mcikosos

mcikosos Sep 16, 2021

ReplaceAll was added in go1.12
readme: The minimum requirement of Go is 1.6.
Please update readme or revert the changes ?

This comment has been minimized.

Copy link
@unknwon

unknwon Nov 11, 2021

Author Member

Good catch! Go 1.6 is fairly old, so I'll update the README.

line = strings.ReplaceAll(line, `\#`, "#")
} else if p.options.AllowPythonMultilineValues && lastChar == '\n' {
return p.readPythonMultilines(line, bufferSize)
}
Expand Down

0 comments on commit f8a14ab

Please sign in to comment.