Skip to content
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

CSI-2625 create driver ci #344

Draft
wants to merge 45 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1ac05dc
create driver ci
matancarmeli7 Jun 30, 2021
6aff2f7
move env vars place
matancarmeli7 Jul 1, 2021
1fe56d8
add environment variables to yq command
matancarmeli7 Jul 1, 2021
572dddc
show all pods while wating
matancarmeli7 Jul 1, 2021
88672c3
change the images check
matancarmeli7 Jul 1, 2021
0eb3674
add docker-hub command
matancarmeli7 Jul 1, 2021
1e6d6be
not fail on getting the image tags
matancarmeli7 Jul 1, 2021
34f9715
made yq butifule
matancarmeli7 Jul 5, 2021
057884f
change the .bash_profile path
matancarmeli7 Jul 5, 2021
683a5a2
add CSI-3164
matancarmeli7 Jul 7, 2021
90add39
add permissions to edit cr files
matancarmeli7 Jul 8, 2021
364b42b
allow editing cr file
matancarmeli7 Jul 8, 2021
782645f
answer some code review comments
matancarmeli7 Jul 12, 2021
e6a4b96
change the image tag
matancarmeli7 Jul 12, 2021
1ea7d40
change saving driver logs script
matancarmeli7 Jul 12, 2021
605d016
use run_action_on_pod function
matancarmeli7 Jul 12, 2021
ed661c5
fix save logs
matancarmeli7 Jul 12, 2021
12050f8
cahnge the edit of the cr file
matancarmeli7 Jul 12, 2021
c2fba0b
fix some problems
matancarmeli7 Jul 12, 2021
d640b79
create github_actions firectory
matancarmeli7 Jul 12, 2021
31438ff
create github_actions firectory
matancarmeli7 Jul 12, 2021
6d906c0
fix syntax errors in wait for k8s cluster
matancarmeli7 Jul 13, 2021
31d711b
fix is_pod_ready function
matancarmeli7 Jul 13, 2021
0827d76
fix some syntax errors in deploy driver
matancarmeli7 Jul 14, 2021
2ba9b3a
change the node ripository yaml path
matancarmeli7 Jul 14, 2021
36d7a6e
remove cluster setup from driver repository
matancarmeli7 Jul 21, 2021
e3aa5d6
fix get_image_tag_from_branch script path
matancarmeli7 Jul 21, 2021
f854cb0
add build_number env variable
matancarmeli7 Jul 21, 2021
b4300ee
fix setup ci dependencies
matancarmeli7 Jul 21, 2021
7e6c394
change get_image_tags_from_branch script name
matancarmeli7 Jul 26, 2021
684aecc
add commit sha to docker image
matancarmeli7 Jul 27, 2021
1c9a227
change the order in the get branch script
matancarmeli7 Jul 27, 2021
0477825
change stages names
matancarmeli7 Aug 3, 2021
3496a4a
change commit sha parameter
matancarmeli7 Aug 4, 2021
a04194b
Merge branch 'develop' of https://github.com/IBM/ibm-block-csi-driver…
matancarmeli7 Aug 4, 2021
90f3e06
add csiblock1 secret
matancarmeli7 Aug 18, 2021
fb1f865
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 Aug 18, 2021
a4b84c1
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 Oct 3, 2021
8ff6f1c
fix setup_ci_dependencies script comments
matancarmeli7 Oct 3, 2021
3b3c0b9
add setup_yq.sh file
matancarmeli7 Oct 4, 2021
fadd666
Merge branch 'develop' into task/CSI-2625_add_another_stage_before_th…
matancarmeli7 Oct 31, 2021
cda5430
PR
matancarmeli7 Oct 31, 2021
43aabe1
avoid double assignment
matancarmeli7 Nov 1, 2021
9bc70b5
align setup_ci with operator
matancarmeli7 Nov 2, 2021
a05503f
fix spacing problem
matancarmeli7 Nov 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
135 changes: 135 additions & 0 deletions .github/workflows/driver_ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Driver Build
on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master
jobs:
prepare_env:
name: "Prepare env"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9.7'
Comment on lines +18 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remind me what is this for?
it's hard to tell which setup is required by which logic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it for docker/build-push-action?

- uses: FranzDiebold/github-env-vars-action@v2
- name: Setup dependencies
id: setup_dependencies
run: |
scripts/ci/github_actions/driver/setup_ci_dependencies.sh
env:
build_number: "${{ github.run_number }}"
- uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('dev-requirements.txt') }}
- name: Save dependencies files
uses: actions/upload-artifact@v2
with:
name: ci-dependencies
path: |
/home/runner/.bash_profile
retention-days: 1
outputs:
docker_image_branch_tag: "${{ steps.setup_dependencies.outputs.docker_image_branch_tag }}"
driver_images_specific_tag: "${{ steps.setup_dependencies.outputs.driver_images_specific_tag }}"

csi_controller_static_code_analysis:
runs-on: ubuntu-latest
name: "CSI controller static code analysis"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: CSI-controller- static code analysis
Copy link
Contributor

@oriyarde oriyarde Nov 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: CSI-controller- static code analysis
- name: CSI-controller: static code analysis

(same for unit testing, etc...)
could you align the names to the ones in the jenkinsfile, as much as possible?
unless you know of an easy way to maintain them in one place

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would also mean:
k8s yamls validation should be:
K8s yamls validation (in both files)

run: |
./scripts/run_static_code_analysis.sh

