-
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 all 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.9.7' | ||||||
- 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 | ||||||
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
(same for unit testing, etc...) 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. this would also mean: |
||||||
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/[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: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 |
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}" |
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 |
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.
could you remind me what is this for?
it's hard to tell which setup is required by which logic
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.
is it for
docker/build-push-action
?