Skip to content

Commit

Permalink
Enhance tests (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsihk authored Jan 5, 2025
1 parent 7836bbb commit 7de0eea
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 62 deletions.
95 changes: 65 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ on:
- '*.md'
- 'LICENSE'

env:
GO_VERSION: 1.19.13
PROVISIONER_NFS_IMAGE: provisioner-nfs
NFS_SERVER_IMAGE: nfs-server-alpine
EXPORT_PATH: /tmp
IMAGE_ORG: ${{ github.repository_owner }}
IMAGE_ARCH: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le

jobs:
lint:
# to ignore builds on release
Expand Down Expand Up @@ -55,30 +63,74 @@ jobs:
- name: Upload Coverage Report
uses: codecov/codecov-action@v1

sanity-test:
sanity-build:
# to ignore builds on release
if: ${{ (github.event.ref_type != 'tag') }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
kubernetes: [v1.27.3]
needs: ['lint', 'unit-test']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
uses: actions/setup-go@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.13
go-version: ${{ env.GO_VERSION }}

- name: Build provisioner-nfs image
run: make provisioner-nfs-image

- name: Build nfs-server-alpine image
run: make nfs-server-image

- name: Export images
run: make output-image

- name: Upload provisioner-nfs image
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROVISIONER_NFS_IMAGE }}
path: ${{ env.EXPORT_PATH }}/${{ env.PROVISIONER_NFS_IMAGE }}.tar

- name: Upload nfs-server-alpine image
uses: actions/upload-artifact@v4
with:
name: ${{ env.NFS_SERVER_IMAGE }}
path: ${{ env.EXPORT_PATH }}/${{ env.NFS_SERVER_IMAGE }}.tar

sanity-test:
# to ignore builds on release
if: ${{ (github.event.ref_type != 'tag') }}
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
kubernetes: [v1.27.3, v1.29.12, v1.30.8, v1.31.0]
needs: ['lint', 'unit-test', 'sanity-build']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Download provisioner-nfs image
uses: actions/download-artifact@v4
with:
name: ${{ env.PROVISIONER_NFS_IMAGE }}
path: ${{ env.EXPORT_PATH }}

- name: Download nfs-server-alpine image
uses: actions/download-artifact@v4
with:
name: ${{ env.NFS_SERVER_IMAGE }}
path: ${{ env.EXPORT_PATH }}

- name: Load images
run: make load-image

- name: Install NFS utils
run: |
sudo apt-get update && sudo apt-get install -y nfs-common
Expand All @@ -87,7 +139,7 @@ jobs:
uses: medyagh/setup-minikube@latest
with:
cache: false
minikube-version: 1.31.1
minikube-version: 1.34.0
driver: none
kubernetes-version: ${{ matrix.kubernetes }}
cni: calico
Expand All @@ -108,16 +160,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.13

- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
go-version: ${{ env.GO_VERSION }}

- name: Set CI Tag
run: |
Expand Down Expand Up @@ -187,7 +233,7 @@ jobs:
context: .
file: ./buildscripts/provisioner-nfs/provisioner-nfs.Dockerfile
push: true
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
${{ steps.docker_meta.outputs.tags }}
build-args: |
Expand All @@ -202,12 +248,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Set CI Tag
run: |
BRANCH="${GITHUB_REF##*/}"
Expand Down Expand Up @@ -271,7 +311,7 @@ jobs:
context: ./nfs-server-container
file: nfs-server-container/Dockerfile
push: true
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
${{ steps.docker_meta.outputs.tags }}
Expand All @@ -281,11 +321,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand Down
82 changes: 67 additions & 15 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ on:
- develop
- 'v*'

env:
GO_VERSION: 1.19.13
PROVISIONER_NFS_IMAGE: provisioner-nfs
NFS_SERVER_IMAGE: nfs-server-alpine
EXPORT_PATH: /tmp
IMAGE_ORG: ${{ github.repository_owner }}
IMAGE_ARCH: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -52,30 +60,74 @@ jobs:
- name: Upload Coverage Report
uses: codecov/codecov-action@v1

