Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

. #33

Closed
wants to merge 28 commits into from
Closed

. #33

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6780691
fix missing label on server_server_latency metric
ckcd Nov 29, 2023
23d93a8
feat: add linter version checker and workflow
mikeee Oct 22, 2023
b88ea63
feat: add lint version checker to lint make flow
mikeee Oct 22, 2023
4ee8516
fix: convert line endings to LF on checkout
mikeee Oct 22, 2023
61efacc
fix: rename main branch
mikeee Oct 22, 2023
1c2a616
fix: remove erroneous char
mikeee Oct 22, 2023
86a6b5b
fix: set up go using go.mod version
mikeee Oct 22, 2023
65873af
fix: migrate tool into build-tools
mikeee Oct 22, 2023
698d88b
fix: migrate tooling workflow
mikeee Oct 22, 2023
de761d2
fix: remove strict lint step for tools
mikeee Oct 22, 2023
e3541a5
fix: refactor version comparison function
mikeee Oct 23, 2023
9354ec0
Fixing typo.
artursouza Nov 16, 2023
cbba34f
Metadata API: report actor runtime status (#7040)
ItalyPaleAle Nov 27, 2023
d54abf6
Enhance workflow logs (#7222)
shivamkm07 Nov 30, 2023
88e05b8
add e2e test of workflow parallel execution (#7237)
MregXN Nov 30, 2023
5d5ca2b
Updates Go to 1.21, golangci-lint to 1.55.2
JoshVanL Nov 30, 2023
2ad8e44
Lint code
JoshVanL Dec 1, 2023
345bcb7
Disable tagalign linter, don't aline yaml tags
JoshVanL Dec 1, 2023
79d1b13
Remove gRPC Get nil checkings
JoshVanL Dec 1, 2023
c353d51
Add extra env vars to charts (#7183)
filintod Dec 4, 2023
ef10920
chore: removed namespace (#7271)
sadath-12 Dec 5, 2023
d992df9
Updates dapr/kit and dapr/components-contrib to HEAD
JoshVanL Dec 5, 2023
d1df26e
Adds Daprd option `--dapr-block-shutdown-duration` (#7268)
JoshVanL Dec 6, 2023
5c61a36
Fix timeouts in HTTP service invocation when resiliency policies with…
ItalyPaleAle Dec 11, 2023
4f5d1d3
Serialize reminders as protobuf in state store (#7129)
ItalyPaleAle Dec 12, 2023
a450f61
Adding myself as dapr bot owner (#7233)
ASHIQUEMD Dec 13, 2023
2275262
Version Skew Integration Tests
JoshVanL Dec 13, 2023
d07ee1b
.
JoshVanL Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
111 changes: 111 additions & 0 deletions .build-tools/cmd/check-lint-version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package cmd

import (
"errors"
"fmt"
"os"
"os/exec"
"regexp"

"github.com/spf13/cobra"
"golang.org/x/mod/semver"
"gopkg.in/yaml.v3"
)

var (
ErrVersionNotSupported = errors.New("version not supported")
ErrVersionNotFound = errors.New("version not found")
)

type GHWorkflow struct {
Jobs struct {
Lint struct {
Env struct {
GOVER string `yaml:"GOVER"`
GOLANGCILINTVER string `yaml:"GOLANGCILINT_VER"`
} `yaml:"env"`
} `yaml:"lint"`
} `yaml:"jobs"`
}

func parseWorkflowVersionFromFile(path string) (string, error) {
var ghWorkflow GHWorkflow

raw, err := os.ReadFile(path)
if err != nil {
return "", err
}
err = yaml.Unmarshal(raw, &ghWorkflow)
if err != nil {
return "", err
}
return ghWorkflow.Jobs.Lint.Env.GOLANGCILINTVER, err
}

func getCurrentVersion() (string, error) {
out, err := exec.Command("golangci-lint", "--version").Output()
if err != nil {
return "", err
}

regex, err := regexp.Compile(`golangci-lint\shas\sversion\sv?([\d+.]+[\d])`)
if err != nil {
return "", err
}

matches := regex.FindStringSubmatch(string(out))

if matches == nil {
return "", fmt.Errorf("no version found: %v", string(out))
}
return fmt.Sprintf("v%s", matches[1]), err
}

func isVersionValid(workflowVersion, currentVersion string) bool {
res := semver.MajorMinor(workflowVersion) == semver.MajorMinor(currentVersion)
return res
}

func compareVersions(path string) (string, error) {
workflowVersion, err := parseWorkflowVersionFromFile(path)
if err != nil {
return fmt.Sprintf("Error parsing workflow version: %v", err), ErrVersionNotFound
}
currentVersion, err := getCurrentVersion()
if err != nil {
return fmt.Sprintf("Error getting current version: %v", err), ErrVersionNotFound
}
validVersion := isVersionValid(workflowVersion, currentVersion)
if !validVersion {
return fmt.Sprintf("Invalid version, expected: %s, current: %s ", workflowVersion, currentVersion), ErrVersionNotSupported
}
return fmt.Sprintf("Linter version is valid (MajorMinor): %s", currentVersion), nil
}

func getCmdCheckLint(cmdType string) *cobra.Command {
// Base command
cmd := &cobra.Command{
Use: cmdType,
Short: "Compare local golangci-lint version against workflow version",
Run: func(cmd *cobra.Command, args []string) {
path := cmd.Flag("path").Value.String()
res, err := compareVersions(path)
fmt.Println(res)
if err != nil {
fmt.Println("Please install the correct version using the guide - https://golangci-lint.run/usage/install/")
if err == ErrVersionNotSupported {
fmt.Println("Alternatively review the golangci-lint version in the workflow file at .github/workflows/dapr.yml")
}
os.Exit(1)
}
},
}
cmd.PersistentFlags().String("path", "../.github/workflows/dapr.yml", "Path to workflow file")
return cmd
}

func init() {
// checkLintCmd represents the checkLint command
checkLintCmd := getCmdCheckLint("check-linter")
rootCmd.AddCommand(checkLintCmd)
}
91 changes: 91 additions & 0 deletions .build-tools/cmd/check-lint-version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestParseWorkflow(t *testing.T) {
t.Run("parse invalid workflow file", func(t *testing.T) {
parsedVersion, err := parseWorkflowVersionFromFile("../testdata/check-lint-version/invalid.yml")
assert.Equal(t, "", parsedVersion)
assert.Error(t, err)
})

t.Run("parse workflow file with a missing key", func(t *testing.T) {
parsedVersion, err := parseWorkflowVersionFromFile("../testdata/check-lint-version/invalid-test.yml")
assert.Equal(t, "", parsedVersion)
assert.NoError(t, err)
})

t.Run("parse an invalid workflow file", func(t *testing.T) {
parsedVersion, err := parseWorkflowVersionFromFile("../testdata/check-lint-version/invalid-yaml.yml")
assert.Equal(t, "", parsedVersion)
assert.Error(t, err)
})

t.Run("parse testing workflow file", func(t *testing.T) {
parsedVersion, err := parseWorkflowVersionFromFile("../testdata/check-lint-version/valid-test.yml")
assert.Equal(t, "123.123.123", parsedVersion)
assert.NoError(t, err)
})
}

func TestGetCurrentVersion(t *testing.T) {
t.Run("get current version from system", func(t *testing.T) {
currentVersion, err := getCurrentVersion()
assert.Equal(t, "v1.55.2", currentVersion)
assert.NoError(t, err)
})

// TODO: test failure to detect current version

// TODO: test failure to compile regex expression

// TODO: test failure finding matches
}

func TestIsVersionValid(t *testing.T) {
t.Run("compare versions - exactly equal to", func(t *testing.T) {
assert.Equal(t, true, isVersionValid("v1.54.2", "v1.54.2"))
})

t.Run("compare versions - patch version greater (workflow)", func(t *testing.T) {
assert.Equal(t, true, isVersionValid("v1.54.3", "v1.54.2"))
})

t.Run("compare versions - patch version greater (installed)", func(t *testing.T) {
assert.Equal(t, true, isVersionValid("v1.54.2", "v1.54.3"))
})

t.Run("compare versions - invalid (installed)", func(t *testing.T) {
assert.Equal(t, false, isVersionValid("v1.54.2", "v1.52.2"))
})

t.Run("compare versions - invalid (workflow)", func(t *testing.T) {
assert.Equal(t, false, isVersionValid("v1.52.2", "v1.54.2"))
})
}

func TestCompareVersions(t *testing.T) {
t.Run("Valid comparison", func(t *testing.T) {
res, err := compareVersions("../../.github/workflows/dapr.yml")
assert.Contains(t, res, "Linter version is valid")
assert.NoError(t, err)
})

t.Run("Invalid comparison", func(t *testing.T) {
res, err := compareVersions("../testdata/check-lint-version/invalid-test.yml")
assert.Contains(t, res, "Invalid version")
assert.Error(t, err)
})

// TODO: test function for failure to get the current version using getCurrentVersion()

t.Run("Invalid path for comparison", func(t *testing.T) {
res, err := compareVersions("../testdata/check-lint-version/invalid-test-incorrect-path.yml")
assert.Contains(t, res, "Error parsing workflow")
assert.Error(t, err)
})
}
8 changes: 7 additions & 1 deletion .build-tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
module build-tools

go 1.20
go 1.21

require (
github.com/google/go-containerregistry v0.11.1-0.20220802162123-c1f9836a4fa9
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.7.0
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/containerd/stargz-snapshotter/estargz v0.12.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v20.10.17+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.15.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220729202839-6ad7100eb087 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
Expand Down
11 changes: 11 additions & 0 deletions .build-tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ github.com/containerd/stargz-snapshotter/estargz v0.12.0 h1:idtwRTLjk2erqiYhPWy2
github.com/containerd/stargz-snapshotter/estargz v0.12.0/go.mod h1:AIQ59TewBFJ4GOPEQXujcrJ/EKxh5xXZegW1rkR1P/M=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -23,16 +24,23 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.8 h1:JahtItbkWjf2jzm/T+qgMxkP9EMHsqEUA6vCMGmXvhA=
github.com/klauspost/compress v1.15.8/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.3-0.20220729202839-6ad7100eb087 h1:vm7/Jb0eH7oibgUngG/ljkvHBxF+mHlekCvVFyLGOc8=
github.com/opencontainers/image-spec v1.0.3-0.20220729202839-6ad7100eb087/go.mod h1:K/JAU0m27RFhDRX4PcFdIKntROP6y5Ed6O91aZYDQfs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand All @@ -59,6 +67,8 @@ github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaW
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/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=
Expand All @@ -68,6 +78,7 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
12 changes: 12 additions & 0 deletions .build-tools/testdata/check-lint-version/invalid-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test

on:
push:
pull_request:
branches:
- main

jobs:
build:
env:
NOGOLANGCILINT_VER: "123.123.123"
1 change: 1 addition & 0 deletions .build-tools/testdata/check-lint-version/invalid-yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testfile
12 changes: 12 additions & 0 deletions .build-tools/testdata/check-lint-version/valid-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Test

on:
push:
pull_request:
branches:
- main

jobs:
lint:
env:
GOLANGCILINT_VER: "123.123.123"
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
1 change: 1 addition & 0 deletions .github/scripts/dapr_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const owners = [
'tanvigour',
'yaron2',
'rabollin',
'ashiquemd'
]

const SDKs = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go b/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go
index 1bb56944f..18bb9c63a 100644
--- a/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go
+++ b/tests/integration/suite/daprd/serviceinvocation/http/httpendpoints.go
@@ -209,7 +209,7 @@ func (h *httpendpoints) Run(t *testing.T, ctx context.Context) {
t.Run("bad PKI", func(t *testing.T) {
invokeTests(t, http.StatusInternalServerError, func(t *testing.T, body string) {
assert.Contains(t, body, `"errorCode":"ERR_DIRECT_INVOKE"`)
- assert.Contains(t, body, "tls: bad certificate")
+ assert.Contains(t, body, "remote error: tls: unknown certificate authority")
}, h.daprd2)
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/tests/integration/suite/daprd/metadata/metadata.go b/tests/integration/suite/daprd/metadata/metadata.go
index 5e5a86452..0cccd8bd8 100644
--- a/tests/integration/suite/daprd/metadata/metadata.go
+++ b/tests/integration/suite/daprd/metadata/metadata.go
@@ -19,6 +19,7 @@ import (
"fmt"
"io"
"net/http"
+ "strings"
"testing"
"time"

@@ -82,11 +83,13 @@ func validateResponse(t *testing.T, appID string, appPort int, body io.Reader) {
require.NoError(t, err)

require.Equal(t, appID, bodyMap["id"])
- require.Equal(t, "edge", bodyMap["runtimeVersion"])
+ require.True(t, "edge" == bodyMap["runtimeVersion"].(string) ||
+ strings.HasPrefix(bodyMap["runtimeVersion"].(string), "1.12."))

extended, ok := bodyMap["extended"].(map[string]interface{})
require.True(t, ok)
- require.Equal(t, "edge", extended["daprRuntimeVersion"])
+ require.True(t, "edge" == extended["daprRuntimeVersion"].(string) ||
+ strings.HasPrefix(extended["daprRuntimeVersion"].(string), "1.12."))

appConnectionProperties, ok := bodyMap["appConnectionProperties"].(map[string]interface{})
require.True(t, ok)
2 changes: 1 addition & 1 deletion .github/workflows/dapr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
target_os: ["linux"]
target_arch: ["amd64"]
env:
GOLANGCILINT_VER: "v1.51.2"
GOLANGCILINT_VER: "v1.55.2"
PROTOC_VERSION: "21.12"
GOOS: "${{ matrix.target_os }}"
GOARCH: "${{ matrix.target_arch }}"
Expand Down
Loading
Loading