Skip to content

Commit 1d3367b

Browse files
committed
chore: CI upgrades
1 parent 39e6074 commit 1d3367b

File tree

6 files changed

+68
-40
lines changed

6 files changed

+68
-40
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: monthly

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v5
2828

2929
- name: Initialize CodeQL
3030
uses: github/codeql-action/init@v2

.github/workflows/test.yaml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,59 @@ permissions:
1010
jobs:
1111
clean:
1212
# https://github.blesdmm.dns-dynamic.netmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
13-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
13+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }}
1414
runs-on: ubuntu-latest
1515
timeout-minutes: 10
1616
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-go@v3
17+
- uses: actions/checkout@v5
18+
- uses: actions/setup-go@v6
1919
with:
20-
go-version: "^1"
20+
go-version: stable
2121
- run: lint=0 script/clean
2222

2323
bench:
2424
# https://github.blesdmm.dns-dynamic.netmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
25-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
25+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }}
2626
runs-on: ubuntu-latest
2727
timeout-minutes: 10
2828
steps:
29-
- uses: actions/checkout@v3
30-
- uses: actions/setup-go@v3
29+
- uses: actions/checkout@v5
30+
- uses: actions/setup-go@v6
3131
with:
32-
go-version: "^1"
32+
go-version: stable
3333
- run: script/bench
3434

3535
lint:
3636
# https://github.blesdmm.dns-dynamic.netmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
37-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
37+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }}
3838
runs-on: ubuntu-latest
3939
timeout-minutes: 10
4040
steps:
41-
- uses: actions/checkout@v3
42-
- uses: actions/setup-go@v3
41+
- uses: actions/checkout@v5
42+
- uses: actions/setup-go@v6
4343
with:
44-
go-version: "^1"
45-
- uses: golangci/golangci-lint-action@v2
44+
go-version: stable
45+
- uses: golangci/golangci-lint-action@v8
46+
with:
47+
version: v2.5.0
4648

4749
test:
4850
name: "test with Go ${{ matrix.go }}"
4951
# https://github.blesdmm.dns-dynamic.netmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
50-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
52+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }}
5153
runs-on: ubuntu-latest
5254
timeout-minutes: 10
5355
strategy:
5456
fail-fast: false
5557
matrix:
5658
include:
57-
- { go: "1.11" }
59+
- { go: "1.12" }
5860
- { go: "1.17" }
5961
- { go: "1.18" }
6062
- { go: "^1", coverage: true }
6163
steps:
62-
- uses: actions/checkout@v3
63-
- uses: actions/setup-go@v3
64+
- uses: actions/checkout@v5
65+
- uses: actions/setup-go@v6
6466
with:
6567
go-version: ${{ matrix.go }}
6668
- run: go test -race
@@ -72,9 +74,9 @@ jobs:
7274

7375
vuln:
7476
# https://github.blesdmm.dns-dynamic.netmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
75-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
77+
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.fork }}
7678
runs-on: ubuntu-latest
7779
timeout-minutes: 10
7880
steps:
79-
- uses: actions/checkout@v3
81+
- uses: actions/checkout@v5
8082
- uses: kmulvey/govulncheck-action@main

.golangci.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1+
version: "2"
12
linters:
23
enable:
4+
- copyloopvar
5+
- decorder
6+
- errcheck
37
- goconst
4-
- gofmt
58
- gosec
6-
- maligned
9+
- govet
10+
- ineffassign
711
- prealloc
812
- staticcheck
9-
disable:
10-
- deadcode
11-
- structcheck
12-
- varcheck
13-
14-
linters-settings:
15-
gofmt:
16-
simplify: true
17-
govet:
18-
check-shadowing: true
19-
maligned:
20-
suggest-new: true
13+
- unused
14+
exclusions:
15+
generated: lax
16+
presets:
17+
- comments
18+
- common-false-positives
19+
- legacy
20+
- std-error-handling
21+
paths:
22+
- third_party$
23+
- builtin$
24+
- examples$
25+
rules:
26+
- linters:
27+
- staticcheck
28+
text: "error strings should not be capitalized"
29+
formatters:
30+
enable:
31+
- gofmt
32+
settings:
33+
gofmt:
34+
simplify: true
35+
exclusions:
36+
generated: lax
37+
paths:
38+
- third_party$
39+
- builtin$
40+
- examples$

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/temoto/robotstxt
22

3-
go 1.11
3+
go 1.12
44

55
require github.com/stretchr/testify v1.3.0

parser.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (p *parser) parseAll() (groups map[string]*Group, host string, sitemaps []s
8888
case lDisallow:
8989
// Error if no current group
9090
if len(agents) == 0 {
91-
errs = append(errs, fmt.Errorf("Disallow before User-agent at token #%d.", p.pos))
91+
errs = append(errs, fmt.Errorf("Disallow before User-agent at token #%d", p.pos))
9292
} else {
9393
isEmptyGroup = false
9494
var r *rule
@@ -103,7 +103,7 @@ func (p *parser) parseAll() (groups map[string]*Group, host string, sitemaps []s
103103
case lAllow:
104104
// Error if no current group
105105
if len(agents) == 0 {
106-
errs = append(errs, fmt.Errorf("Allow before User-agent at token #%d.", p.pos))
106+
errs = append(errs, fmt.Errorf("Allow before User-agent at token #%d", p.pos))
107107
} else {
108108
isEmptyGroup = false
109109
var r *rule
@@ -123,7 +123,7 @@ func (p *parser) parseAll() (groups map[string]*Group, host string, sitemaps []s
123123

124124
case lCrawlDelay:
125125
if len(agents) == 0 {
126-
errs = append(errs, fmt.Errorf("Crawl-delay before User-agent at token #%d.", p.pos))
126+
errs = append(errs, fmt.Errorf("Crawl-delay before User-agent at token #%d", p.pos))
127127
} else {
128128
isEmptyGroup = false
129129
delay := time.Duration(li.vf * float64(time.Second))
@@ -182,8 +182,8 @@ func (p *parser) parseLine() (li *lineInfo, err error) {
182182
// Must compile a regexp, this is a pattern.
183183
// Escape string before compile.
184184
t2 = regexp.QuoteMeta(t2)
185-
t2 = strings.Replace(t2, `\*`, `.*`, -1)
186-
t2 = strings.Replace(t2, `\$`, `$`, -1)
185+
t2 = strings.ReplaceAll(t2, `\*`, `.*`)
186+
t2 = strings.ReplaceAll(t2, `\$`, `$`)
187187
if r, e := regexp.Compile(t2); e != nil {
188188
return nil, e
189189
} else {

0 commit comments

Comments
 (0)