github.com/RedHatInsights/insights-content-service@v1.0.0/pr_check.sh (about)

     1  #!/bin/bash
     2  # Copyright 2022 Red Hat, Inc
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #      http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -exv
    17  
    18  
    19  # --------------------------------------------
    20  # Options that must be configured by app owner
    21  # --------------------------------------------
    22  APP_NAME="ccx-data-pipeline"  #  name of app-sre "application" folder this component lives in
    23  REF_ENV="insights-production"
    24  COMPONENT_NAME="insights-content-service"  # name of app-sre "resourceTemplate" in deploy.yaml for this component
    25  IMAGE="quay.io/cloudservices/ccx-insights-content-service"
    26  COMPONENTS="ccx-data-pipeline ccx-insights-results insights-content-service insights-results-smart-proxy ocp-advisor-frontend ccx-mock-ams" # space-separated list of components to laod
    27  COMPONENTS_W_RESOURCES="insights-content-service"  # component to keep
    28  CACHE_FROM_LATEST_IMAGE="true"
    29  DEPLOY_FRONTENDS="true"   # enable for front-end/UI tests
    30  
    31  export IQE_PLUGINS="ccx"
    32  # Run all pipeline and ui tests
    33  export IQE_MARKER_EXPRESSION="pipeline or (core and ui)"
    34  # Skip fuzz_api_v1/fuzz_api_v2 tests. The take long and not much useful for PR.
    35  export IQE_FILTER_EXPRESSION="not test_fuzz"
    36  export IQE_REQUIREMENTS_PRIORITY=""
    37  export IQE_TEST_IMPORTANCE=""
    38  export IQE_CJI_TIMEOUT="30m"
    39  export IQE_SELENIUM="true"  # Required for UI tests
    40  export IQE_ENV="ephemeral"
    41  
    42  
    43  changes_including_ocp_rules_version() {
    44      git log -1 HEAD . | grep "Bumped ccx-rules-ocp version"
    45  }
    46  
    47  create_junit_dummy_result() {
    48      mkdir -p 'artifacts'
    49  
    50      cat <<- EOF > 'artifacts/junit-dummy.xml'
    51  	<?xml version="1.0" encoding="UTF-8"?>
    52  	<testsuite tests="1">
    53  	    <testcase classname="dummy" name="dummy-empty-test"/>
    54  	</testsuite>
    55  	EOF
    56  }
    57  
    58  function build_image() {
    59      source $CICD_ROOT/build.sh
    60  }
    61  
    62  function deploy_ephemeral() {
    63      source $CICD_ROOT/deploy_ephemeral_env.sh
    64  }
    65  
    66  function run_smoke_tests() {
    67      # component name needs to be re-export to match ClowdApp name (as bonfire requires for this)
    68      export COMPONENT_NAME="ccx-insights-content"
    69      source $CICD_ROOT/cji_smoke_test.sh
    70      source $CICD_ROOT/post_test_results.sh  # publish results in Ibutsu
    71  }
    72  
    73  
    74  # for ccx-rules-ocp version bump PRs skip pr_check.sh tests.
    75  if changes_including_ocp_rules_version; then
    76      echo "Only ccx-rules-ocp version bump, exiting"
    77      create_junit_dummy_result
    78      exit 0
    79  fi
    80  
    81  # Install bonfire repo/initialize
    82  CICD_URL=https://raw.githubusercontent.com/RedHatInsights/bonfire/master/cicd
    83  curl -s $CICD_URL/bootstrap.sh > .cicd_bootstrap.sh && source .cicd_bootstrap.sh
    84  echo "creating PR image"
    85  build_image
    86  
    87  echo "deploying to ephemeral"
    88  deploy_ephemeral
    89  
    90  echo "running PR smoke tests"
    91  run_smoke_tests