Skip to content

Commit

Permalink
chore(ci): use different version of Go (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Aug 10, 2023
1 parent 067b930 commit ecb75df
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 119 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# This file adheres to the YAML5 style.
{
name: "Go",
on: ["push", "pull_request"],
on: [ "push", "pull_request" ],
jobs: {
build: {
name: "Build",
"runs-on": "ubuntu-latest",
strategy: { matrix: { "go-version": [ "stable", "oldstable"] } },
steps: [
{ name: "Check out code into the Go module directory", uses: "actions/checkout@v3" },
{
name: "Set up Go 1.18",
uses: "actions/setup-go@v1",
"with": {"go-version": 1.18},
name: "Set up Go ${{ matrix.go-version }}",
uses: "actions/setup-go@v4",
with: { "go-version": "${{ matrix.go-version }}" },
id: "go",
},
{name: "Check out code into the Go module directory", uses: "actions/checkout@v1"},
{name: "Linter", run: "make lint"},
{name: "Test", run: "make test"},
{name: "Test release", run: "make test-release"},
{ name: "Linter", run: "make lint" },
{ name: "Test", run: "make test" },
{ name: "Test release", run: "make test-release" },
],
},
},
Expand Down
19 changes: 11 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,39 @@
"fast": false,
"linters": {
"enable": [
"deadcode",
"errcheck",
"gas",
"gosec",
"gocritic",
"gofmt",
"goimports",
"golint",
"govet",
"gosimple",
"ineffassign",
"megacheck",
"misspell",
"nakedret",
"staticcheck",
"structcheck",
"typecheck",
"unconvert",
"unparam",
"unused",
"varcheck",
],
},
"disable": [
"deadcode", # deprecated
"depguard",
"dupl",
"exhaustivestruct", # deprecated
"gocyclo",
"interfacer",
"golint", # deprecated
"ifshort", # deprecated
"interfacer", # deprecated
"lll",
"maligned",
"maligned", # deprecated
"nosnakecase", # deprecated
"prealloc",
"scopelint", # deprecated
"structcheck", # deprecated
"varcheck", # deprecated
],
"linters-settings": {
"gocritic": {
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test-release:
@echo "everything is OK"

lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH_DIR)/bin v1.49.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH_DIR)/bin v1.54.0
$(GOPATH_DIR)/bin/golangci-lint run ./...
go build -o go-ruleguard ./cmd/ruleguard
./go-ruleguard -debug-imports -rules rules.go ./...
Expand Down
3 changes: 1 addition & 2 deletions analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"go/token"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -232,7 +231,7 @@ func newEngine() (*ruleguard.Engine, error) {
filenames := strings.Split(flagRules, ",")
for _, filename := range filenames {
filename = strings.TrimSpace(filename)
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("read rules file: %v", err)
}
Expand Down
5 changes: 2 additions & 3 deletions analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"go/token"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -180,7 +179,7 @@ var rulesFile = %s
}
t.Run(test.name, func(t *testing.T) {
rulesFilename := filepath.Join(wd, "testdata", "src", test.name, "rules.go")
data, err := ioutil.ReadFile(rulesFilename)
data, err := os.ReadFile(rulesFilename)
if err != nil {
t.Fatalf("%s: %v", test.name, err)
}
Expand All @@ -205,7 +204,7 @@ var rulesFile = %s
}
var irfileBuf bytes.Buffer
irprint.File(&irfileBuf, irfile)
mainFile, err := ioutil.TempFile("", "ruleguard-test*.go")
mainFile, err := os.CreateTemp("", "ruleguard-test*.go")
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/gorules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package main

import (
"bytes"
"os"

"encoding/json"
"flag"
"fmt"
Expand All @@ -12,8 +10,8 @@ import (
"go/parser"
"go/token"
"go/types"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -86,7 +84,7 @@ func docCommand(args []string) error {
filenames := strings.Split(*flagRules, ",")
for _, filename := range filenames {
filename = strings.TrimSpace(filename)
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("read rules file: %v", err)
}
Expand Down Expand Up @@ -164,7 +162,7 @@ func precompileCommand(args []string) error {

fset := token.NewFileSet()
filename := strings.TrimSpace(*flagRules)
fileData, err := ioutil.ReadFile(filename)
fileData, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("read %s: %v", filename, err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/quasilyte/go-ruleguard

go 1.17
go 1.19

require (
github.com/go-toolsmith/astcopy v1.0.2
Expand Down
30 changes: 0 additions & 30 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,65 +22,35 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4l
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ=
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
3 changes: 1 addition & 2 deletions ruleguard/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"go/token"
"go/types"
"io"
"io/ioutil"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -48,7 +47,7 @@ func (e *engine) LoadedGroups() []GoRuleGroup {
}

func (e *engine) Load(ctx *LoadContext, buildContext *build.Context, filename string, r io.Reader) error {
data, err := ioutil.ReadAll(r)
data, err := io.ReadAll(r)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions ruleguard/ir/gen_filter_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"os"
"strings"
)

Expand Down Expand Up @@ -142,7 +142,7 @@ func main() {
panic(err)
}

if err := ioutil.WriteFile("filter_op.gen.go", pretty, 0644); err != nil {
if err := os.WriteFile("filter_op.gen.go", pretty, 0644); err != nil {
panic(err)
}
}
4 changes: 2 additions & 2 deletions ruleguard/ir_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"go/parser"
"go/token"
"go/types"
"io/ioutil"
"os"
"regexp"

"github.com/quasilyte/gogrep"
Expand Down Expand Up @@ -144,7 +144,7 @@ func (l *irLoader) loadBundle(bundle ir.BundleImport) error {
}

func (l *irLoader) loadExternFile(prefix, pkgPath, filename string) (*goRuleSet, error) {
src, err := ioutil.ReadFile(filename)
src, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions ruleguard/quasigo/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -241,7 +240,7 @@ func TestEval(t *testing.T) {
}

func TestEvalFile(t *testing.T) {
files, err := ioutil.ReadDir("testdata")
files, err := os.ReadDir("testdata")
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions ruleguard/quasigo/gen_opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"log"
"os"
"strings"
"text/template"
)
Expand Down Expand Up @@ -186,7 +186,7 @@ func writeFile(filename string, data []byte) {
if err != nil {
log.Panicf("gofmt: %v", err)
}
if err := ioutil.WriteFile(filename, pretty, 0666); err != nil {
if err := os.WriteFile(filename, pretty, 0666); err != nil {
log.Panicf("write %s: %v", filename, err)
}
}
4 changes: 2 additions & 2 deletions ruleguard/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"go/build"
"go/printer"
"go/token"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"sort"
Expand Down Expand Up @@ -166,7 +166,7 @@ func (rr *rulesRunner) fileBytes() []byte {
}

// TODO(quasilyte): re-use src slice?
src, err := ioutil.ReadFile(rr.filename)
src, err := os.ReadFile(rr.filename)
if err != nil || src == nil {
// Assign a zero-length slice so rr.src
// is never nil during the second fileBytes call.
Expand Down
Loading

0 comments on commit ecb75df

Please sign in to comment.