ci-util-4am.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. # MIRROR_HOST="${MIRROR_HOST:-nexus-nexus-repository-manager.nexus}"
  35. export PIP_TRUSTED_HOST="nexus-ci.zilliz.cc"
  36. export PIP_INDEX_URL="https://nexus-ci.zilliz.cc/repository/pypi-all/simple"
  37. export PIP_INDEX="https://nexus-ci.zilliz.cc/repository/pypi-all/pypi"
  38. export PIP_FIND_LINKS="https://nexus-ci.zilliz.cc/repository/pypi-all/pypi"
  39. python3 -m pip install --no-cache-dir -r requirements.txt --timeout 30 --retries 6
  40. }
  41. # Login in ci docker registry
  42. function docker_login_ci_registry(){
  43. if [[ -z "${CI_REGISTRY_USERNAME:-}" || -z "${CI_REGISTRY_PASSWORD:-}" ]]; then
  44. echo "Please setup docker credential for ci registry-${HUB}"
  45. else
  46. echo "docker login ci registry"
  47. docker login -u ${CI_REGISTRY_USERNAME} -p ${CI_REGISTRY_PASSWORD} ${HUB}
  48. fi
  49. }