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:
Andreas Fleig 2023-06-20 19:46:30 +02:00 committed by GitHub
parent cb242ae89c
commit 7cd39d14e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,4 @@
#!/bin/bash
# Copyright 2018 Google LLC
#
# 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.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Ignore these paths in the following tests.
ignore="vendor\|out"
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.
set +e
files=$(python ${BOILERPLATEDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BOILERPLATEDIR} | grep -v $ignore)
relevant_files=$(echo "$files" | grep -v $ignore)
set -e
if [[ ! -z ${files} ]]; then
if [[ ! -z ${relevant_files} ]]; then
echo "Boilerplate missing in:"
echo "${files}"
echo "${relevant_files}"
exit 1
fi

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2018 Google LLC
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright YEAR Google LLC
#