From e451bf62289ff293eb131ce5315427017625f916 Mon Sep 17 00:00:00 2001 From: bococ Date: Tue, 17 Oct 2023 19:57:32 +0800 Subject: [PATCH 1/3] feat: Add CI for spark-k8s-operator --- .github/workflows/main.yml | 82 ++++++++++++++++++++++++++++++++++++++ .github/workflows/tags.yml | 80 +++++++++++++++++++++++++++++++++++++ .markdownlint.yml | 20 ++++++++++ Makefile | 4 +- 4 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/tags.yml create mode 100644 .markdownlint.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ef79310 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,82 @@ +# 定义工作流的名称 +name: Build and Push Docker Image + +on: + workflow_dispatch: # 允许手动触发工作流 + push: # 当有代码推送事件发生时 + branches: + - main # 只有推送到 master 分支时才触发 + pull_request: + + +# 定义工作流的任务 +jobs: + build: + # 定义运行此任务的环境:最新版本的 ubuntu + runs-on: ubuntu-latest + + # 定义任务中的步骤 + steps: + # 检出代码。只检出最新的1次提交 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # 设置 QEMU 模拟器,这通常用于多平台的 Docker 构建 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + # 设置 Docker Buildx,用于构建多平台的 Docker 镜像 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - run: | + export VERSION=0.0.1-alpha + make docker-build + + linting: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + 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 + + deploy: + if: github.event_name == 'push' && github.repository == 'zncdata-labs/spark-k8s-operator' + runs-on: ubuntu-latest + needs: + - build + - linting + + steps: + # 检出代码。只检出最新的1次提交 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # 登录到 QUAY Hub + - name: Login to quay.io + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} # 使用存储在 GitHub Secrets 中的 QUAY 用户名 + password: ${{ secrets.QUAY_PASSWORD }} # 使用存储在 GitHub Secrets 中的 QUAY 密码 + + - name: Build and push Docker image + run: | + export VERSION=0.0.1-alpha + make docker-buildx + make bundle + make bundle-buildx \ No newline at end of file diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml new file mode 100644 index 0000000..1da0e64 --- /dev/null +++ b/.github/workflows/tags.yml @@ -0,0 +1,80 @@ +# 定义工作流的名称 +name: Build and Push Docker Image + +on: + workflow_dispatch: # 允许手动触发工作流 + push: # 当有代码推送事件发生时 + tags: + - '*' + +# 定义工作流的任务 +jobs: + build: + # 定义运行此任务的环境:最新版本的 ubuntu + runs-on: ubuntu-latest + + # 定义任务中的步骤 + steps: + # 检出代码。只检出最新的1次提交 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # 设置 QEMU 模拟器,这通常用于多平台的 Docker 构建 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + # 设置 Docker Buildx,用于构建多平台的 Docker 镜像 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - run: | + export VERSION=$GITHUB_REF_NAME + make docker-build + + linting: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + 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 + + deploy: + if: github.event_name == 'push' && github.repository == 'zncdata-labs/spark-k8s-operator' + runs-on: ubuntu-latest + needs: + - build + - linting + + steps: + # 检出代码。只检出最新的1次提交 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # 登录到 QUAY Hub + - name: Login to quay.io + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} # 使用存储在 GitHub Secrets 中的 QUAY 用户名 + password: ${{ secrets.QUAY_PASSWORD }} # 使用存储在 GitHub Secrets 中的 QUAY 密码 + + - name: Build and push Docker image + run: | + export VERSION=$GITHUB_REF_NAME + make docker-buildx + make bundle + make bundle-buildx diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..45d588e --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,20 @@ +MD007: + indent: 4 + start_indented: false + +MD013: + line_length: 200 + heading_line_length: 80 + code_block_line_length: 200 + code_blocks: true + tables: true + headings: true + headers: true + strict: false + stern: false + +MD012: + maximum: 20 + +MD046: false +MD051: false \ No newline at end of file diff --git a/Makefile b/Makefile index 1a0edcb..f43785e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # To re-generate a bundle for another specific version without changing the standard setup, you can: # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) -VERSION ?= 0.0.2 +VERSION ?= 0.0.1 # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") @@ -260,7 +260,7 @@ ifeq (,$(shell which opm 2>/dev/null)) set -e ;\ mkdir -p $(dir $(OPM)) ;\ OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.29.0/$${OS}-$${ARCH}-opm ;\ chmod +x $(OPM) ;\ } else From d0d422c60d75d4e840df0644131fad132287f745 Mon Sep 17 00:00:00 2001 From: bococ Date: Wed, 18 Oct 2023 09:10:48 +0800 Subject: [PATCH 2/3] feat: Add CI for spark-k8s-operator --- .github/workflows/main.yml | 2 -- Makefile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef79310..265ad44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - run: | - export VERSION=0.0.1-alpha make docker-build linting: @@ -76,7 +75,6 @@ jobs: - name: Build and push Docker image run: | - export VERSION=0.0.1-alpha make docker-buildx make bundle make bundle-buildx \ No newline at end of file diff --git a/Makefile b/Makefile index f43785e..0707e09 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # To re-generate a bundle for another specific version without changing the standard setup, you can: # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) -VERSION ?= 0.0.1 +VERSION ?= 0.0.1-alpha # CHANNELS define the bundle channels used in the bundle. # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable") From 7af631986605fde166b01cc3fd2ab9379f9231cb Mon Sep 17 00:00:00 2001 From: bococ Date: Wed, 18 Oct 2023 09:49:53 +0800 Subject: [PATCH 3/3] feat: Merge main tag branch to ci --- .github/workflows/{tags.yml => ci.yml} | 40 +++++++++++-- .github/workflows/main.yml | 80 -------------------------- 2 files changed, 35 insertions(+), 85 deletions(-) rename .github/workflows/{tags.yml => ci.yml} (66%) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/tags.yml b/.github/workflows/ci.yml similarity index 66% rename from .github/workflows/tags.yml rename to .github/workflows/ci.yml index 1da0e64..10c8016 100644 --- a/.github/workflows/tags.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,15 @@ # 定义工作流的名称 -name: Build and Push Docker Image +name: CI on: workflow_dispatch: # 允许手动触发工作流 push: # 当有代码推送事件发生时 + branches: + - main # 只有推送到 main 分支时才触发 tags: - '*' + pull_request: + # 定义工作流的任务 jobs: @@ -28,7 +32,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - run: | - export VERSION=$GITHUB_REF_NAME make docker-build linting: @@ -51,8 +54,8 @@ jobs: LINTER_RULES_PATH: / MARKDOWN_CONFIG_FILE: .markdownlint.yml - deploy: - if: github.event_name == 'push' && github.repository == 'zncdata-labs/spark-k8s-operator' + main: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'bococ/redis-operator' runs-on: ubuntu-latest needs: - build @@ -74,7 +77,34 @@ jobs: - name: Build and push Docker image run: | - export VERSION=$GITHUB_REF_NAME make docker-buildx make bundle make bundle-buildx + + tags: + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'bococ/redis-operator' + runs-on: ubuntu-latest + needs: + - build + - linting + + steps: + # 检出代码。只检出最新的1次提交 + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # 登录到 QUAY Hub + - name: Login to quay.io + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} # 使用存储在 GitHub Secrets 中的 QUAY 用户名 + password: ${{ secrets.QUAY_PASSWORD }} # 使用存储在 GitHub Secrets 中的 QUAY 密码 + + - name: Build and push Docker image + run: | + export VERSION=$GITHUB_REF_NAME + make docker-buildx + make bundle + make bundle-buildx \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 265ad44..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,80 +0,0 @@ -# 定义工作流的名称 -name: Build and Push Docker Image - -on: - workflow_dispatch: # 允许手动触发工作流 - push: # 当有代码推送事件发生时 - branches: - - main # 只有推送到 master 分支时才触发 - pull_request: - - -# 定义工作流的任务 -jobs: - build: - # 定义运行此任务的环境:最新版本的 ubuntu - runs-on: ubuntu-latest - - # 定义任务中的步骤 - steps: - # 检出代码。只检出最新的1次提交 - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - # 设置 QEMU 模拟器,这通常用于多平台的 Docker 构建 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - # 设置 Docker Buildx,用于构建多平台的 Docker 镜像 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - run: | - make docker-build - - linting: - name: Lint Code Base - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - 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 - - deploy: - if: github.event_name == 'push' && github.repository == 'zncdata-labs/spark-k8s-operator' - runs-on: ubuntu-latest - needs: - - build - - linting - - steps: - # 检出代码。只检出最新的1次提交 - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - # 登录到 QUAY Hub - - name: Login to quay.io - uses: docker/login-action@v2 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} # 使用存储在 GitHub Secrets 中的 QUAY 用户名 - password: ${{ secrets.QUAY_PASSWORD }} # 使用存储在 GitHub Secrets 中的 QUAY 密码 - - - name: Build and push Docker image - run: | - make docker-buildx - make bundle - make bundle-buildx \ No newline at end of file