-
Notifications
You must be signed in to change notification settings - Fork 25
200 lines (198 loc) · 7.1 KB
/
driver_ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: CSI IBM Driver CI
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'
- name: Setup dependencies
run: |
scripts/ci/setup_ci_dependencies.sh
- 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
- uses: FranzDiebold/github-env-vars-action@v2
CSI-controller-static_code_analysis:
runs-on: ubuntu-latest
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 }}
CSI-deployment-k8s_yamls_validation:
runs-on: ubuntu-latest
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
needs:
- CSI-controller-static_code_analysis
- Unit_testing_coverage
- CSI-deployment-k8s_yamls_validation
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
id: buildx
uses: docker/[email protected]
- uses: FranzDiebold/github-env-vars-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: 'csiblock1'
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: Create github branch parameter
id: tested_github_branch
run: |
docker_image_branch_tag=`echo $CI_ACTION_REF_NAME| sed 's|/|.|g'`
echo "::set-output name=docker_image_branch_tag::${docker_image_branch_tag}"
- 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: |
csiblock1/ibm-block-csi-${{ matrix.image_type }}:${{ steps.tested_github_branch.outputs.docker_image_branch_tag }}_${{ github.run_number }}
csiblock1/ibm-block-csi-${{ matrix.image_type }}:${{ steps.tested_github_branch.outputs.docker_image_branch_tag }}
csiblock1/ibm-block-csi-${{ matrix.image_type }}:latest
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
# https://github.com/docker/build-push-action/issues/252
# 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 }}
outputs:
driver_images_tag: "${{ steps.tested_github_branch.outputs.docker_image_branch_tag }}_${{ github.run_number }}"
create-cluster:
runs-on: ubuntu-latest
needs: CSI-Build-and-push-images
env:
csiblock_dockerhub_password: ${{ secrets.CSIBLOCK_DOCKERHUB_PASSWORD }}
controller_repository_for_test: csiblock1/ibm-block-csi-controller
node_repository_for_test: csiblock1/ibm-block-csi-node
operator_image_repository_for_test: csiblock1/ibm-block-csi-operator
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: driver
- uses: FranzDiebold/github-env-vars-action@v2
- name: Retrieve ci dependencies
uses: actions/download-artifact@v2
with:
name: ci-dependencies
path: /home/runner
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('dev-requirements.txt') }}
- name: Get the operator github branch
id: operator_github_branch
run: |
driver/scripts/ci/get_operator_github_branch.sh
env:
github_token: ${{ secrets.CSIBLOCK_GITHUB_TOKEN }}
- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
version: v0.11.1
- name: Wait for k8s cluster to be ready
run: |
driver/scripts/ci/wait_for_k8s_ready.sh
- name: Checkout
uses: actions/checkout@v2
with:
repository: IBM/ibm-block-csi-operator
ref: "${{ steps.operator_github_branch.outputs.operator_branch }}"
path: operator
- name: Deploy ibm block csi driver
run: |
driver/scripts/ci/deploy_driver.sh
env:
driver_images_tag: "${{ needs.CSI-Build-and-push-images.outputs.driver_images_tag }}"
operator_image_tag_for_test: "${{ steps.operator_github_branch.outputs.docker_image_branch_tag }}"
operator_file: "operator/deploy/installer/generated/ibm-block-csi-operator.yaml"
cr_file: "operator/deploy/crds/csi.ibm.com_v1_ibmblockcsi_cr.yaml"
- name: Wait for csi ibm block driver to be ready
run: |
driver/scripts/ci/wait_for_driver_to_be_ready.sh
- name: Save driver pods logs
if: always()
run: |
driver/scripts/ci/save_driver_pods_logs.sh
- name: Upload driver pods logs
if: always()
uses: actions/upload-artifact@v2
with:
name: Driver logs
path: |
/tmp/driver_*.txt
retention-days: 7