Skip to content

Commit

Permalink
Merge pull request #16 from breml/fix-build
Browse files Browse the repository at this point in the history
Fix test for Go 1.22, update GH actions.
  • Loading branch information
breml committed Feb 29, 2024
2 parents c3a9efc + 2b092ff commit 3db7b78
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- uses: actions/go-dependency-submission@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go-cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache Go modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
steps:

- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Go modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

-
name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"

-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
Expand Down
11 changes: 10 additions & 1 deletion pkg/depcaps/depcaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package depcaps_test
import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"

// unused import of "github.com/google/uuid" to workaround GOPROXY=no in
Expand Down Expand Up @@ -89,7 +91,7 @@ func TestAll(t *testing.T) {
{
name: "capslock file",
linterSettings: &depcaps.LinterSettings{
CapslockBaselineFile: "capslockfile/capslock.json",
CapslockBaselineFile: "capslockfile/capslock" + versionSuffix() + ".json",
},
testdataDir: "alltest",
packages: []string{"./capslockfile/..."},
Expand Down Expand Up @@ -128,3 +130,10 @@ func TestAll(t *testing.T) {
})
}
}

func versionSuffix() string {
if strings.HasPrefix(runtime.Version(), "go1.22") {
return "_go122"
}
return ""
}
3 changes: 3 additions & 0 deletions testdata/src/alltest/allow/allow.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !go1.22
// +build !go1.22

package main

import (
Expand Down
12 changes: 12 additions & 0 deletions testdata/src/alltest/allow/allow_go122.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build go1.22
// +build go1.22

package main

import (
"github.com/google/uuid" // want "Package github.com/google/uuid has not allowed capability CAPABILITY_NETWORK" "Package github.com/google/uuid has not allowed capability CAPABILITY_REFLECT"
)

func main() {
uuid.GetTime()
}
189 changes: 189 additions & 0 deletions testdata/src/alltest/capslockfile/capslock_go122.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"capabilityInfo": [
{
"packageName": "main",
"capability": "CAPABILITY_REFLECT",
"depPath": "alltest/capslockfile.init github.com/google/uuid.init database/sql/driver.init reflect.TypeFor[database/sql/driver.Valuer]",
"path": [
{
"name": "alltest/capslockfile.init"
},
{
"name": "github.com/google/uuid.init"
},
{
"name": "database/sql/driver.init"
},
{
"name": "reflect.TypeFor[database/sql/driver.Valuer]",
"site": {
"filename": "types.go",
"line": "215",
"column": "48"
}
}
],
"packageDir": "alltest/capslockfile",
"capabilityType": "CAPABILITY_TYPE_TRANSITIVE"
},
{
"packageName": "main",
"capability": "CAPABILITY_NETWORK",
"depPath": "alltest/capslockfile.main github.com/google/uuid.GetTime github.com/google/uuid.getTime github.com/google/uuid.setClockSequence github.com/google/uuid.randomBits io.ReadFull io.ReadAtLeast (*net.TCPConn).Read (*net.conn).Read",
"path": [
{
"name": "alltest/capslockfile.main"
},
{
"name": "github.com/google/uuid.GetTime",
"site": {
"filename": "capslockfile.go",
"line": "8",
"column": "14"
}
},
{
"name": "github.com/google/uuid.getTime",
"site": {
"filename": "time.go",
"line": "48",
"column": "16"
}
},
{
"name": "github.com/google/uuid.setClockSequence",
"site": {
"filename": "time.go",
"line": "56",
"column": "19"
}
},
{
"name": "github.com/google/uuid.randomBits",
"site": {
"filename": "time.go",
"line": "100",
"column": "13"
}
},
{
"name": "io.ReadFull",
"site": {
"filename": "util.go",
"line": "13",
"column": "26"
}
},
{
"name": "io.ReadAtLeast",
"site": {
"filename": "io.go",
"line": "354",
"column": "20"
}
},
{
"name": "(*net.TCPConn).Read",
"site": {
"filename": "io.go",
"line": "335",
"column": "19"
}
},
{
"name": "(*net.conn).Read"
}
],
"packageDir": "alltest/capslockfile",
"capabilityType": "CAPABILITY_TYPE_TRANSITIVE"
},
{
"packageName": "main",
"capability": "CAPABILITY_FILES",
"depPath": "alltest/capslockfile.main github.com/google/uuid.GetTime github.com/google/uuid.getTime github.com/google/uuid.setClockSequence github.com/google/uuid.randomBits io.ReadFull io.ReadAtLeast (*os.File).Read",
"path": [
{
"name": "alltest/capslockfile.main"
},
{
"name": "github.com/google/uuid.GetTime",
"site": {
"filename": "capslockfile.go",
"line": "8",
"column": "14"
}
},
{
"name": "github.com/google/uuid.getTime",
"site": {
"filename": "time.go",
"line": "48",
"column": "16"
}
},
{
"name": "github.com/google/uuid.setClockSequence",
"site": {
"filename": "time.go",
"line": "56",
"column": "19"
}
},
{
"name": "github.com/google/uuid.randomBits",
"site": {
"filename": "time.go",
"line": "100",
"column": "13"
}
},
{
"name": "io.ReadFull",
"site": {
"filename": "util.go",
"line": "13",
"column": "26"
}
},
{
"name": "io.ReadAtLeast",
"site": {
"filename": "io.go",
"line": "354",
"column": "20"
}
},
{
"name": "(*os.File).Read",
"site": {
"filename": "io.go",
"line": "335",
"column": "19"
}
}
],
"packageDir": "alltest/capslockfile",
"capabilityType": "CAPABILITY_TYPE_TRANSITIVE"
}
],
"moduleInfo": [
{
"path": "github.com/google/uuid",
"version": "v1.3.1"
}
],
"packageInfo": [
{
"path": "alltest/capslockfile",
"ignoredFiles": [
"tools.go"
]
},
{
"path": "github.com/google/uuid",
"ignoredFiles": [
"node_js.go"
]
}
]
}
3 changes: 3 additions & 0 deletions testdata/src/alltest/simple/function/func.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !go1.22
// +build !go1.22

package function

import (
Expand Down
12 changes: 12 additions & 0 deletions testdata/src/alltest/simple/function/func_go122.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build go1.22
// +build go1.22

package function

import (
"github.com/google/uuid" // want "Package github.com/google/uuid has not allowed capability CAPABILITY_FILES" "Package github.com/google/uuid has not allowed capability CAPABILITY_NETWORK" "Package github.com/google/uuid has not allowed capability CAPABILITY_REFLECT"
)

func Call() {
uuid.GetTime() // regular function call is reported
}

0 comments on commit 3db7b78

Please sign in to comment.