-
Notifications
You must be signed in to change notification settings - Fork 14
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 all 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,91 @@ | ||
| name: Community Operators test | ||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| - master | ||
| pull_request: | ||
| branches: | ||
| - develop | ||
| - master | ||
| jobs: | ||
| operator_image_build: | ||
|
oriyarde marked this conversation as 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 | ||
| id: 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: | ||
| image_branch_tag: "${{ steps.setup_dependencies.outputs.image_branch_tag }}" | ||
| 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: | ||
| original_community_operators_repository: "k8s-operatorhub/community-operators" | ||
| original_community_operators_repository_prod: "redhat-openshift-ecosystem/community-operators-prod" | ||
| forked_community_operators_repository: "csiblock/community-operators" | ||
|
Contributor
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 |
||
| forked_community_operators_repository_prod: "csiblock/community-operators-prod" | ||
| 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 }} | ||
| latest_operator_version: ${{ needs.prepare_env.outputs.image_branch_tag }} | ||
| 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,24 @@ | ||
| #!/bin/bash -xe | ||
| set +o pipefail | ||
|
|
||
| # CSI-3172 - run Red Hat bot checks | ||
|
|
||
| did_all_checks_pass(){ | ||
| community_operators_branch=$1 | ||
| forked_repository=$2 | ||
| all_checks_passed=false | ||
| if [ "$(gh pr checks $community_operators_branch --repo $forked_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 $forked_community_operators_repository) | ||
| passed_openshift_checks=$(did_all_checks_pass $community_operators_openshift_branch $forked_community_operators_repository_prod) | ||
|
|
||
| if [ $passed_k8s_checks == "false" ] || [ $passed_openshift_checks == "false" ] | ||
| then | ||
| echo "some test failed :(" | ||
|
Contributor
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,17 @@ | ||
| #!/bin/bash -xe | ||
| set +o pipefail | ||
|
|
||
| print_checks_and_delete_pr(){ | ||
| community_operators_branch=$1 | ||
| cluster_kind=$2 | ||
| forked_repository=$3 | ||
| repo_pr="gh pr list --repo $forked_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_repository || true | ||
| gh pr close $community_operators_branch --delete-branch --repo $forked_repository | ||
| fi | ||
| } | ||
|
|
||
| print_checks_and_delete_pr $community_operators_kubernetes_branch 'kubernetes' $forked_community_operators_repository | ||
| print_checks_and_delete_pr $community_operators_openshift_branch 'openshift' $forked_community_operators_repository_prod |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/bin/bash -xel | ||
| set +o pipefail | ||
|
|
||
| edit_operator_image_in_csv_yaml (){ | ||
| 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 - | ||
| } | ||
|
|
||
| create_demo_pr(){ | ||
| community_operators_branch=$1 | ||
| dest_path=$2 | ||
| cluster_kind=$3 | ||
| forked_repository=$4 | ||
| cd $forked_repository-fork | ||
| repo_pr="gh pr list --repo $forked_repository | grep $community_operators_branch" | ||
| if [[ "`eval $repo_pr`" == *"$community_operators_branch"* ]]; then | ||
| gh pr close $community_operators_branch --delete-branch --repo $forked_repository | ||
| fi | ||
| git checkout main | ||
| git checkout -b $community_operators_branch | ||
| yes | cp -r $repository_path/deploy/olm-catalog/ibm-block-csi-operator-community/$latest_operator_version/ $dest_path/ibm-block-csi-operator-community | ||
| 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_repository --base main --head $community_operators_branch --body "pr check" | ||
| cd - | ||
| } | ||
|
|
||
| update_community_operators_fork (){ | ||
|
zingero marked this conversation as resolved.
|
||
| forked_repository=$1 | ||
| original_repository=$2 | ||
| echo $github_token > github_token.txt | ||
| gh auth login --with-token < github_token.txt | ||
| gh repo fork $original_repository --clone $forked_repository-fork | ||
| cd $forked_repository-fork | ||
| git remote set-url origin https://csiblock:$github_token@github.com/$forked_repository.git | ||
| git fetch upstream | ||
| git rebase upstream/main | ||
| git push origin main --force | ||
| cd - | ||
| } | ||
|
|
||
| edit_operator_image_in_csv_yaml | ||
| update_community_operators_fork $forked_community_operators_repository $original_community_operators_repository | ||
| update_community_operators_fork $forked_community_operators_repository_prod $original_community_operators_repository_prod | ||
| create_demo_pr $community_operators_kubernetes_branch "operators/" "kubernetes" $forked_community_operators_repository | ||
| create_demo_pr $community_operators_openshift_branch "operators/" "openshift" $forked_community_operators_repository_prod | ||
| 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.
|
||
| # CSI-3171 - handle non GA versions | ||
| csv_version=`echo ${csv_version//ibm-block-csi-operator.v}` | ||
| repository_path=~/work/$CI_REPOSITORY_NAME/$CI_REPOSITORY_NAME | ||
| csv_file=$repository_path/deploy/olm-catalog/ibm-block-csi-operator-community/$csv_version/manifests/ibm-block-csi-operator.v$csv_version.clusterserviceversion.yaml | ||
| upstream_community_operators_path=upstream-community-operators/ibm-block-csi-operator-community/$csv_version | ||
| 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,17 @@ | ||
| #!/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 | ||
|
Contributor
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 csi.block1@il.ibm.com | ||
| git config --global user.name csiblock | ||
|
|
||
| image_version=`cat version/version.go | grep -i driverversion | awk -F = '{print $2}'` | ||
| image_version=`echo ${image_version//\"}` | ||
|
|
||
| echo "::set-output name=image_branch_tag::${image_version}" | ||
|
Contributor
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. |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| #!/bin/bash -xe | ||||||
| set +o pipefail | ||||||
|
|
||||||
| gh_pr_checks_command (){ | ||||||
|
Contributor
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
Contributor
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
Contributor
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.
Contributor
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.
Contributor
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.
Contributor
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 | ||||||
| forked_repository=$2 | ||||||
| gh pr checks $community_operators_branch --repo $forked_repository | ||||||
| } | ||||||
|
|
||||||
| wait_for_checks_to_start(){ | ||||||
| community_operators_branch=$1 | ||||||
| forked_repository=$2 | ||||||
| while [ `gh_pr_checks_command $community_operators_branch $forked_repository | wc -l` -eq 0 ]; do | ||||||
| sleep 1 | ||||||
| done | ||||||
| } | ||||||
| wait_for_checks_to_complete(){ | ||||||
|
zingero marked this conversation as resolved.
Comment on lines
+16
to
+17
Contributor
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 | ||||||
| forked_repository=$2 | ||||||
| all_tests_passed=false | ||||||
| repo_pr=`gh pr list --repo $forked_repository | grep $community_operators_branch` | ||||||
| if [[ "$repo_pr" == *"$community_operators_branch"* ]]; then | ||||||
|
Comment on lines
+21
to
+22
Contributor
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 you give an example for an output of the
Contributor
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. and what does it mean if there is no pr with the required branch? shouldn't it fail?
Contributor
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. in addition, I see this code in at least 3 different places in this PR. |
||||||
| wait_for_checks_to_start $community_operators_branch $forked_repository | ||||||
| test_summary="gh_pr_checks_command $community_operators_branch $forked_repository | 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 $forked_community_operators_repository | ||||||
| wait_for_checks_to_complete $community_operators_openshift_branch $forked_community_operators_repository_prod | ||||||
Uh oh!
There was an error while loading. Please reload this page.