diff --git a/init.ps1 b/init.ps1 index 6726277e..29a7fcb9 100644 --- a/init.ps1 +++ b/init.ps1 @@ -51,7 +51,7 @@ Param( [switch]$down ) function execScript($name) { - $scriptsDir = "$(join-path scripts ps)" + $scriptsDir = "$(Join-Path scripts ps)" & "$(Join-Path $scriptsDir $name)" } diff --git a/scripts/check_deps.sh b/scripts/check_deps.sh index e9c4156f..0d5a2d08 100755 --- a/scripts/check_deps.sh +++ b/scripts/check_deps.sh @@ -14,7 +14,7 @@ set -xeuo pipefail git remote set-branches --add origin master && git fetch ChangedFiles=`git diff --name-only origin/master` -# in the casse that ChangedFiles contains go.mod or go.sum run go mod verify +# in the case that ChangedFiles contains go.mod or go.sum run go mod verify case "$ChangedFiles" in go.mod | go.sum) go mod verify diff --git a/scripts/ps/check_deps.ps1 b/scripts/ps/check_deps.ps1 new file mode 100644 index 00000000..d718fee1 --- /dev/null +++ b/scripts/ps/check_deps.ps1 @@ -0,0 +1,17 @@ +# check_deps.ps1 +# this script checks for changes to the files go.mod and go.sum +# +# this is intended to be used in your CI tests +# +# on encountering any changes for these files the script runs go mod verify +# to check for any conflicts in versions or digests +# which on any exit code > 0 would suggest that action should be taken +# before a pull request can be merged. +git remote set-branches --add origin master ; git fetch +$ChangedFiles=$(git diff --name-only origin/master) + +# in the case that ChangedFiles contains go.mod or go.sum run go mod verify +$contains= $ChangedFiles | Select-String -Pattern "go.mod|go.sum" +if ($contains.length -gt 0) { + Write-Error $(go mod verify) +} \ No newline at end of file diff --git a/scripts/ps/check_gofmt.ps1 b/scripts/ps/check_gofmt.ps1 index 909a1374..972fd4d3 100755 --- a/scripts/ps/check_gofmt.ps1 +++ b/scripts/ps/check_gofmt.ps1 @@ -1,6 +1,6 @@ # check_gofmt.ps1 # Fail if a .go file hasn't been formatted with gofmt -$GO_FILES = Get-ChildItem -Recurse -Filter *.go -Name | Select-String -Pattern $(Join-Path "vendor" | Join-Path -ChildPath "") -NotMatch +$GO_FILES = Get-ChildItem -Recurse -Filter *.go -Name | Select-String -Pattern $(Join-Path "vendor" -ChildPath ".*") -NotMatch $out = & gofmt -s -l $GO_FILES if ($out.length -gt 0) { Write-Error $out