ci-util.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Licensed to the LF AI & Data foundation under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Exit immediately for non zero status
  18. set -e
  19. # Check unset variables
  20. set -u
  21. # Print commands
  22. set -x
  23. SOURCE="${BASH_SOURCE[0]}"
  24. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  25. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  26. SOURCE="$(readlink "$SOURCE")"
  27. [[ $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
  28. done
  29. ROOT="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
  30. # Install pytest requirements
  31. function install_pytest_requirements(){
  32. echo "Install pytest requirements"
  33. cd ${ROOT}/tests/python_client
  34. export PIP_TRUSTED_HOST="nexus-nexus-repository-manager.nexus"
  35. export PIP_INDEX_URL="http://nexus-nexus-repository-manager.nexus:8081/repository/pypi-all/simple"
  36. export PIP_INDEX="http://nexus-nexus-repository-manager.nexus:8081/repository/pypi-all/pypi"
  37. export PIP_FIND_LINKS="http://nexus-nexus-repository-manager.nexus:8081/repository/pypi-all/pypi"
  38. python3 -m pip install --no-cache-dir -r requirements.txt --timeout 300 --retries 6
  39. }
  40. # Login in ci docker registry
  41. function docker_login_ci_registry(){
  42. if [[ -z "${CI_REGISTRY_USERNAME:-}" || -z "${CI_REGISTRY_PASSWORD:-}" ]]; then
  43. echo "Please setup docker credential for ci registry-${HUB}"
  44. else
  45. echo "docker login ci registry"
  46. docker login -u ${CI_REGISTRY_USERNAME} -p ${CI_REGISTRY_PASSWORD} ${HUB}
  47. fi
  48. }