diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..90222cb --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f0a129d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: main - -on: ['push', 'pull_request'] - -jobs: - markdown-lint: - name: Markdown Lint - runs-on: ubuntu-22.04 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Lint Code Base - uses: github/super-linter@v4 - env: - VALIDATE_MARKDOWN: true - VALIDATE_ALL_CODEBASE: false - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - LINTER_RULES_PATH: / - MARKDOWN_CONFIG_FILE: .markdownlint.yml - - - golang-test: - name: Golang Test - runs-on: ubuntu-22.04 - strategy: - matrix: - go-version: ['1.23'] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - uses: actions/checkout@v4 - - name: Setup Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} - - name: Display Go version - run: go version - - name: Install dependencies - run: go get ./... - - name: Test with Go - run: make test - - - golang-lint: - name: golang-lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: '1.23' - cache: false - - name: golangci-lint - run: | - make lint - - - chainsaw-test: - name: Chainsaw Test - runs-on: ubuntu-22.04 - strategy: - matrix: - k8s-version: ['1.26.14', '1.27.11'] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: '1.23' - cache: false - - name: Create KinD clustet - 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 - - - deploy-operator: - name: Deploy operator - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'zncdatadev' }} - runs-on: ubuntu-22.04 - needs: - - golang-lint - - golang-test - - chainsaw-test - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - 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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..19a8df8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d7c218a --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..aef8e9b --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index 2e68b46..93779fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Kubedoop Operator for Apache Kafka -[![Build](https://github.com/zncdatadev/kafka-operator/actions/workflows/main.yml/badge.svg)](https://github.com/zncdatadev/kafka-operator/actions/workflows/main.yml) +[![Build](https://github.com/zncdatadev/kafka-operator/actions/workflows/publish.yml/badge.svg)](https://github.com/zncdatadev/kafka-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/kafka-operator)](https://goreportcard.com/report/github.com/zncdatadev/kafka-operator) [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kafka-operator)](https://artifacthub.io/packages/helm/kubedoop/kafka-operator)