Skip to content

Commit 4587432

Browse files
Vishal VaibhavGitHub Enterprise
authored andcommitted
open source review comment-update dependenciesA (#27)
* open source review comment-update dependenciesA * removed drone related stuffs * formatting fixes * test cases fixes * fix vela thing * fix vela thing * fix vela thing * fix vela thing * fix vela thing * fix vela thing
1 parent 3086811 commit 4587432

6 files changed

Lines changed: 154 additions & 270 deletions

File tree

.vela.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "1"
22

33
build: &build
4-
image: golang:1.13
4+
image: golang:1.17
55
environment:
66
- CGO_ENABLED=0
77
- GOOS=linux
@@ -21,8 +21,9 @@ check-pr-code-coverage: &check-pr-code-coverage
2121
- PARAMETER_COVERAGE_FILE=./coverage.xml
2222
- PARAMETER_COVERAGE_TYPE=cobertura
2323
- PARAMETER_SOURCE_DIRS=/vela/src/git.target.com/TargetOSS/pull-request-code-coverage
24-
- PLUGIN_RUN_DIR=bin
24+
- PARAMETER_RUN_DIR=bin
2525
- PARAMETER_GH_API_BASE_URL=https://git.target.com
26+
- PARAMETER_DEBUG=true
2627
secrets:
2728
- source: github_pr_token
2829
target: plugin_gh_api_key
@@ -31,7 +32,7 @@ check-pr-code-coverage: &check-pr-code-coverage
3132
- ./scripts/start.sh
3233
steps:
3334
- name: build-push
34-
image: golang:1.13
35+
image: golang:1.17
3536
<<: *build
3637
ruleset:
3738
branch:
@@ -40,7 +41,7 @@ steps:
4041
- push
4142

4243
- name : check-format-on-pr
43-
image: golang:1.13
44+
image: golang:1.17
4445
commands:
4546
- make format
4647
ruleset:

go.mod

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
module git.target.com/searchoss/pull-request-code-coverage
22

3-
go 1.13
3+
go 1.17
44

55
require (
66
github.com/pkg/errors v0.9.1
7-
github.com/sirupsen/logrus v1.2.0
8-
github.com/stretchr/testify v1.4.0
7+
github.com/sirupsen/logrus v1.8.1
8+
github.com/stretchr/testify v1.7.0
99

1010
)
11+
12+
require (
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
github.com/stretchr/objx v0.1.0 // indirect
16+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
17+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
18+
)

go.sum

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,20 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
5-
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
6-
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
7-
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
8-
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
9-
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
10-
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
11-
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
12-
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
13-
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
14-
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
15-
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
16-
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
17-
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
18-
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
19-
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
20-
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
21-
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
22-
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
23-
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
24-
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
25-
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
26-
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
27-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
28-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
29-
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
30-
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
314
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
325
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
336
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
347
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
35-
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
36-
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
8+
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
9+
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
10+
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
3711
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
38-
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
39-
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
40-
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
4112
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
42-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
43-
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
44-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
45-
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
46-
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
47-
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
48-
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
49-
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
50-
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
51-
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
52-
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
53-
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
54-
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
55-
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
56-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
13+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
14+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
16+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5717
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
5818
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
59-
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
60-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
61-
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
62-
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
19+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
20+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/plugin/runner.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func NewRunner() *DefaultRunner {
2828
// nolint: gocyclo
2929
func (*DefaultRunner) Run(propertyGetter func(string) (string, bool), changedSourceLinesSource io.Reader, reportDefaultOut io.Writer) error {
3030

31-
rawSourceDirs, found := getActiveEnvVariable(propertyGetter, "PLUGIN_SOURCE_DIRS", "PARAMETER_SOURCE_DIRS")
31+
rawSourceDirs, found := propertyGetter("PARAMETER_SOURCE_DIRS")
3232
if !found {
3333
return errors.New("Missing property PARAMETER_SOURCE_DIRS")
3434
}
35-
logrus.Info(fmt.Sprintf("PLUGIN_SOURCE_DIRS set to %v", rawSourceDirs))
35+
logrus.Info(fmt.Sprintf("PARAMETER_SOURCE_DIRS set to %v", rawSourceDirs))
3636

3737
sourceDirs := parseSourceDirs(rawSourceDirs)
3838

39-
coverageType, found := getActiveEnvVariable(propertyGetter, "PLUGIN_COVERAGE_TYPE", "PARAMETER_COVERAGE_TYPE")
39+
coverageType, found := propertyGetter("PARAMETER_COVERAGE_TYPE")
4040
if !found {
4141
return errors.New("Missing property PARAMETER_COVERAGE_TYPE")
4242
}
@@ -46,36 +46,36 @@ func (*DefaultRunner) Run(propertyGetter func(string) (string, bool), changedSou
4646
return errors.Wrap(getLoaderErr, "Failed opening coverage loader")
4747
}
4848

49-
coverageFile, found := getActiveEnvVariable(propertyGetter, "PLUGIN_COVERAGE_FILE", "PARAMETER_COVERAGE_FILE")
49+
coverageFile, found := propertyGetter("PARAMETER_COVERAGE_FILE")
5050
if !found {
5151
return errors.New("Missing property PARAMETER_COVERAGE_FILE")
5252
}
5353

54-
module, found := getActiveEnvVariable(propertyGetter, "PLUGIN_MODULE", "PARAMETER_MODULE")
54+
module, found := propertyGetter("PARAMETER_MODULE")
5555
if !found {
5656
logrus.Info("PARAMETER_MODULE was missing defaulting to false")
5757
module = ""
5858
}
5959

60-
ghAPIKey, ghAPIKeyFound := getActiveEnvVariable(propertyGetter, "PLUGIN_GH_API_KEY", "PARAMETER_GH_API_KEY")
60+
ghAPIKey, ghAPIKeyFound := propertyGetter("PARAMETER_GH_API_KEY")
6161
if !ghAPIKeyFound {
6262
logrus.Info("PARAMETER_GH_API_KEY was missing, will not send report to PR comments")
6363
}
6464

65-
ghAPIBaseURL, ghAPIBaseURLFound := getActiveEnvVariable(propertyGetter, "PLUGIN_GH_API_BASE_URL", "PARAMETER_GH_API_BASE_URL")
65+
ghAPIBaseURL, ghAPIBaseURLFound := propertyGetter("PARAMETER_GH_API_BASE_URL")
6666
if !ghAPIBaseURLFound {
6767
logrus.Info("PARAMETER_GH_API_BASE_URL was missing, will not send report to PR comments")
6868
}
6969

70-
repoPR, repoPRFound := getActiveEnvVariable(propertyGetter, "DRONE_PULL_REQUEST", "BUILD_PULL_REQUEST_NUMBER")
70+
repoPR, repoPRFound := propertyGetter("BUILD_PULL_REQUEST_NUMBER")
7171
if !repoPRFound {
7272
logrus.Info("BUILD_PULL_REQUEST_NUMBER was missing, will not send report to PR comments")
7373
}
74-
repoOwner, repoOwnerFound := getActiveEnvVariable(propertyGetter, "DRONE_REPO_OWNER", "REPOSITORY_ORG")
74+
repoOwner, repoOwnerFound := propertyGetter("REPOSITORY_ORG")
7575
if !repoOwnerFound {
7676
logrus.Info("REPOSITORY_ORG was missing, will not send report to PR comments")
7777
}
78-
repoName, repoNameFound := getActiveEnvVariable(propertyGetter, "DRONE_REPO_NAME", "REPOSITORY_NAME")
78+
repoName, repoNameFound := propertyGetter("REPOSITORY_NAME")
7979
if !repoNameFound {
8080
logrus.Info("REPOSITORY_NAME was missing, will not send report to PR comments")
8181
}
@@ -89,15 +89,15 @@ func (*DefaultRunner) Run(propertyGetter func(string) (string, bool), changedSou
8989
return errors.Wrap(changedLinesErr, "Failed loading changed lines")
9090
}
9191

92-
debugStr, found := getActiveEnvVariable(propertyGetter, "PLUGIN_DEBUG", "PARAMETER_DEBUG")
92+
debugStr, found := propertyGetter("PARAMETER_DEBUG")
9393
if !found {
94-
logrus.Info("PLUGIN_DEBUG was missing defaulting to false")
94+
logrus.Info("PARAMETER_DEBUG was missing defaulting to false")
9595
debugStr = "false"
9696
}
9797

9898
debug, parseDebugErr := strconv.ParseBool(debugStr)
9999
if parseDebugErr != nil {
100-
logrus.Info("PLUGIN_DEBUG was invalid, defaulting to false")
100+
logrus.Info("PARAMETER_DEBUG was invalid, defaulting to false")
101101
debug = false
102102
}
103103

@@ -144,11 +144,3 @@ func getCoverageReportLoader(coverageType string, sourceDirs []string) (coverage
144144
}
145145

146146
}
147-
148-
func getActiveEnvVariable(propertyGetter func(string) (string, bool), droneVar, velaVar string) (string, bool) {
149-
value, droneVarFound := propertyGetter(droneVar)
150-
if !droneVarFound {
151-
return propertyGetter(velaVar)
152-
}
153-
return value, droneVarFound
154-
}

0 commit comments

Comments
 (0)