From 537bab5683fcfe655d58366b76c2a6ed99a8e3f9 Mon Sep 17 00:00:00 2001 From: TomHellier Date: Thu, 2 Dec 2021 16:47:48 +0000 Subject: [PATCH] Improve github CI, and helm default docker version (#1415) Add a docker build into the github CI, even if we don't use it, and also stop using latest as the default container version, as it is clearly wrong, and the latest tag hasn't been updated in a long time. travis-ci.org has stopped building the code for this repository as well, so we should focus on github workflows. Ideally we'd move the building of the docker container into github as well because then at least all CI is managed in one place. Signed-off-by: Tom Hellier --- .github/workflows/main.yaml | 29 ++++++++++++-- .github/workflows/release.yaml | 38 +++++++++++++++++-- .travis.gofmt.sh | 24 ------------ .travis.yml | 29 -------------- Makefile | 14 +++++-- README.md | 1 - charts/spark-operator-chart/.helmignore | 1 + charts/spark-operator-chart/Chart.yaml | 4 +- charts/spark-operator-chart/ci/ci-values.yaml | 2 + charts/spark-operator-chart/values.yaml | 4 +- test/e2e/README.md | 3 +- 11 files changed, 79 insertions(+), 70 deletions(-) delete mode 100755 .travis.gofmt.sh delete mode 100644 .travis.yml create mode 100644 charts/spark-operator-chart/.helmignore create mode 100644 charts/spark-operator-chart/ci/ci-values.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 521901928..c02f065e0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -47,6 +47,12 @@ jobs: with: fetch-depth: 2 + - name: Build Spark-Operator Docker Image + run: | + tag=$(git describe --tags --dirty)_v3.1.1 + docker build -t gcr.io/spark-operator/spark-operator:${tag} . + docker build -t gcr.io/spark-operator/spark-operator:local . + - name: Install Helm uses: azure/setup-helm@v1 with: @@ -68,8 +74,25 @@ jobs: - name: Detect CRDs drift between chart and manifest run: make detect-crds-drift - - name: Create kind cluster - uses: helm/kind-action@v1.2.0 + - name: setup minikube + uses: manusa/actions-setup-minikube@v2.4.2 + with: + minikube version: "v1.24.0" + kubernetes version: "v1.20.8" + start args: --memory 6g --cpus=2 --addons ingress + github token: ${{ inputs.github-token }} - name: Run chart-testing (install) - run: ct install + run: | + tag=$(git describe --tags --dirty)_v3.1.1 + minikube image load gcr.io/spark-operator/spark-operator:local + ct install + + # The integration tests are currently broken see: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/issues/1416 + # - name: Run chart-testing (integration test) + # run: make it-test + + - name: Setup tmate session + if: failure() + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 15 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 46fae8d7f..0754b7f70 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,6 +28,24 @@ jobs: with: python-version: 3.7 + # TODO: Maintainer of repository to follow: + # https://github.com/docker/login-action#google-container-registry-gcr to add credentials so + # we can push from github actions + # - name: log in to container registry + # uses: docker/login-action@v1 + # with: + # registry: gcr.io + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Spark-Operator Docker Image + run: | + tag=$(git describe --tags --dirty)_v3.1.1 + docker build -t gcr.io/spark-operator/spark-operator:${tag} . + docker build -t gcr.io/spark-operator/spark-operator:local . + echo "Ideally, we'd release the docker container at this point, but the maintainer of this repo needs to approve..." + echo "docker push gcr.io/spark-operator/spark-operator:${tag}" + - name: Set up chart-testing uses: helm/chart-testing-action@v2.0.1 @@ -42,15 +60,27 @@ jobs: - name: Run chart-testing (lint) run: ct lint - - name: Create kind cluster - uses: helm/kind-action@v1.2.0 - if: steps.list-changed.outputs.changed == 'true' + - name: setup minikube + uses: manusa/actions-setup-minikube@v2.4.2 + with: + minikube version: "v1.24.0" + kubernetes version: "v1.20.8" + start args: --memory 6g --cpus=2 --addons ingress + github token: ${{ inputs.github-token }} - name: Run chart-testing (install) - run: ct install + run: | + tag=$(git describe --tags --dirty)_v3.1.1 + minikube image load gcr.io/spark-operator/spark-operator:local + ct install - name: Run chart-releaser uses: helm/chart-releaser-action@v1.1.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" CR_RELEASE_NAME_TEMPLATE: "spark-operator-chart-{{ .Version }}" + + - name: Setup tmate session + if: failure() + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 15 diff --git a/.travis.gofmt.sh b/.travis.gofmt.sh deleted file mode 100755 index d56c12fa5..000000000 --- a/.travis.gofmt.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cd "$(dirname $0)" -if [ -n "$(go fmt ./...)" ]; -then - echo "Go code is not formatted, please run 'go fmt ./...'." >&2 - exit 1 -else - echo "Go code is formatted" -fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7731a7b5f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 2017 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -language: go - -go: - - 1.15.x - -go_import_path: github.com/GoogleCloudPlatform/spark-on-k8s-operator - -script: - - go test -v ./... - - ./.travis.gofmt.sh - - - diff --git a/Makefile b/Makefile index cca336495..95138d913 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,14 @@ helm-docs: helm-docs -c ./charts fmt-check: clean - @echo "running fmt check" - ./.travis.gofmt.sh + @echo "running fmt check"; cd "$(dirname $0)"; \ + if [ -n "$(go fmt ./...)" ]; \ + then \ + echo "Go code is not formatted, please run 'go fmt ./...'." >&2; \ + exit 1; \ + else \ + echo "Go code is formatted"; \ + fi detect-crds-drift: diff -q charts/spark-operator-chart/crds manifest/crds --exclude=kustomization.yaml @@ -62,9 +68,9 @@ test: clean go test -v ./... -covermode=atomic -it-test: clean all +it-test: clean @echo "running unit tests" - go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:v1beta2-1.3.0-3.1.1 + go test -v ./test/e2e/ --kubeconfig "$(HOME)/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:local vet: @echo "running go vet" diff --git a/README.md b/README.md index a4c8cbb74..0e3eb0efd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Build Status](https://travis-ci.org/GoogleCloudPlatform/spark-on-k8s-operator.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/spark-on-k8s-operator.svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/GoogleCloudPlatform/spark-on-k8s-operator)](https://goreportcard.com/report/github.com/GoogleCloudPlatform/spark-on-k8s-operator) **This is not an officially supported Google product.** diff --git a/charts/spark-operator-chart/.helmignore b/charts/spark-operator-chart/.helmignore new file mode 100644 index 000000000..f996f51be --- /dev/null +++ b/charts/spark-operator-chart/.helmignore @@ -0,0 +1 @@ +ci/ \ No newline at end of file diff --git a/charts/spark-operator-chart/Chart.yaml b/charts/spark-operator-chart/Chart.yaml index 4bae7c859..a32dfb629 100644 --- a/charts/spark-operator-chart/Chart.yaml +++ b/charts/spark-operator-chart/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: spark-operator description: A Helm chart for Spark on Kubernetes operator -version: 1.1.14 -appVersion: v1beta2-1.3.0-3.1.1 +version: 1.1.15 +appVersion: v1beta2-1.3.1-3.1.1 keywords: - spark home: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator diff --git a/charts/spark-operator-chart/ci/ci-values.yaml b/charts/spark-operator-chart/ci/ci-values.yaml new file mode 100644 index 000000000..13d37731c --- /dev/null +++ b/charts/spark-operator-chart/ci/ci-values.yaml @@ -0,0 +1,2 @@ +image: + tag: "local" diff --git a/charts/spark-operator-chart/values.yaml b/charts/spark-operator-chart/values.yaml index f481732c9..8e4b510fd 100644 --- a/charts/spark-operator-chart/values.yaml +++ b/charts/spark-operator-chart/values.yaml @@ -11,8 +11,8 @@ image: repository: gcr.io/spark-operator/spark-operator # -- Image pull policy pullPolicy: IfNotPresent - # -- Overrides the image tag whose default is the chart appVersion. - tag: "latest" + # -- if set, override the image tag whose default is the chart appVersion. + tag: "" # -- Image pull secrets imagePullSecrets: [] diff --git a/test/e2e/README.md b/test/e2e/README.md index b8dc9d133..d29f882aa 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -12,7 +12,8 @@ Prerequisites: e2e tests are written as Go test. All go test techniques apply (e.g. picking what to run, timeout length). Let's say I want to run all tests in "test/e2e/": ```bash -$ go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:v1beta2-1.3.0-3.1.1 +$ docker build -t gcr.io/spark-operator/spark-operator:local . +$ go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:local ``` ### Available Tests