Skip to content

Commit

Permalink
Add Go 1.20 support
Browse files Browse the repository at this point in the history
Swaps lint tooling from golint to golangci-lint.
Resolve lint warnings for deprecated package io/ioutil.
Adds Go strategy matrix for Go 1.18, 1.19, and 1.20.
Update actions/setup-go package from v1 to v3 to resolve CI warnings.
Adds go.[mod/sum] files for repository.

Signed-off-by: Austin Vazquez <[email protected]>
  • Loading branch information
austinvazquez committed Feb 4, 2023
1 parent 7301c34 commit 917fe22
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 29 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ on:
jobs:
run:
runs-on: ubuntu-latest

strategy:
matrix:
go: [1.18.x, 1.19.x, 1.20.x]

steps:
- name: checkout source code
uses: actions/checkout@master

- name: setup go environment
uses: actions/setup-go@v1
uses: actions/setup-go@v3
with:
go-version: '1.17.2'
go-version: ${{ matrix.go }}

- name: run tests
run: |
export PATH="$(go env GOPATH)/bin:${PATH}"
set -x
make install.tools
# Fix for "cannot find main module" issue
go mod init github.com/opencontainers/runtime-spec
go get -d ./schema/...
make .govet
make .golint
make .lint
make .gitvalidation
make docs
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ on:
jobs:
run:
runs-on: ubuntu-latest

strategy:
matrix:
go: [1.18.x, 1.19.x, 1.20.x]

steps:
- name: checkout source code
uses: actions/checkout@master

- name: setup go environment
uses: actions/setup-go@v1
uses: actions/setup-go@v3
with:
go-version: '1.17.2'
go-version: ${{ matrix.go }}

- name: run tests
run: |
export PATH="$(go env GOPATH)/bin:${PATH}"
set -x
make install.tools
# Fix for "cannot find main module" issue
go mod init github.com/opencontainers/runtime-spec
go get -d ./schema/...
make .govet
make .golint
make .lint
make .gitvalidation
make docs
Expand Down
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ test: .govet .golint .gitvalidation
.govet:
go vet -x ./...

# `go get github.com/golang/lint/golint`
.golint:
ifeq ($(call ALLOWED_GO_VERSION,1.7,$(HOST_GOLANG_VERSION)),true)
@which golint > /dev/null 2>/dev/null || (echo "ERROR: golint not found. Consider 'make install.tools' target" && false)
golint ./...
endif
.lint:
@which golangci-lint > /dev/null 2>/dev/null || (echo "ERROR: golangci-lint not found. Consider 'make install.tools' target" && false)
golangci-lint run


# When this is running in GitHub, it will only check the GitHub commit range
Expand All @@ -78,16 +75,13 @@ else
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
endif

install.tools: .install.golint .install.gitvalidation
install.tools: .install.lint .install.gitvalidation

# golint does not even build for <go1.7
.install.golint:
ifeq ($(call ALLOWED_GO_VERSION,1.7,$(HOST_GOLANG_VERSION)),true)
go get -u golang.org/x/lint/golint
endif
.install.lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]

.install.gitvalidation:
go get -u github.com/vbatts/git-validation
go install github.com/vbatts/git-validation@v1.1.0

clean:
rm -rf $(OUTPUT_DIRNAME) *~
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/opencontainers/runtime-spec

go 1.18

require github.com/xeipuuv/gojsonschema v1.2.0

require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
4 changes: 2 additions & 2 deletions schema/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -61,7 +61,7 @@ func main() {
}
documentLoader = gojsonschema.NewReferenceLoader("file://" + documentPath)
} else {
documentBytes, err := ioutil.ReadAll(os.Stdin)
documentBytes, err := io.ReadAll(os.Stdin)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down

0 comments on commit 917fe22

Please sign in to comment.