Skip to content

Commit

Permalink
ci: refactor gh workflow (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwpk110 authored Nov 29, 2024
1 parent 5b1024c commit a3d7c6d
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 120 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
119 changes: 0 additions & 119 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
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kubedoop Operator for Apache Hadoop

[![Build](https://github.com/zncdatadev/hdfs-operator/actions/workflows/main.yml/badge.svg)](https://github.com/zncdatadev/hdfs-operator/actions/workflows/main.yml)
[![Build](https://github.com/zncdatadev/hdfs-operator/actions/workflows/publish.yml/badge.svg)](https://github.com/zncdatadev/hdfs-operator/actions/workflows/publish.yml)
[![LICENSE](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Go Report Card](https://goreportcard.com/badge/github.com/zncdatadev/hdfs-operator)](https://goreportcard.com/report/github.com/zncdatadev/hdfs-operator)
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/hdfs-operator)](https://artifacthub.io/packages/helm/kubedoop/hdfs-operator)
Expand Down

0 comments on commit a3d7c6d

Please sign in to comment.