forked from ansible/ansible-hub-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pr_check.sh
executable file
·96 lines (79 loc) · 3.91 KB
/
pr_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# --------------------------------------------
# Export vars for helper scripts to use
# --------------------------------------------
# name of app-sre "application" folder this component lives in; needs to match for quay
export COMPONENT="automation-hub"
export WORKSPACE=${WORKSPACE:-$APP_ROOT} # if running in jenkins, use the build's workspace
export APP_ROOT=$(pwd)
COMMON_BUILDER=https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master
export NODE_BUILD_VERSION=16
export APP_NAME="automation-hub" # name of app-sre "application" folder this component lives in
export COMPONENT_NAME="automation-hub" # name of app-sre "resourceTemplate" in deploy.yaml for this component
export COMPONENTS_W_RESOURCES="all" # components which should preserve resource settings (optional, default: none)
export IMAGE_FRONTEND="quay.io/cloudservices/ansible-hub-ui"
export IMAGE_FRONTEND_TAG=$(git rev-parse --short=7 HEAD)
export IMAGE_FRONTEND_SHA1=$(git rev-parse HEAD)
export IMAGE=${IMAGE_FRONTEND}
export IMAGE_BACKEND="quay.io/cloudservices/automation-hub-galaxy-ng"
export IMAGE_BACKEND_TAG=$(curl -s https://api.github.com/repos/ansible/galaxy_ng/commits/master | jq -r '.sha' | head -c7)
export BACKUP_APP_ROOT=$APP_ROOT
set -exv
# source is preferred to | bash -s in this case to avoid a subshell
source <(curl -sSL $COMMON_BUILDER/src/frontend-build.sh)
BUILD_RESULTS=$?
export IMAGE_FRONTEND_TAG=${IMAGE_TAG}
# install bonfire repo/initialize
CICD_URL=https://raw.githubusercontent.com/RedHatInsights/bonfire/master/cicd
curl -s "$CICD_URL/bootstrap.sh" > .cicd_bootstrap.sh
source .cicd_bootstrap.sh
source ${CICD_ROOT}/_common_deploy_logic.sh
# deploy to ephemeral
export NAMESPACE=$(bonfire namespace reserve)
bonfire deploy \
${APP_NAME} \
--source=appsre \
--ref-env insights-stage \
--set-template-ref ${COMPONENT_NAME}=master \
--set-image-tag ${IMAGE_BACKEND}=${IMAGE_BACKEND_TAG} \
--set-image-tag ${IMAGE_FRONTEND}=${IMAGE_FRONTEND_TAG} \
--set-template-ref automation-hub-frontend=${IMAGE_FRONTEND_SHA1} \
--frontends=true \
--namespace ${NAMESPACE} \
--timeout ${DEPLOY_TIMEOUT} \
${COMPONENTS_ARG} \
${COMPONENTS_RESOURCES_ARG} \
--set-parameter ${COMPONENT_NAME}/IMPORTER_JOB_NAMESPACE=${NAMESPACE}
# configure ephemeral environment
git clone https://github.com/ansible/galaxy_ng.git
cd galaxy_ng
oc project ${NAMESPACE}
echo "patching CONTENT_ORIGIN"
CONTENT_ORIGIN=$(oc get route -l frontend=automation-hub -o jsonpath='https://{.items[0].spec.host}')
oc patch clowdapp automation-hub --type=json -p '[{"op": "replace", "path": "/spec/deployments/1/podSpec/env/1/value", "value": "'"${CONTENT_ORIGIN}"'"}]'
sleep 5
oc rollout status deploy/automation-hub-galaxy-api
echo "patching PULP_AWS_S3_ENDPOINT_URL"
oc create route edge minio --service=env-${NAMESPACE}-minio --insecure-policy=Redirect
MINIO_ROUTE=$(oc get route minio -o jsonpath='https://{.spec.host}{"\n"}')
oc patch clowdapp automation-hub --type=json -p '[{"op": "add", "path": "/spec/deployments/2/podSpec/env/-", "value": {"name": "PULP_AWS_S3_ENDPOINT_URL", "value": "'"${MINIO_ROUTE}"'"}}]'
sleep 5
oc rollout status deploy/automation-hub-pulp-content-app
echo "Get pod names"
AH_API_POD=$(oc get pod -l pod=automation-hub-galaxy-api -o jsonpath='{.items[0].metadata.name}')
DB_POD=$(oc get pod -l service=db -o jsonpath='{.items[0].metadata.name}')
echo "Creating admin user and data used for tests: i.e. namespaces, groups, users, tokens"
oc exec $AH_API_POD -c automation-hub-galaxy-api -i -- /entrypoint.sh manage shell < dev/common/setup_test_data.py
cd ..
# end configuring ephemeral
# smoke tests
#source dev/ephemeral/smoke_test.sh
# Stubbed out for now, will be added as tests are enabled
mkdir -p $WORKSPACE/artifacts
cat << EOF > $WORKSPACE/artifacts/junit-dummy.xml
<testsuite tests="1">
<testcase classname="dummy" name="dummytest"/>
</testsuite>
EOF
# teardown_docker
exit $BUILD_RESULTS