sanity-test:
sanity-build:
# to ignore builds on release
if: ${{ (github.event.ref_type != 'tag') }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
kubernetes: [v1.27.3]
needs: ['lint', 'unit-test']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.13
go-version: ${{ env.GO_VERSION }}

- name: Build provisioner-nfs image
run: make provisioner-nfs-image

- name: Build nfs-server-alpine image
run: make nfs-server-image

- name: Export images
run: make output-image

- name: Upload provisioner-nfs image
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROVISIONER_NFS_IMAGE }}
path: ${{ env.EXPORT_PATH }}/${{ env.PROVISIONER_NFS_IMAGE }}.tar

- name: Upload nfs-server-alpine image
uses: actions/upload-artifact@v4
with:
name: ${{ env.NFS_SERVER_IMAGE }}
path: ${{ env.EXPORT_PATH }}/${{ env.NFS_SERVER_IMAGE }}.tar

sanity-test:
# to ignore builds on release
if: ${{ (github.event.ref_type != 'tag') }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
kubernetes: [v1.27.3, v1.29.12, v1.30.8, v1.31.0]
needs: ['lint', 'unit-test', 'sanity-build']
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Download provisioner-nfs image
uses: actions/download-artifact@v4
with:
name: ${{ env.PROVISIONER_NFS_IMAGE }}
path: ${{ env.EXPORT_PATH }}

- name: Download nfs-server-alpine image
uses: actions/download-artifact@v4
with:
name: ${{ env.NFS_SERVER_IMAGE }}
path: ${{ env.EXPORT_PATH }}

- name: Load images
run: make load-image

- name: Install NFS utils
run: |
sudo apt-get update && sudo apt-get install -y nfs-common
Expand All @@ -84,7 +136,7 @@ jobs:
uses: medyagh/setup-minikube@latest
with:
cache: false
minikube-version: 1.31.1
minikube-version: 1.34.0
driver: none
kubernetes-version: ${{ matrix.kubernetes }}
cni: calico
Expand All @@ -105,10 +157,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19.13
go-version: ${{ env.GO_VERSION }}

- name: Setup QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -127,9 +179,9 @@ jobs:
context: .
file: ./buildscripts/provisioner-nfs/provisioner-nfs.Dockerfile
push: false
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
openebs/provisioner-nfs:ci
${{ env.IMAGE_ORG }}/provisioner-nfs:ci
nfs-server:
runs-on: ubuntu-latest
Expand All @@ -155,9 +207,9 @@ jobs:
context: ./nfs-server-container
file: nfs-server-container/Dockerfile
push: false
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
openebs/nfs-server-alpine:ci
${{ env.IMAGE_ORG }}/nfs-server-alpine:ci
nfs-e2e:
runs-on: ubuntu-latest
Expand All @@ -173,4 +225,4 @@ jobs:
load: false
platforms: linux/amd64
tags: |
openebs/nfs-e2e:ci
${{ env.IMAGE_ORG }}/nfs-e2e:ci
20 changes: 6 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ on:
types:
- 'created'

env:
IMAGE_ORG: ${{ github.repository_owner }}
IMAGE_ARCH: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le

jobs:
provisioner-nfs:
if: contains(github.ref, 'tags/v')
Expand All @@ -27,12 +31,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Set Release Tag
run: |
TAG="${GITHUB_REF#refs/*/v}"
Expand Down Expand Up @@ -97,7 +95,7 @@ jobs:
context: .
file: ./buildscripts/provisioner-nfs/provisioner-nfs.Dockerfile
push: true
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
${{ steps.docker_meta.outputs.tags }}
build-args: |
Expand All @@ -113,12 +111,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Set Release Tag
run: |
TAG="${GITHUB_REF#refs/*/v}"
Expand Down Expand Up @@ -183,7 +175,7 @@ jobs:
context: ./nfs-server-container
file: nfs-server-container/Dockerfile
push: true
platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le
platforms: ${{ env.IMAGE_ARCH }}
tags: |
${{ steps.docker_meta.outputs.tags }}
Loading

0 comments on commit 7de0eea

Please sign in to comment.