-
Notifications
You must be signed in to change notification settings - Fork 16
task CSI-2892/add community checks to operator #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 44 commits
f2952d0
9650ea5
58a46c1
135b96f
352247c
3ca3975
b267d6d
f9fdda3
218a95a
975fc66
362c38f
3bb0c93
89e065e
f3959c6
c57a0a6
4181fe0
466059a
aefc113
68c5583
5fd4b11
f58e6f4
ca18f57
bf9eac4
afdc338
4584130
0672ae8
7e9d305
88bd0a3
9386785
5eff30a
c0140d0
79bf3dc
c30c381
caef19d
219b1a2
28777cf
e52e5f9
8bf24e1
2f2a1bd
0b6a6b5
5f3c8dd
abff90b
1fcdb33
e4b57bf
75f4007
c0bd35d
d40871f
e9da769
3e2f6d2
c79479c
d4a0f6b
a13fab7
613014a
e25ec2b
7ff7b63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Community Operators test | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- master | ||
pull_request: | ||
branches: | ||
- develop | ||
- master | ||
jobs: | ||
operator_image_build: | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: "set env" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
outputs: | ||
operator_image_for_test: "ibmcom/ibm-block-csi-operator:latest" | ||
|
||
prepare_env: | ||
name: "prepare env" | ||
needs: operator_image_build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Setup dependencies | ||
run: | | ||
build/ci/community/setup_ci_dependencies.sh | ||
- name: Save dependencies files | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: gitconfig-file | ||
path: | | ||
/home/runner/.gitconfig | ||
/home/runner/.bash_profile | ||
retention-days: 1 | ||
- uses: FranzDiebold/github-env-vars-action@v2 | ||
- name: Prepare env | ||
id: environment_setup | ||
run: | | ||
build/ci/community/prepare_env.sh | ||
outputs: | ||
community_operators_path: "${{ steps.environment_setup.outputs.community_operators_path }}" | ||
upstream_community_operators_path: "${{ steps.environment_setup.outputs.upstream_community_operators_path }}" | ||
repository_path: "${{ steps.environment_setup.outputs.repository_path }}" | ||
operator_image_for_test: ${{ needs.operator_image_build.outputs.operator_image_for_test }} | ||
csv_file: ${{ steps.environment_setup.outputs.csv_file }} | ||
|
||
CI-csi-demo-pr: | ||
name: "community-operators fork checks" | ||
needs: prepare_env | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
env: | ||
forked_community_operators_repository: "csiblock/community-operators" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change the |
||
community_operators_kubernetes_branch: "ibm-block-csi-update-kubernetes-${{ github.run_number }}" | ||
community_operators_openshift_branch: "ibm-block-csi-update-openshift-${{ github.run_number }}" | ||
github_token: ${{ secrets.CSIBLOCK_GITHUB_TOKEN }} | ||
repository_path: ${{ needs.prepare_env.outputs.repository_path }} | ||
operator_image_for_test: ${{ needs.prepare_env.outputs.operator_image_for_test }} | ||
csv_file: ${{ needs.prepare_env.outputs.csv_file }} | ||
github_build_number: ${{ github.run_number }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Retrieve gitconfig file | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: gitconfig-file | ||
path: /home/runner | ||
- name: Create demo PR | ||
run: | | ||
build/ci/community/create_demo_pr.sh | ||
- name: Wait for all demo PR checks to finish | ||
run: | | ||
build/ci/community/wait_demo_pr_checks.sh | ||
- name: Assert all demo PR checks passed | ||
run: | | ||
build/ci/community/check_all_checks.sh | ||
- name: Clean demo PR | ||
if: always() | ||
run: | | ||
build/ci/community/clean_demo_pr.sh |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||
#!/bin/bash -xe | ||||||
set +o pipefail | ||||||
|
||||||
# CSI-3172 - run rad hat bot checks | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
|
||||||
did_all_checks_pass(){ | ||||||
community_operators_branch=$1 | ||||||
all_checks_passed=false | ||||||
if [ "$(gh pr checks $community_operators_branch --repo $forked_community_operators_repository | grep -iv pass | wc -l)" -eq 0 ] | ||||||
then | ||||||
all_checks_passed=true | ||||||
fi | ||||||
echo "$all_checks_passed" | ||||||
} | ||||||
|
||||||
passed_k8s_checks=$(did_all_checks_pass $community_operators_kubernetes_branch) | ||||||
passed_openshift_checks=$(did_all_checks_pass $community_operators_openshift_branch) | ||||||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
if [ $passed_k8s_checks == "false" ] || [ $passed_openshift_checks == "false" ] | ||||||
then | ||||||
echo "some test failed :(" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not clear which test failed (nor if more than 1 failed) |
||||||
exit 1 | ||||||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
print_checks_and_delete_pr(){ | ||
community_operators_branch=$1 | ||
cluster_kind=$2 | ||
repo_pr="gh pr list --repo $forked_community_operators_repository | grep $community_operators_branch" | ||
if [[ "`eval $repo_pr`" == *"$community_operators_branch"* ]]; then | ||
echo "The $cluster_kind checks:" | ||
gh pr checks $community_operators_branch --repo $forked_community_operators_repository || true | ||
gh pr close $community_operators_branch --delete-branch --repo $forked_community_operators_repository | ||
fi | ||
} | ||
|
||
print_checks_and_delete_pr $community_operators_kubernetes_branch 'kubernetes' | ||
print_checks_and_delete_pr $community_operators_openshift_branch 'openshift' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash -xel | ||
set +o pipefail | ||
|
||
cd $(dirname $csv_file) | ||
chmod 547 $(basename $csv_file) | ||
declare -a operator_image_fields=( | ||
".spec.install.spec.deployments[0].spec.template.spec.containers[0].image" | ||
".metadata.annotations.containerImage" | ||
".spec.relatedImages[0].image" | ||
) | ||
for image_field in "${operator_image_fields[@]}" | ||
do | ||
yq eval "$image_field |= env(operator_image_for_test)" $(basename $csv_file) -i | ||
done | ||
cd - | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo $github_token > github_token.txt | ||
gh auth login --with-token < github_token.txt | ||
gh repo fork operator-framework/community-operators --clone community-operators-fork | ||
cd community-operators-fork | ||
git remote set-url origin https://csiblock:[email protected]/csiblock/community-operators.git | ||
git fetch upstream | ||
git rebase upstream/master | ||
git push origin master --force | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this also be a function? with a name about whatever it does? something like fork_and_clone? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
create_demo_pr(){ | ||
community_operators_branch=$1 | ||
dest_path=$2 | ||
cluster_kind=$3 | ||
repo_pr="gh pr list --repo $forked_community_operators_repository | grep $community_operators_branch" | ||
if [[ "`eval $repo_pr`" == *"$community_operators_branch"* ]]; then | ||
gh pr close $community_operators_branch --delete-branch --repo $forked_community_operators_repository | ||
fi | ||
git checkout master | ||
git checkout -b $community_operators_branch | ||
yes | cp -r $repository_path/deploy/olm-catalog/ibm-block-csi-operator-community/ $dest_path | ||
git add . | ||
git commit --signoff -m "build number $github_build_number $cluster_kind" | ||
git push origin $community_operators_branch | ||
gh pr create --title "IBM Block CSI update $cluster_kind" --repo $forked_community_operators_repository --base master --head $community_operators_branch --body "pr check" | ||
} | ||
|
||
create_demo_pr $community_operators_kubernetes_branch "upstream-community-operators/" "kubernetes" | ||
create_demo_pr $community_operators_openshift_branch "community-operators/" "openshift" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash -xel | ||
set +o pipefail | ||
operator_package_file_path=deploy/olm-catalog/ibm-block-csi-operator/ibm-block-csi-operator.package.yaml | ||
csv_version=`yq eval .channels[0].currentCSV $operator_package_file_path` | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# CSI-3171 - handle non GA versions | ||
export csv_version=`echo ${csv_version//ibm-block-csi-operator.v}` | ||
export repository_path=~/work/$CI_REPOSITORY_NAME/$CI_REPOSITORY_NAME | ||
export csv_file=$repository_path/deploy/olm-catalog/ibm-block-csi-operator-community/$csv_version/manifests/ibm-block-csi-operator.v$csv_version.clusterserviceversion.yaml | ||
export upstream_community_operators_path=upstream-community-operators/ibm-block-csi-operator-community/$csv_version | ||
export community_operators_path=community-operators/ibm-block-csi-operator-community/$csv_version | ||
|
||
echo "::set-output name=upstream_community_operators_path::${upstream_community_operators_path}" | ||
echo "::set-output name=community_operators_path::${community_operators_path}" | ||
echo "::set-output name=repository_path::${repository_path}" | ||
echo "::set-output name=csv_file::${csv_file}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
echo $'yq() {\n docker run --rm -e operator_image_for_test=$operator_image_for_test -i -v "${PWD}":/workdir mikefarah/yq:4 "$@"\n}' >> /home/runner/.bash_profile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please apply conversations from other PRs where applicable |
||
|
||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install gh | ||
|
||
git config --global user.email [email protected] | ||
git config --global user.name csiblock |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,30 @@ | ||||||
#!/bin/bash -xe | ||||||
set +o pipefail | ||||||
|
||||||
gh_pr_checks_command (){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we run the command, I suggest naming the function accordingly:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From this article:
Thus, I suggest using a verb. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with the article, though I think in this case, the function is being used more like a command alias than a function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matancarmeli7 let's use |
||||||
community_operators_branch=$1 | ||||||
gh pr checks $community_operators_branch --repo $forked_community_operators_repository | ||||||
} | ||||||
|
||||||
wait_fot_checks_to_start(){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is there no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the filename wasn't changed |
||||||
community_operators_branch=$1 | ||||||
forked_community_operators_repository=$2 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this necessary for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed it, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if both are passed, then I think their name inside the |
||||||
while [ `gh_pr_checks_command $community_operators_branch | wc -l` -eq 0 ]; do | ||||||
sleep 1 | ||||||
done | ||||||
} | ||||||
wait_for_checks_to_complete(){ | ||||||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to have a single line break between functions? what is the convention here? |
||||||
community_operators_branch=$1 | ||||||
all_tests_passed=false | ||||||
repo_pr=`gh pr list --repo $forked_community_operators_repository | grep $community_operators_branch` | ||||||
if [[ "$repo_pr" == *"$community_operators_branch"* ]]; then | ||||||
wait_fot_checks_to_start $community_operators_branch $forked_community_operators_repository | ||||||
test_summary="gh_pr_checks_command $community_operators_branch | grep -i summary" | ||||||
while [[ ! "`eval $test_summary`" =~ "pass" ]] && [[ ! "`eval $test_summary`" =~ "fail" ]]; do | ||||||
sleep 1 | ||||||
done | ||||||
fi | ||||||
} | ||||||
|
||||||
wait_for_checks_to_complete $community_operators_kubernetes_branch | ||||||
wait_for_checks_to_complete $community_operators_openshift_branch |
Uh oh!
There was an error while loading. Please reload this page.