Skip to content

Commit 54b7da8

Browse files
authored
feat(multiarch): adding multi arch build process for LVM Driver (#1)
- Add GitHub actions for CI builds. - Add making Travis run for the forked repo. Signed-off-by: Pawan <[email protected]>
1 parent ab61542 commit 54b7da8

File tree

12 files changed

+437
-230
lines changed

12 files changed

+437
-230
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Tell us about a problem you are experiencing
4+
labels: Bug
5+
6+
---
7+
8+
**What steps did you take and what happened:**
9+
[A clear and concise description of what the bug is, and what commands you ran.]
10+
11+
12+
**What did you expect to happen:**
13+
14+
15+
**The output of the following commands will help us better understand what's going on**:
16+
(Pasting long output into a [GitHub gist](https://gist.github.com) or other [Pastebin](https://pastebin.com/) is fine.)
17+
18+
* `kubectl logs -f openebs-lvm-controller-0 -n kube-system -c openebs-lvm-plugin`
19+
* `kubectl logs -f openebs-lvm-node-[xxxx] -n kube-system -c openebs-lvm-plugin`
20+
* `kubectl get pods -n kube-system`
21+
* `kubectl get lvmvol -A -o yaml`
22+
23+
**Anything else you would like to add:**
24+
[Miscellaneous information that will assist in solving the issue.]
25+
26+
27+
**Environment:**
28+
- LVM Driver version
29+
- Kubernetes version (use `kubectl version`):
30+
- Kubernetes installer & version:
31+
- Cloud provider or hardware configuration:
32+
- OS (e.g. from `/etc/os-release`):
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
labels: Enhancement
5+
6+
---
7+
8+
**Describe the problem/challenge you have**
9+
[A description of the current limitation/problem/challenge that you are experiencing.]
10+
11+
12+
**Describe the solution you'd like**
13+
[A clear and concise description of what you want to happen.]
14+
15+
16+
**Anything else you would like to add:**
17+
[Miscellaneous information that will assist in solving the issue.]
18+
19+
20+
**Environment:**
21+
- LVM Driver version
22+
- Kubernetes version (use `kubectl version`):
23+
- Kubernetes installer & version:
24+
- Cloud provider or hardware configuration:
25+
- OS (e.g. from `/etc/os-release`):

.github/workflows/build.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2020 The OpenEBS Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: build
15+
16+
on: ['push']
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Shellcheck
26+
uses: reviewdog/action-shellcheck@v1
27+
with:
28+
github_token: ${{ secrets.github_token }}
29+
reporter: github-pr-review
30+
path: '.'
31+
pattern: '*.sh'
32+
exclude: './.git/*,./vendor/*'
33+
34+
35+
unit-test:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
- name: Unit test
42+
run: make test
43+
44+
- name: Upload Coverage Report
45+
uses: codecov/codecov-action@v1
46+
47+
csi-driver:
48+
runs-on: ubuntu-latest
49+
needs: ['lint', 'unit-test']
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v2
53+
54+
- name: Set Tag
55+
run: |
56+
BRANCH="${GITHUB_REF##*/}"
57+
CI_TAG=${BRANCH#v}-ci
58+
if [ ${BRANCH} = "master" ]; then
59+
CI_TAG="ci"
60+
fi
61+
echo "TAG=${CI_TAG}" >> $GITHUB_ENV
62+
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
63+
64+
- name: Print Tag info
65+
run: |
66+
echo "BRANCH: ${BRANCH}"
67+
echo "TAG: ${TAG}"
68+
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v1
71+
with:
72+
platforms: all
73+
74+
- name: Set up Docker Buildx
75+
id: buildx
76+
uses: docker/setup-buildx-action@v1
77+
with:
78+
version: v0.5.1
79+
80+
- name: Login to Docker Hub
81+
uses: docker/login-action@v1
82+
with:
83+
username: ${{ secrets.DOCKERHUB_USERNAME }}
84+
password: ${{ secrets.DOCKERHUB_TOKEN }}
85+
86+
- name: Build & Push Image
87+
env:
88+
IMAGE_ORG: ${{ secrets.IMAGE_ORG}}
89+
run: |
90+
make docker.buildx.csi-driver
91+
make buildx.push.csi-driver

.github/workflows/pull_request.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright 2020 The OpenEBS Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: ci
16+
17+
on:
18+
pull_request:
19+
branches:
20+
# on pull requests to master and release branches
21+
- master
22+
- 'v*'
23+
24+
jobs:
25+
lint:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
31+
- name: Format test
32+
run: make format
33+
34+
- name: License test
35+
run: make license-check
36+
37+
- name: Lint test
38+
run: make golint
39+
40+
- name: Shellcheck
41+
uses: reviewdog/action-shellcheck@v1
42+
with:
43+
github_token: ${{ secrets.github_token }}
44+
reporter: github-pr-review
45+
path: '.'
46+
pattern: '*.sh'
47+
exclude: './vendor/*'
48+
49+
50+
unit-test:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v2
55+
56+
- name: Unit test
57+
run: make test
58+
59+
- name: Upload Coverage Report
60+
uses: codecov/codecov-action@v1
61+
62+
63+
csi-driver:
64+
runs-on: ubuntu-latest
65+
needs: ['lint', 'unit-test']
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
70+
- name: Set up QEMU
71+
uses: docker/setup-qemu-action@v1
72+
with:
73+
platforms: all
74+
75+
- name: Set up Docker Buildx
76+
id: buildx
77+
uses: docker/setup-buildx-action@v1
78+
with:
79+
version: v0.5.1
80+
81+
- name: Build Image
82+
env:
83+
IMG_RESULT: cache
84+
run: make docker.buildx.csi-driver

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2020 The OpenEBS Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: release
15+
16+
on:
17+
create:
18+
tags:
19+
- 'v*'
20+
21+
jobs:
22+
csi-driver:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v1
27+
28+
- name: Set Tag
29+
run: |
30+
TAG="${GITHUB_REF#refs/*/v}"
31+
echo "TAG=${TAG}" >> $GITHUB_ENV
32+
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
33+
34+
- name: Print Tag info
35+
run: |
36+
echo "RELEASE TAG: ${RELEASE_TAG}"
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v1
40+
with:
41+
platforms: all
42+
43+
- name: Set up Docker Buildx
44+
id: buildx
45+
uses: docker/setup-buildx-action@v1
46+
with:
47+
version: v0.5.1
48+
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v1
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
55+
- name: Build & Push Image
56+
env:
57+
IMAGE_ORG: ${{ secrets.IMAGE_ORG}}
58+
run: |
59+
make docker.buildx.csi-driver
60+
make buildx.push.csi-driver

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ addons:
2020
before_install:
2121
- sudo apt-get update -qq
2222
install:
23+
- if [ "$TRAVIS_BUILD_DIR" != "$GOPATH/src/github.com/openebs/lvm-localpv" ]; then
24+
mkdir -p $GOPATH/src/github.com/openebs/;
25+
mv $TRAVIS_BUILD_DIR $GOPATH/src/github.com/openebs;
26+
cd $GOPATH/src/github.com/openebs/lvm-localpv;
27+
fi
2328
- make bootstrap
2429
- make format
2530
- make license-check

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,5 @@ license-check:
267267
fi
268268
@echo "--> Done checking license."
269269
@echo
270+
271+
include Makefile.buildx.mk

Makefile.buildx.mk

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
# Copyright 2020 The OpenEBS Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Build lvm-driver docker images with buildx
17+
# Experimental docker feature to build cross platform multi-architecture docker images
18+
# https://docs.docker.com/buildx/working-with-buildx/
19+
20+
ifeq (${TAG}, )
21+
export TAG=ci
22+
endif
23+
24+
# default list of platforms for which multiarch image is built
25+
ifeq (${PLATFORMS}, )
26+
export PLATFORMS="linux/amd64,linux/arm64"
27+
endif
28+
29+
# if IMG_RESULT is unspecified, by default the image will be pushed to registry
30+
ifeq (${IMG_RESULT}, load)
31+
export PUSH_ARG="--load"
32+
# if load is specified, image will be built only for the build machine architecture.
33+
export PLATFORMS="local"
34+
else ifeq (${IMG_RESULT}, cache)
35+
# if cache is specified, image will only be available in the build cache, it won't be pushed or loaded
36+
# therefore no PUSH_ARG will be specified
37+
else
38+
export PUSH_ARG="--push"
39+
endif
40+
41+
# Name of the multiarch image for csi-driver
42+
DOCKERX_IMAGE_CSI_DRIVER:=${IMAGE_ORG}/lvm-driver:${TAG}
43+
44+
.PHONY: docker.buildx
45+
docker.buildx:
46+
export DOCKER_CLI_EXPERIMENTAL=enabled
47+
@if ! docker buildx ls | grep -q container-builder; then\
48+
docker buildx create --platform ${PLATFORMS} --name container-builder --use;\
49+
fi
50+
@docker buildx build --platform "${PLATFORMS}" \
51+
-t "$(DOCKERX_IMAGE_NAME)" ${BUILD_ARGS} \
52+
-f $(PWD)/buildscripts/$(COMPONENT)/Dockerfile.buildx \
53+
. ${PUSH_ARG}
54+
@echo "--> Build docker image: $(DOCKERX_IMAGE_NAME)"
55+
@echo
56+
57+
.PHONY: buildx.csi-driver
58+
buildx.csi-driver:
59+
@echo '--> Building csi-driver binary...'
60+
@pwd
61+
@PNAME=${CSI_DRIVER} CTLNAME=${CSI_DRIVER} BUILDX=true sh -c "'$(PWD)/buildscripts/build.sh'"
62+
@echo '--> Built binary.'
63+
@echo
64+
65+
.PHONY: docker.buildx.csi-driver
66+
docker.buildx.csi-driver: DOCKERX_IMAGE_NAME=$(DOCKERX_IMAGE_CSI_DRIVER)
67+
docker.buildx.csi-driver: COMPONENT=$(CSI_DRIVER)
68+
docker.buildx.csi-driver: BUILD_ARGS=$(DBUILD_ARGS)
69+
docker.buildx.csi-driver: docker.buildx
70+
71+
72+
.PHONY: buildx.push.csi-driver
73+
buildx.push.csi-driver:
74+
BUILDX=true DIMAGE=${IMAGE_ORG}/lvm-driver ./buildscripts/push

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OpenEBS LVM CSI Driver
2-
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3523/badge)](https://bestpractices.coreinfrastructure.org/en/projects/3523)
2+
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3523/badge)](https://bestpractices.coreinfrastructure.org/en/projects/4548)
33
[![Slack](https://img.shields.io/badge/chat!!!-slack-ff1493.svg?style=flat-square)](https://openebsslacksignup.herokuapp.com/)
44
[![Community Meetings](https://img.shields.io/badge/Community-Meetings-blue)](https://hackmd.io/yJb407JWRyiwLU-XDndOLA?view)
55
[![Go Report](https://goreportcard.com/badge/github.com/openebs/lvm-localpv)](https://goreportcard.com/report/github.com/openebs/lvm-localpv)

0 commit comments

Comments
 (0)