Skip to content

Commit c884157

Browse files
authored
Add GitHub workflow (#671)
Signed-off-by: Bala.FA <[email protected]>
1 parent 3dcd35f commit c884157

File tree

14 files changed

+364
-98
lines changed

14 files changed

+364
-98
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Screenshots and logs**
20+
21+
If applicable, add screenshots to help explain your problem. Or logs from the pods in directpv-min-io namespace.
22+
23+
**Deployment information (please complete the following information):**
24+
- DirectPV version: (This can be captured by `kubectl directpv --version`)
25+
- Kubernetes Version:
26+
- OS info:
27+
- Kernel version:
28+
29+
**Additional context**
30+
Add any other context about the problem here.

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master, devel ]
6+
7+
pull_request:
8+
branches: [ master, devel ]
9+
10+
# This ensures that previous jobs for the PR are canceled when the PR is
11+
# updated.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-go@v3
22+
with:
23+
go-version: 1.19.x
24+
check-latest: true
25+
- uses: docker/setup-qemu-action@v2
26+
- uses: docker/setup-buildx-action@v2
27+
- name: Set environment
28+
run: |
29+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
30+
mkdir -p "$(go env GOPATH)/src/github.com/minio/"
31+
ln -s "$PWD" "$(go env GOPATH)/src/github.com/minio/directpv"
32+
- name: Build and test
33+
env:
34+
CGO_ENABLED: 0
35+
GO111MODULE: on
36+
run: |
37+
./build.sh
38+
go test -v ./...
39+
docker build . -t "directpv:latest"
40+
- uses: goreleaser/goreleaser-action@v3
41+
with:
42+
version: latest
43+
args: release --skip-publish --skip-sign --rm-dist --snapshot

.github/workflows/functests.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Functional Tests
2+
3+
on:
4+
push:
5+
branches: [ master, devel ]
6+
7+
pull_request:
8+
branches: [ master, devel ]
9+
10+
# This ensures that previous jobs for the PR are canceled when the PR is
11+
# updated.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
name: Testing on Kubernetes ${{ matrix.kube-version }} in ${{ matrix.os }}
19+
runs-on: ${{ matrix.os }}
20+
timeout-minutes: 60
21+
strategy:
22+
matrix:
23+
kube-version: ['v1.18.20', 'v1.19.16', 'v1.20.15', 'v1.21.14', 'v1.22.15', 'v1.23.13', 'v1.24.7', 'v1.25.3']
24+
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
25+
exclude:
26+
- os: ubuntu-22.04
27+
kube-version: 'v1.18.20'
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-go@v3
32+
with:
33+
go-version: 1.19.x
34+
check-latest: true
35+
36+
- name: Install dependencies
37+
run: |
38+
sudo apt-get update
39+
40+
- name: Set environment
41+
run: |
42+
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
43+
mkdir -p "$(go env GOPATH)/src/github.com/minio/"
44+
ln -s "$PWD" "$(go env GOPATH)/src/github.com/minio/directpv"
45+
echo "VERSION=$(git describe --tags --always --dirty)" >> $GITHUB_ENV
46+
47+
- name: Build binaries
48+
env:
49+
CGO_ENABLED: 0
50+
GO111MODULE: on
51+
run: |
52+
go build -tags "osusergo netgo static_build" -ldflags="-X main.Version=${VERSION} -extldflags=-static" github.com/minio/directpv/cmd/directpv
53+
go build -tags "osusergo netgo static_build" -ldflags="-X main.Version=${VERSION} -extldflags=-static" github.com/minio/directpv/cmd/kubectl-directpv
54+
55+
- name: Build docker image
56+
run: |
57+
docker build -t quay.io/minio/directpv:${VERSION} .
58+
59+
- name: Setup Minikube
60+
uses: manusa/[email protected]
61+
with:
62+
minikube version: 'v1.27.1'
63+
kubernetes version: ${{ matrix.kube-version }}
64+
github token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Check Minikube
67+
run: |
68+
kubectl get nodes
69+
kubectl get pods -A
70+
while kubectl get pods -n kube-system --no-headers | grep -vqw Running; do echo "Waiting for Minikube pods to be ready"; sleep 3; done
71+
while kubectl get nodes --no-headers | grep -vqw Ready; do echo "Waiting for Minikube node to be ready"; sleep 3; done
72+
73+
- name: Run tests
74+
run: |
75+
functests/run-tests.sh

