-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathverify_release_build.sh
More file actions
executable file
·151 lines (131 loc) · 6 KB
/
verify_release_build.sh
File metadata and controls
executable file
·151 lines (131 loc) · 6 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script helps to verify full life cycle of Gradle build and all
# PostCommit tests against release branch on Jenkins.
#
# It reads configurations from script.config, setup environment and finally
# create a test PR to run Jenkins jobs.
#
# NOTE:
# 1. Please create a personal access token from your Github account first.
# Instructions: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
# 2. Please set RELEASE_BUILD_CONFIGS in script.config before running this
# script.
# 3. Please manually start "Release Nightly Snapshot" GHA workflow on the
# release branch to start Gradle release build.
. script.config
set -e
BEAM_REPO_URL=https://github.com/apache/beam.git
RELEASE_BRANCH="release-$(cut -d '.' -f 1,2 <<< $RELEASE_VER)"
WORKING_BRANCH=postcommit_validation_pr
SCRIPT=$(readlink -f $0)
SCRIPT_DIR=$(dirname $SCRIPT)
function clean_up(){
echo ""
echo "==================== Final Cleanup ===================="
rm -rf ${LOCAL_BEAM_DIR}
echo "* Deleted workspace ${LOCAL_BEAM_DIR}"
}
trap clean_up EXIT
echo ""
echo "==================== 1 Checking Environment Variables ================="
echo "* PLEASE update RELEASE_BUILD_CONFIGS in file script.config first *"
echo ""
echo "Verify release build against branch: ${RELEASE_BRANCH}."
echo "Use workspace: ${LOCAL_BEAM_DIR}"
echo ""
echo "All environment and workflow configurations from RELEASE_BUILD_CONFIGS:"
for i in "${RELEASE_BUILD_CONFIGS[@]}"; do
echo "$i = ${!i}"
done
echo "[Confirmation Required] Are they all provided and correctly set? [y|N]"
read confirmation
if [[ $confirmation != "y" ]]; then
echo "Please rerun this script and make sure you have the right configurations."
exit
fi
echo ""
echo "==================== 2 Checking Requirements ======================="
echo "====================== 2.1 Checking git ========================"
if [[ -z ${GITHUB_TOKEN} ]]; then
echo "Error: A Github personal access token is required to perform git push "
echo "under a newly cloned directory. Please manually create one from Github "
echo "website with guide:"
echo "https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line"
echo "Note: This token can be reused in other release scripts."
exit
else
echo "====================== Cloning repo ======================"
git clone ${BEAM_REPO_URL} ${LOCAL_BEAM_DIR}
cd ${LOCAL_BEAM_DIR}
# Set upstream repo url with access token included.
USER_REPO_URL=https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_USERNAME}/beam.git
git remote add ${GITHUB_USERNAME} ${USER_REPO_URL}
# For hub access Github API.
export GITHUB_TOKEN=${GITHUB_TOKEN}
# For local git repo only. Required if global configs are not set.
git config user.name "${GITHUB_USERNAME}"
git config user.email "${GITHUB_USERNAME}@gmail.com"
fi
echo "====================== 2.2 Checking hub ========================"
HUB_VERSION=2.12.0
if [[ "$(uname)" == "Linux" ]]; then
ARCITECTURE=linux-amd64
elif [[ "$(uname)" == "Darwin" ]]; then
ARCITECTURE=darwin-amd64
else
echo "Error: unsupported architecture for Hub"
exit
fi
HUB_ARTIFACTS_NAME=hub-${ARCITECTURE}-${HUB_VERSION}
if [[ -z `which hub` ]]; then
echo "There is no hub installed on your machine."
if [[ "${INSTALL_HUB}" = true ]]; then
echo "====================== Installing hub ======================="
wget https://github.com/github/hub/releases/download/v${HUB_VERSION}/${HUB_ARTIFACTS_NAME}.tgz
tar zvxvf ${HUB_ARTIFACTS_NAME}.tgz
sudo ./${HUB_ARTIFACTS_NAME}/install
echo "eval "$(hub alias -s)"" >> ~/.bashrc
rm -rf ${HUB_ARTIFACTS_NAME}*
else
echo "Refused to install hub. Cannot proceed into next setp."; exit
fi
fi
hub version
echo ""
echo "==================== 3 Run PostCommit Tests on Jenkins ==================="
echo "[Current Task] Run all PostCommit Tests against Release Branch on Jenkins."
echo "This task will create a PR against apache/beam."
echo "After PR created, you need to comment phrases listed in description in the created PR:"
if [[ ! -z `which hub` ]]; then
git checkout -b ${WORKING_BRANCH} origin/${RELEASE_BRANCH} --quiet
# The version change is needed for Dataflow python batch tests.
# Without changing to dev version, the dataflow pipeline will fail because of non-existed worker containers.
# Note that dataflow worker containers should be built after RC has been built.
bash "$SCRIPT_DIR"/set_version.sh "$RELEASE_VER" --git-add
# add a file that will trigger all relevant GHA workflows. Need to be .json extension to be excluded from RAT check
echo "{}" > release/trigger_all_tests.json
git add release/trigger_all_tests.json
git commit -m "Changed version.py and gradle.properties to python dev version to create a test PR" --quiet
git push -f ${GITHUB_USERNAME} ${WORKING_BRANCH} --quiet
hub pull-request -b apache:${RELEASE_BRANCH} -h ${GITHUB_USERNAME}:${WORKING_BRANCH} -F- <<<"[DO NOT MERGE] Run all PostCommit and PreCommit Tests against Release Branch
Tests run on GHA should be queued shortly."
echo ""
echo "[NOTE]: Please make sure all test targets (GHA) have been invoked."
echo "Please check the test results. If there is any failure, follow the policy in release guide."
fi