Skip to content

Commit

Permalink
ci: refactor gh workflow (#121)
Browse files Browse the repository at this point in the history
* ci: refactor gh workflow

* ci: update release workflow to include linting and testing dependencies
  • Loading branch information
lwpk110 authored Nov 29, 2024
1 parent aafdd45 commit 5f37b51
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 121 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
push:
branches:
- "main"
pull_request:


jobs:
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Run markdownlint
uses: DavidAnson/markdownlint-cli2-action@v18
with:
globs: |
README.*.md
docs/*.md
golang-lint:
name: golang-lint
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
120 changes: 0 additions & 120 deletions .github/workflows/main.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish

on:
push:
branches:
- main


jobs:
publish-image:
name: Publish Image
if: ${{ github.repository_owner == 'zncdatadev' }}
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push operator
run: |
make docker-buildx
132 changes: 132 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Release

on:
push:
tags:
- '*'


env:
VERSION: ${{ github.ref_name }}


jobs:
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Run markdownlint
uses: DavidAnson/markdownlint-cli2-action@v18
with:
globs: |
README.*.md
docs/*.md
golang-lint:
name: golang-lint
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: v1.61

golang-test:
name: Golang Test
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Running Tests
run: |
go mod tidy
make test
chainsaw-test:
name: Chainsaw Test
runs-on: ubuntu-latest
strategy:
matrix:
k8s-version: ['1.26.15', '1.27.16']
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Create KinD clustet pur
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version}}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make kind-create

- name: Chainsaw test setup
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version }}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make chainsaw-setup

- name: Test with Chainsaw
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version }}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make chainsaw-test


release-image:
name: Release Image
if: ${{ github.repository_owner == 'zncdatadev' }}
runs-on: ubuntu-latest
needs:
- markdown-lint
- golang-lint
- golang-test
- chainsaw-test
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push operator

run: |
make docker-buildx
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

name: Test

on:
push:
branches:
- "main"
pull_request:


jobs:
golang-test:
name: Golang Test
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Running Tests
run: |
go mod tidy
make test
chainsaw-test:
name: Chainsaw Test
runs-on: ubuntu-latest
strategy:
matrix:
k8s-version: ['1.26.15', '1.27.16']
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.23'

- name: Create KinD clustet pur
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version}}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make kind-create

- name: Chainsaw test setup
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version }}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make chainsaw-setup

- name: Test with Chainsaw
env:
KINDTEST_K8S_VERSION: ${{ matrix.k8s-version }}
KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
KIND_KUBECONFIG: kind-kubeconfig-${{ matrix.k8s-version }}
run: make chainsaw-test
Loading

0 comments on commit 5f37b51

Please sign in to comment.