.github/workflows/linters.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Linters
2+
3+
on:
4+
push:
5+
branches: [ master, devel ]
6+
7+
pull_request:
8+
branches: [ master, devel ]
9+
10+
# This ensures that previous jobs for the PR are canceled when the PR is
11+
# updated.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
linters:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-go@v3
22+
with:
23+
go-version: 1.19.x
24+
check-latest: true
25+
- uses: ludeeus/action-shellcheck@master
26+
env:
27+
SHELLCHECK_OPTS: -e SC1091
28+
- uses: golangci/golangci-lint-action@v2
29+
with:
30+
version: v1.50.1
31+
args: --config ./.golangci.yml --timeout=60m
32+
skip-go-installation: true

.github/workflows/vulncheck.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: VulnCheck
2+
3+
on:
4+
push:
5+
branches: [ master, devel ]
6+
7+
pull_request:
8+
branches: [ master, devel ]
9+
10+
# This ensures that previous jobs for the PR are canceled when the PR is
11+
# updated.
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
vulncheck:
18+
name: Analysis
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out code
22+
uses: actions/checkout@v3
23+
- name: Set up Go
24+
uses: actions/setup-go@v3
25+
with:
26+
go-version: 1.19.x
27+
check-latest: true
28+
- name: Install govulncheck
29+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
30+
shell: bash
31+
- name: Run govulncheck
32+
run: govulncheck ./...
33+
shell: bash

.goreleaser.yml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ release:
1313

1414
before:
1515
hooks:
16-
- go mod tidy -compat=1.17
16+
- go mod tidy -compat=1.19
1717
- go mod download
1818

1919
builds:
@@ -35,31 +35,6 @@ builds:
3535
ldflags:
3636
- -s -w -X main.Version={{ .Tag }}
3737

38-
-
39-
main: ./cmd/kubectl-direct_csi
40-
id: kubectl-direct_csi
41-
binary: kubectl-direct_csi
42-
goos:
43-
- linux
44-
- windows
45-
- darwin
46-
goarch:
47-
- amd64
48-
- arm64
49-
- ppc64le
50-
ignore:
51-
- goos: windows
52-
goarch: arm64
53-
env:
54-
- CGO_ENABLED=0
55-
flags:
56-
- -trimpath
57-
- -tags="osusergo netgo static_build"
58-
ldflags:
59-
- -s -w -X main.Version={{ .Tag }}
60-
hooks:
61-
post: ./package.sh {{ .Path }}
62-
6338
-
6439
main: ./cmd/kubectl-directpv
6540
id: kubectl-directpv

functests/common.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ function remove_luks() {
6767
rm -f testluks.img
6868
}
6969

70+
# wait_for_service <service>
71+
function wait_for_service() {
72+
service="$1"
73+
endpoints=$(kubectl get endpoints -n directpv-min-io "${service}" --no-headers | awk '{ print $2 }')
74+
while [[ $endpoints == '<none>' ]]; do
75+
echo "$ME: waiting for ${service} available"
76+
sleep 5
77+
endpoints=$(kubectl get endpoints -n directpv-min-io "${service}" --no-headers | awk '{ print $2 }')
78+
done
79+
}
80+
7081
function install_directpv() {
7182
"${DIRECTPV_CLIENT}" install --quiet
7283

@@ -82,6 +93,10 @@ function install_directpv() {
8293
echo "$ME: waiting for DirectPV to come up"
8394
sleep 5
8495
done
96+
97+
wait_for_service node-api-server-hl
98+
wait_for_service admin-service
99+
sleep 1m
85100
}
86101

87102
function uninstall_directpv() {
@@ -118,7 +133,6 @@ function check_drives_status() {
118133
}
119134

120135
function add_drives() {
121-
# Get the nodeport service url
122136
url=$(minikube service --namespace=directpv-min-io admin-service --url)
123137
admin_server=${url#"http://"}
124138

functests/run.sh renamed to functests/run-tests.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,4 @@ export ME
2222
SCRIPT_DIR=$(dirname "$0")
2323
export SCRIPT_DIR
2424

25-
if [[ $# -ne 1 ]]; then
26-
echo "error: build version must be provided"
27-
echo "usage: $ME <BUILD-VERSION>"
28-
exit 255
29-
fi
30-
31-
BUILD_VERSION="$1"
32-
export BUILD_VERSION
33-
3425
"${SCRIPT_DIR}/execute.sh" "${SCRIPT_DIR}/tests.sh"

package.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
## Goreleaser helper script.
4+
5+
if [ "$#" -ne 1 ]; then
6+
echo "usage: package.sh <kubectl-directpv-binary-path>"
7+
exit 255
8+
fi
9+
10+
dir="$(dirname "$1")"
11+
binary=$(basename "${dir}")
12+
cp -f LICENSE CREDITS README.md "${dir}"
13+
rm -f "${binary}.zip"
14+
zip -r -j "${binary}.zip" "${dir}"

0 commit comments

Comments
 (0)