hack/boilerplate.sh: fix error handling and use python3 (#2587)
* hack/boilerplate.sh: fix successful return code when call to python fails * hack/boilerplate.sh: update to python3 python2 is no longer included in most distros and will be removed from Github Actions Ubuntu images: https://github.com/actions/runner-images/issues/7402
This commit is contained in:
parent
cb242ae89c
commit
7cd39d14e3
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Copyright 2018 Google LLC
|
# Copyright 2018 Google LLC
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -13,16 +12,20 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
set -e
|
||||||
|
|
||||||
# Ignore these paths in the following tests.
|
# Ignore these paths in the following tests.
|
||||||
ignore="vendor\|out"
|
ignore="vendor\|out"
|
||||||
BOILERPLATEDIR=./hack/boilerplate
|
BOILERPLATEDIR=./hack/boilerplate
|
||||||
|
files=$(python3 ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR})
|
||||||
|
|
||||||
# Grep returns a non-zero exit code if we don't match anything, which is good in this case.
|
# Grep returns a non-zero exit code if we don't match anything, which is good in this case.
|
||||||
set +e
|
set +e
|
||||||
files=$(python ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore)
|
relevant_files=$(echo "$files" | grep -v $ignore)
|
||||||
set -e
|
set -e
|
||||||
if [[ ! -z ${files} ]]; then
|
|
||||||
|
if [[ ! -z ${relevant_files} ]]; then
|
||||||
echo "Boilerplate missing in:"
|
echo "Boilerplate missing in:"
|
||||||
echo "${files}"
|
echo "${relevant_files}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright 2018 Google LLC
|
# Copyright 2018 Google LLC
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Copyright YEAR Google LLC
|
# Copyright YEAR Google LLC
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue