-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: develop
Are you sure you want to change the base?
Changes from 37 commits
1ac05dc
6aff2f7
1fe56d8
572dddc
88672c3
0eb3674
1e6d6be
34f9715
057884f
683a5a2
90add39
364b42b
782645f
e6a4b96
1ea7d40
605d016
ed661c5
12050f8
c2fba0b
d640b79
31438ff
6d906c0
31d711b
0827d76
2ba9b3a
36d7a6e
e3aa5d6
f854cb0
b4300ee
7e6c394
684aecc
1c9a227
0477825
3496a4a
a04194b
90f3e06
fb1f865
a4b84c1
8ff6f1c
3b3c0b9
fadd666
cda5430
43aabe1
9bc70b5
a05503f
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,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.x' | ||
- 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 | ||
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: "CSI 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: "CSI 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/[email protected] | ||
- 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 | ||
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 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 }} |
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 | ||
branch_tag=`echo $GIT_BRANCH| sed 's|/|.|g'` #not sure if docker accept / in the version | ||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
specific_tag="${IMAGE_VERSION}_b${BUILD_NUMBER}_${COMMIT_HASH}${branch_tag}" | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo $specific_tag | ||
echo $branch_tag |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash -xe | ||
set +o pipefail | ||
|
||
install_ci_dependencies (){ | ||
python -m pip install --upgrade pip | ||
echo docker-hub==2.2.0 > dev-requirements.txt | ||
pip install -r dev-requirements.txt | ||
} | ||
|
||
get_driver_version (){ | ||
source /home/runner/.bash_profile | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cd common | ||
image_version=`yq eval .identity.version config.yaml` | ||
cd - | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
install_ci_dependencies | ||
cat >>/home/runner/.bash_profile <<'EOL' | ||
yq() { | ||
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@" | ||
} | ||
EOL | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
get_driver_version | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GITHUB_SHA=${GITHUB_SHA:0:7}_ | ||
zingero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
driver_image_tags=`scripts/ci/get_image_tags_from_branch.sh ${CI_ACTION_REF_NAME} ${image_version} ${build_number} ${GITHUB_SHA}` | ||
docker_image_branch_tag=`echo $driver_image_tags | awk '{print$2}'` | ||
driver_images_specific_tag=`echo $driver_image_tags | awk '{print$1}'` | ||
oriyarde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ "$docker_image_branch_tag" == "develop" ]; then | ||
docker_image_branch_tag=latest | ||
fi | ||
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 think we can avoid double assignment if we move this 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. what do you mean by "first assignment"? 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.e.
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. but without backticks of course 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. could you also put the 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. also why is it sometimes |
||
|
||
echo "::set-output name=docker_image_branch_tag::${docker_image_branch_tag}" | ||
echo "::set-output name=driver_images_specific_tag::${driver_images_specific_tag}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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
There was a problem hiding this comment.
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)