зеркало из https://github.com/Azure/aks-engine.git
ci: use diff instead of git diff for the CI validation checks of the generated files (#491)
* use diff instead of git diff for the CI validation checks of the generated files * copy only generated files to diff
This commit is contained in:
Родитель
7a02bd43b7
Коммит
242035c7f2
4
Makefile
4
Makefile
|
@ -126,9 +126,9 @@ test-style:
|
|||
@scripts/validate-go.sh
|
||||
|
||||
.PHONY: validate-generated
|
||||
validate-generated: generate
|
||||
validate-generated:
|
||||
@echo "==> Checking generated files <=="
|
||||
! git diff --name-only pkg/ | grep _generated.go
|
||||
@scripts/validate-generated.sh
|
||||
|
||||
.PHONY: test-e2e
|
||||
test-e2e:
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
####################################################
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
ROOT="${DIR}/.."
|
||||
####################################################
|
||||
|
||||
set -x
|
||||
|
||||
GENERATED_FILES=(
|
||||
"pkg/i18n/translations_generated.go"
|
||||
"pkg/engine/templates_generated.go"
|
||||
)
|
||||
|
||||
T="$(mktemp -d)"
|
||||
trap "rm -rf ${T}" EXIT
|
||||
|
||||
for file in ${GENERATED_FILES[*]}; do
|
||||
cp -a "${file}" "${T}/"
|
||||
done
|
||||
|
||||
(go generate ../...)
|
||||
|
||||
for file in ${GENERATED_FILES[*]}; do
|
||||
basefile="$(basename ${file})"
|
||||
if ! diff -r "${T}/${basefile}" "${ROOT}/${file}" 2>&1 ; then
|
||||
echo "go generate produced changes that were not already present."
|
||||
echo "Make sure you include generated assets in your commit."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Generated assets have no material difference than what is committed."
|
Загрузка…
Ссылка в новой задаче