diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 85c21ba8c..0a2f0ae89 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -17,17 +17,22 @@ steps: set -o errexit set -o xtrace - bazel build --host_force_python=PY2 //package_manager:dpkg_parser.par + # Make sure python points to python3 + # perhaps the gcr.io/cloud-marketplace-containers/google/bazel image + # should be doing this though + update-alternatives --install /usr/bin/python python /usr/bin/python3 0 + + bazel build //package_manager:dpkg_parser.par # Optional: trigger building package bundles without concurrency to avoid # flakiness: https://github.com/GoogleContainerTools/distroless/issues/646 - bazel build --jobs=1 --host_force_python=PY2 @package_bundle_amd64_debian10//file:packages.bzl - bazel build --jobs=1 --host_force_python=PY2 @package_bundle_arm_debian10//file:packages.bzl - bazel build --jobs=1 --host_force_python=PY2 @package_bundle_arm64_debian10//file:packages.bzl - bazel build --jobs=1 --host_force_python=PY2 @package_bundle_s390x_debian10//file:packages.bzl - bazel build --jobs=1 --host_force_python=PY2 @package_bundle_ppc64le_debian10//file:packages.bzl + bazel build --jobs=1 @package_bundle_amd64_debian10//file:packages.bzl + bazel build --jobs=1 @package_bundle_arm_debian10//file:packages.bzl + bazel build --jobs=1 @package_bundle_arm64_debian10//file:packages.bzl + bazel build --jobs=1 @package_bundle_s390x_debian10//file:packages.bzl + bazel build --jobs=1 @package_bundle_ppc64le_debian10//file:packages.bzl - bazel run --host_force_python=PY2 //:publish + bazel run //:publish - name: docker env: diff --git a/package_manager/version_utils.py b/package_manager/version_utils.py index 6cddde101..cb96926a9 100644 --- a/package_manager/version_utils.py +++ b/package_manager/version_utils.py @@ -27,11 +27,11 @@ def get_epoch(version_str): try: epoch = int(version_str[0:e_index]) - except ValueError: + except ValueError as value_error: raise Exception( 'Corrupt dpkg version %s: epochs can only be ints, and ' 'epochless versions cannot use the colon character.' % - version_str) + version_str) from value_error return epoch, version_str[e_index + 1:] diff --git a/test.sh b/test.sh index bc7e23c21..dab69da84 100755 --- a/test.sh +++ b/test.sh @@ -21,17 +21,26 @@ set -o xtrace buildifier -mode=fix $(find . -name 'BUILD*' -o -name 'WORKSPACE*' -o -name '*.bzl' -type f) find . -name "*.py" | xargs pylint --disable=R,C +# Make sure python points to python3 +PYTHON_VERSION=$(python --version) +if [[ ! $PYTHON_VERSION == Python\ 3* ]]; +then + echo "python must point to a python3, currently points to $(readlink -f "$(which python)")" + echo "maybe run: update-alternatives --install /usr/bin/python python /usr/bin/python3" + exit 1 +fi + # Bazel build and test bazel clean --curses=no bazel build --curses=no //package_manager:dpkg_parser.par # Optional: trigger building package bundles without concurrency to avoid # flakiness: https://github.com/GoogleContainerTools/distroless/issues/646 -bazel build --jobs=1 --host_force_python=PY2 @package_bundle_amd64_debian10//file:packages.bzl -bazel build --jobs=1 --host_force_python=PY2 @package_bundle_arm_debian10//file:packages.bzl -bazel build --jobs=1 --host_force_python=PY2 @package_bundle_arm64_debian10//file:packages.bzl -bazel build --jobs=1 --host_force_python=PY2 @package_bundle_s390x_debian10//file:packages.bzl -bazel build --jobs=1 --host_force_python=PY2 @package_bundle_ppc64le_debian10//file:packages.bzl +bazel build --jobs=1 @package_bundle_amd64_debian10//file:packages.bzl +bazel build --jobs=1 @package_bundle_arm_debian10//file:packages.bzl +bazel build --jobs=1 @package_bundle_arm64_debian10//file:packages.bzl +bazel build --jobs=1 @package_bundle_s390x_debian10//file:packages.bzl +bazel build --jobs=1 @package_bundle_ppc64le_debian10//file:packages.bzl bazel build --curses=no //... # Run all tests not tagged as "manual"