From 07fe4242314b966684c3eefe84c26b332430324a Mon Sep 17 00:00:00 2001 From: whg517 Date: Thu, 29 Aug 2024 20:03:30 +0800 Subject: [PATCH] ci: enable deploy dev image (#85) --- .github/workflows/e2e.yml | 37 -------- .github/workflows/{ci.yml => main.yml} | 113 ++++++++++++++++--------- Makefile | 16 ++-- catalog-template.yaml | 4 +- 4 files changed, 85 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/e2e.yml rename .github/workflows/{ci.yml => main.yml} (73%) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index e182e26..0000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,37 +0,0 @@ -# e2e test - -name: e2e-test - -on: ['push', 'pull_request'] - -jobs: - 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.22' - cache: false - - name: Create KinD cluster - 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/.github/workflows/ci.yml b/.github/workflows/main.yml similarity index 73% rename from .github/workflows/ci.yml rename to .github/workflows/main.yml index fe80980..1831cf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/main.yml @@ -1,30 +1,26 @@ -name: CI +name: main on: ['push', 'pull_request'] jobs: - - golang-test: - name: Golang Test + markdown-lint: + name: Markdown Lint runs-on: ubuntu-22.04 - strategy: - matrix: - go-version: ['1.22'] steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - uses: actions/checkout@v4 - - name: Setup Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 + - name: Checkout Code + uses: actions/checkout@v3 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 + 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-lint: name: Golang Lint @@ -69,32 +65,70 @@ jobs: # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. # install-mode: "goinstall" - markdown-lint: - name: Markdown Lint + + golang-test: + name: Golang Test runs-on: ubuntu-22.04 + strategy: + matrix: + go-version: ['1.22'] steps: - - name: Checkout Code - uses: actions/checkout@v3 + - 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 + 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 + + + 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.22' + cache: false + - name: Create KinD cluster + 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_type == 'tag' && github.repository_owner == 'zncdatadev' + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'zncdatadev' }} runs-on: ubuntu-22.04 needs: - - golang-test - - markdown-lint - golang-lint + - golang-test + - chainsaw-test steps: - uses: actions/checkout@v3 with: @@ -111,7 +145,6 @@ jobs: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} - - name: Build and push operator run: | make docker-buildx @@ -119,3 +152,7 @@ jobs: run: | make bundle make bundle-buildx + - name: Build and push catalog + run: | + make catalog + make catalog-buildx diff --git a/Makefile b/Makefile index 8b9f628..7fc8b2e 100644 --- a/Makefile +++ b/Makefile @@ -300,8 +300,8 @@ endif # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:latest -.PHONY: catalog-build -catalog-build: opm ## Build a catalog manifests. +.PHONY: catalog +catalog: opm ## Build a catalog manifests. mkdir -p catalog @if ! test -f ./catalog.Dockerfile; then \ $(OPM) generate dockerfile catalog; \ @@ -309,17 +309,17 @@ catalog-build: opm ## Build a catalog manifests. sed -E "s|(image: ).*-bundle:v$(VERSION)|\1$(BUNDLE_IMG)|g" catalog-template.yaml | \ $(OPM) alpha render-template basic -o yaml > catalog/catalog.yaml -.PHONY: catalog-docker-build -catalog-docker-build: ## Build a catalog image. +.PHONY: catalog-build +catalog-build: ## Build a catalog image. $(CONTAINER_TOOL) build -t ${CATALOG_IMG} -f catalog.Dockerfile . # Push the catalog image. -.PHONY: catalog-docker-push -catalog-docker-push: ## Push a catalog image. +.PHONY: catalog-push +catalog-push: ## Push a catalog image. $(MAKE) docker-push IMG=$(CATALOG_IMG) -.PHONY: catalog-docker-buildx -catalog-docker-buildx: ## Build and push a catalog image for cross-platform support +.PHONY: catalog-buildx +catalog-buildx: ## Build and push a catalog image for cross-platform support - $(CONTAINER_TOOL) buildx create --name project-v3-builder $(CONTAINER_TOOL) buildx use project-v3-builder - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) -f catalog.Dockerfile --tag ${CATALOG_IMG} . diff --git a/catalog-template.yaml b/catalog-template.yaml index 3b3dbcd..53873ed 100644 --- a/catalog-template.yaml +++ b/catalog-template.yaml @@ -105,7 +105,7 @@ schema: olm.channel package: zookeeper-operator name: stable entries: - - name: zookeeper-operator.v0.0.1 + - name: zookeeper-operator.v0.0.0-dev --- schema: olm.bundle -image: quay.io/zncdatadev/zookeeper-operator-bundle:v0.0.1 \ No newline at end of file +image: quay.io/zncdatadev/zookeeper-operator-bundle:0.0.0-dev