mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Consolidate scripts into k8s-traditional hack dir.
This commit is contained in:
95
hack/Invoke-PreCommit.ps1
Normal file
95
hack/Invoke-PreCommit.ps1
Normal file
@@ -0,0 +1,95 @@
|
||||
<#
|
||||
|
||||
Please reference this document:
|
||||
/docs/howtowindows.md
|
||||
|
||||
#>
|
||||
|
||||
#####################################################################################
|
||||
# Start of process
|
||||
#####################################################################################
|
||||
# stop on any error
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
|
||||
Push-Location
|
||||
|
||||
try{
|
||||
$scriptPath = $MyInvocation.MyCommand.Path
|
||||
Write-Host "Script Root: $scriptPath"
|
||||
$baseDir = Split-Path (Split-Path $scriptPath -Parent) -Parent
|
||||
Write-Host "Changing Directory: $baseDir"
|
||||
|
||||
Set-Location $baseDir
|
||||
|
||||
$rc = $false
|
||||
|
||||
function Test-GoLangCILint {
|
||||
golangci-lint -v run ./...
|
||||
}
|
||||
|
||||
function Test-GoTest {
|
||||
go test -v ./...
|
||||
}
|
||||
|
||||
function Test-Examples {
|
||||
mdrip --mode test --label test README.md ./examples
|
||||
}
|
||||
|
||||
# unfortunately because go test hides output in windows if we try to call it
|
||||
# using Invoke-Express ( calling the function dynamically )
|
||||
# we have to call them in-line here instead of using a function
|
||||
|
||||
Write-Host "============== begin Test-GoLangCILint"
|
||||
Test-GoLangCILint
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$lint = 0
|
||||
$result = "SUCCESS"
|
||||
} else {
|
||||
$lint = 1
|
||||
$result = "FAILURE"
|
||||
}
|
||||
Write-Host ("============== end Test-GoLangCILint : {0} code={1}`n`n`n" -f $result, $lint)
|
||||
|
||||
|
||||
Write-Host "============== begin Test-GoTest"
|
||||
Test-GoTest
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$tests = 0
|
||||
$result = "SUCCESS"
|
||||
} else {
|
||||
$tests = 1
|
||||
$result = "FAILURE"
|
||||
}
|
||||
Write-Host ("============== end Test-GoTest : {0} code={1}`n`n`n" -f $result, $tests)
|
||||
|
||||
|
||||
Write-Host "============== skipping Test-Examples for Windows Testing "
|
||||
|
||||
#Write-Host "============== begin Test-Examples"
|
||||
#Test-Examples
|
||||
#if ($LASTEXITCODE -eq 0) {
|
||||
# $examples = 0
|
||||
# $result = "SUCCESS"
|
||||
#} else {
|
||||
# $examples = 1
|
||||
# $result = "FAILURE"
|
||||
#}
|
||||
#Write-Host ("============== end Test-Examples : {0} code={1}`n`n`n" -f $result, $examples)
|
||||
|
||||
#calc final return code
|
||||
#$rc = $lint -AND $tests -AND $examples
|
||||
|
||||
#calc final return code - omit mdrip testing
|
||||
$rc = $lint -AND $tests
|
||||
|
||||
Pop-Location
|
||||
|
||||
Exit $rc
|
||||
|
||||
} catch {
|
||||
Write-Host "Error: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
22
hack/check-go-mod.sh
Executable file
22
hack/check-go-mod.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# verify all modules pass validation
|
||||
for i in $(find . -name go.mod); do
|
||||
pushd .
|
||||
cd $(dirname $i);
|
||||
go list -m -json all > /dev/null
|
||||
go mod tidy -v
|
||||
popd
|
||||
done
|
||||
|
||||
# Need better check. This is repeated git diff check
|
||||
# more pain than benefit for most people 25Apr2020
|
||||
## verify no changes to go.mods -- these should be part of the PR
|
||||
# find . -name go.sum | xargs git checkout --
|
||||
# git add .
|
||||
# git diff-index HEAD --exit-code
|
||||
23
hack/check-multi-module.sh
Executable file
23
hack/check-multi-module.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [[ "$PULL_NUMBER" -ne "" ]]; then
|
||||
cmd="$MYGOBIN/prchecker
|
||||
-owner=$REPO_OWNER
|
||||
-repo=$REPO_NAME
|
||||
-pr=$PULL_NUMBER
|
||||
$MODULES"
|
||||
|
||||
|
||||
echo $MYGOBIN
|
||||
echo $REPO_OWNER
|
||||
echo $REPO_NAME
|
||||
echo $PULL_NUMBER
|
||||
echo $MODULES
|
||||
eval $cmd
|
||||
else
|
||||
echo "Multi-module check skipped. No PULL_NUMBER provided.
|
||||
|
||||
To run this check locally set PULL_NUMBER to the PR ID from GitHub."
|
||||
fi
|
||||
40
hack/kyaml-pre-commit.sh
Executable file
40
hack/kyaml-pre-commit.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -e
|
||||
|
||||
# run all tests for kyaml and related commands
|
||||
|
||||
targets="
|
||||
kyaml
|
||||
cmd/config
|
||||
functions/examples/injection-tshirt-sizes
|
||||
functions/examples/template-go-nginx
|
||||
functions/examples/template-heredoc-cockroachdb
|
||||
functions/examples/validator-kubeval
|
||||
functions/examples/validator-resource-requests
|
||||
functions/examples/application-cr
|
||||
"
|
||||
|
||||
# don't run e2e tests in CI by default
|
||||
export KUSTOMIZE_DOCKER_E2E=${KUSTOMIZE_DOCKER_E2E:-"false"}
|
||||
|
||||
for target in $targets; do
|
||||
echo " "
|
||||
echo " "
|
||||
echo "----- Making $target -----"
|
||||
pushd .
|
||||
cd $target
|
||||
make all
|
||||
popd
|
||||
done
|
||||
|
||||
# Need better check. This is repeated git diff check
|
||||
# more pain than benefit for most people 25Apr2020
|
||||
## make sure no files were generated or changed by make
|
||||
## ignore changes to go.mod and go.sum -- they are too flaky
|
||||
# find . -name go.mod | xargs git checkout --
|
||||
# find . -name go.sum | xargs git checkout --
|
||||
# git add .
|
||||
# git diff-index HEAD --exit-code
|
||||
Reference in New Issue
Block a user