diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..776166a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,145 @@ +name: CI + +on: + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +env: + GO_VERSION_FILE: go.mod + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ env.GO_VERSION_FILE }} + + - name: Run lint + run: make lint + + test: + name: Unit Tests + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ env.GO_VERSION_FILE }} + + - name: Run unit tests + run: make test + + - name: Upload coverage artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: coverage-report + path: cover.out + retention-days: 7 + + build: + name: Build + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ env.GO_VERSION_FILE }} + + - name: Build binary + run: make build + + verify-codegen: + name: Verify Code Generation + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ env.GO_VERSION_FILE }} + + - name: Run code generation + run: make manifests generate + + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "::error::Generated code is out of date. Run 'make manifests generate' and commit the changes." + git diff + exit 1 + fi + + helm-lint: + name: Helm Lint + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Setup Helm + uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0 + + - name: Setup chart-testing + uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0 + + - name: Run chart-testing lint + run: ct lint --all --validate-maintainers=false + + helm-docs: + name: Verify Helm Docs + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install helm-docs + run: | + HELM_DOCS_VERSION="1.14.2" + curl -fsSL "https://github.com/norwoodj/helm-docs/releases/download/v${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION}_Linux_x86_64.tar.gz" | tar -xzv helm-docs + sudo mv helm-docs /usr/local/bin/helm-docs + + - name: Run helm-docs + run: helm-docs --document-dependency-values + + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "::error::Helm docs are out of date. Run 'helm-docs --document-dependency-values' and commit the changes." + git diff + exit 1 + fi diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000..23e2075 --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,81 @@ +name: Integration Tests + +on: + pull_request: # TODO: remove after validating — keep only workflow_dispatch + issue_comment + branches: [main] + workflow_dispatch: + inputs: + doltdb_engine_version: + description: "DoltDB engine version to test against" + required: false + default: "1.83.6" + issue_comment: + types: [created] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: read + +env: + GO_VERSION_FILE: go.mod + DOLTDB_ENGINE_VERSION: ${{ github.event.inputs.doltdb_engine_version || '1.83.6' }} + KIND_CLUSTER_NAME: dolt + +jobs: + integration-tests: + name: Integration Tests (kind + tilt) + runs-on: ubuntu-latest + timeout-minutes: 45 + if: >- + github.event_name == 'pull_request' || + github.event_name == 'workflow_dispatch' || + (github.event.issue.pull_request && contains(github.event.comment.body, '/test-integration')) + permissions: + contents: read + pull-requests: read + steps: + - name: Checkout PR branch (comment trigger) + if: github.event_name == 'issue_comment' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: refs/pull/${{ github.event.issue.number }}/merge + + - name: Checkout + if: github.event_name != 'issue_comment' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: ${{ env.GO_VERSION_FILE }} + + - name: Install kind + run: | + KIND_VERSION="v0.30.0" + curl -Lo ./kind "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64" + chmod +x ./kind + sudo mv ./kind /usr/local/bin/kind + + - name: Create kind cluster + run: kind create cluster --name ${{ env.KIND_CLUSTER_NAME }} --config hack/manifests/kind/kind-ci.yaml + + - name: Install tilt + run: | + TILT_VERSION="0.33.21" + curl -fsSL "https://github.com/tilt-dev/tilt/releases/download/v${TILT_VERSION}/tilt.${TILT_VERSION}.linux.x86_64.tar.gz" | tar -xzv tilt + sudo mv tilt /usr/local/bin/tilt + + - name: Install kustomize + run: make kustomize + + - name: Set cluster context + run: kubectl config use-context kind-${{ env.KIND_CLUSTER_NAME }} + + - name: Run integration tests + run: tilt ci + env: + DOLTDB_ENGINE_VERSION: ${{ env.DOLTDB_ENGINE_VERSION }} diff --git a/charts/doltdb-operator/README.md b/charts/doltdb-operator/README.md index 3dc0431..e153773 100644 --- a/charts/doltdb-operator/README.md +++ b/charts/doltdb-operator/README.md @@ -13,8 +13,8 @@ A Helm chart for Kubernetes deployment of Dolt operator | existingClusterRole | string | `""` | Name of an existing ClusterRole to use when installClusterRole is false. If not set, defaults to the fullname. | | fullnameOverride | string | `""` | | | image.pullPolicy | string | `"IfNotPresent"` | | -| image.repository | string | `"%%image_repository%%"` | | -| image.tag | string | `"%%image_tag%%"` | | +| image.repository | string | `"ghcr.io/electronicarts/doltdb-operator"` | | +| image.tag | string | `""` | | | imagePullSecrets | list | `[]` | | | installClusterRole | bool | `true` | A boolean flag indicating whether ClusterRole and ClusterRoleBinding should be installed. Set to false for secondary installations. Default: true. | | installCrds | bool | `false` | A boolean flag indicating whether CRDs should be installed. Set to false when using the standalone doltdb-operator-crds chart. Default: false. |