unit_testing_coverage:
runs-on: ubuntu-latest
name: "Unit testing + coverage ${{ matrix.csiblock-component }}"
strategy:
matrix:
include:
- csiblock-component: controller
command-to-run: "./scripts/run_unitests.sh"
- csiblock-component: node
command-to-run: "make test-xunit-in-container"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: CSI-${{ matrix.csiblock-component }}- Unit testing + coverage
run: |
mkdir -p build/reports && chmod 777 build/reports
$command_to_run `pwd`/build/reports
env:
command_to_run: ${{ matrix.command-to-run }}

k8s_yamls_validation:
runs-on: ubuntu-latest
name: "Deployment k8s yamls validation"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: CSI-deployment- k8s yamls validation
run: |
./scripts/run_yamlcheck.sh

csi_build_and_push_images:
runs-on: ubuntu-latest
name: "Build and push images"
needs:
- CSI_controller_static_code_analysis
- Unit_testing_coverage
- k8s_yamls_validation
- Prepare_env
strategy:
matrix:
image_type: ['node', 'controller']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
oriyarde marked this conversation as resolved.
Show resolved Hide resolved
id: buildx
uses: docker/setup-buildx-action@v1.3.0
- uses: FranzDiebold/github-env-vars-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: '${{ secrets.CSIBLOCK_DOCKERHUB_USERNAME }}'
password: '${{ secrets.CSIBLOCK_DOCKERHUB_PASSWORD }}'
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-${{ matrix.image_type }}
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push ${{ matrix.image_type }}
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/ppc64le,linux/s390x
push: true
tags: |
${{ secrets.CSIBLOCK_DOCKERHUB_USERNAME }}/ibm-block-csi-${{ matrix.image_type }}:${{ needs.Prepare_env.outputs.driver_images_specific_tag }}
${{ secrets.CSIBLOCK_DOCKERHUB_USERNAME }}/ibm-block-csi-${{ matrix.image_type }}:${{ needs.Prepare_env.outputs.docker_image_branch_tag }}
file: Dockerfile-csi-${{ matrix.image_type }}
cache-from: type=local,src=/tmp/.buildx-${{ matrix.image_type }}
cache-to: type=local,dest=/tmp/.buildx-new-${{ matrix.image_type }}
# Temp fix
# CSI-3164
# https://github.com/docker/build-push-action/issues/252
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you check if this is still needed?

# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
[[ -G /tmp/.buildx-${{ matrix.image_type }} ]] && rm -rf /tmp/.buildx-${{ matrix.image_type }}
mv /tmp/.buildx-new-${{ matrix.image_type }} /tmp/.buildx-${{ matrix.image_type }}
2 changes: 1 addition & 1 deletion scripts/ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pipeline {
sh 'make test-xunit-in-container'
}
}
stage ('CSI-deployment: k8s yamls validation') {
stage ('k8s yamls validation') {
steps {
sh './scripts/run_yamlcheck.sh'
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/build_push_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ for envi in $MANDATORY_ENVS; do
done

# Prepare specific tag for the image
branch=`echo $GIT_BRANCH| sed 's|/|.|g'` #not sure if docker accept / in the version
specific_tag="${IMAGE_VERSION}_b${BUILD_NUMBER}_${branch}"
tags=`scripts/ci/get_image_tags_from_branch.sh ${GIT_BRANCH} ${IMAGE_VERSION} ${BUILD_NUMBER} ${GIT_COMMIT}`
specific_tag=`echo $tags | awk '{print$1}'`

# Set latest tag only if its from develop branch or master and prepare tags
[ "$GIT_BRANCH" = "develop" -o "$GIT_BRANCH" = "origin/develop" -o "$GIT_BRANCH" = "master" ] && tag_latest="true" || tag_latest="false"
Expand Down
9 changes: 9 additions & 0 deletions scripts/ci/get_image_tags_from_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -xe
GIT_BRANCH=$1
IMAGE_VERSION=$2
BUILD_NUMBER=$3
COMMIT_HASH=${4:0:7}
branch_image_tag=$(echo $GIT_BRANCH| sed 's|/|.|g') #not sure if docker accept / in the version
specific_tag="${IMAGE_VERSION}_b${BUILD_NUMBER}_${COMMIT_HASH}_${branch_image_tag}"
echo $specific_tag
echo $branch_image_tag
29 changes: 29 additions & 0 deletions scripts/ci/github_actions/driver/setup_ci_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash -xe
set +o pipefail

install_ci_dependencies (){
scripts/ci/github_actions/setup_yq.sh
source /home/runner/.bash_profile
python -m pip install --upgrade pip==21.2.4
echo docker-hub==2.2.0 > dev-requirements.txt
pip install -r dev-requirements.txt
}

get_driver_version (){
yq eval .identity.version common/config.yaml
}

install_ci_dependencies
driver_version=$(get_driver_version)
triggering_branch=${CI_ACTION_REF_NAME}
driver_image_tags=$(scripts/ci/get_image_tags_from_branch.sh ${triggering_branch} ${driver_version} ${build_number} ${GITHUB_SHA})
driver_images_specific_tag=$(echo $driver_image_tags | awk '{print$1}')

if [ "$triggering_branch" == "develop" ]; then
docker_image_branch_tag=latest
else
docker_image_branch_tag=$(echo $driver_image_tags | awk '{print$2}')
fi

echo "::set-output name=driver_images_specific_tag::${driver_images_specific_tag}"
echo "::set-output name=docker_image_branch_tag::${docker_image_branch_tag}"
8 changes: 8 additions & 0 deletions scripts/ci/github_actions/setup_yq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -xe
set +o pipefail

cat >>/home/runner/.bash_profile <<'EOL'
yq() {
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
EOL