diff --git a/.github/actions/build-and-push-ci-image/action.yml b/.github/actions/build-and-push-ci-image/action.yml new file mode 100644 index 000000000000..5c7d0532ce02 --- /dev/null +++ b/.github/actions/build-and-push-ci-image/action.yml @@ -0,0 +1,18 @@ +name: Build and push CI Docker image +description: Build and push CI Docker image to local registry +inputs: + binary_path: + default: "./bin" + description: "Binary path" +runs: + using: composite + steps: + - name: Build and push to local registry + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/ci/ubuntu/Dockerfile.ci + push: true + tags: localhost:5001/greptime/greptimedb:latest + build-args: | + BINARY_PATH=${{ inputs.binary_path }} diff --git a/.github/actions/setup-greptimedb-cluster/action.yml b/.github/actions/setup-greptimedb-cluster/action.yml new file mode 100644 index 000000000000..a175947369f3 --- /dev/null +++ b/.github/actions/setup-greptimedb-cluster/action.yml @@ -0,0 +1,105 @@ +name: Setup GreptimeDB cluster +description: Deploy GreptimeDB cluster on Kubernetes +inputs: + frontend-replica-count: + default: 1 + description: "Frontend replica count" + datanode-replica-count: + default: 2 + description: "Datanode replica count" + metasrv-replica-count: + default: 1 + description: "Metasrv replica count" + etcd-replica-count: + default: 1 + description: "Etcd replica count" + image-registry: + default: "docker.io" + description: "Image registry" + image-repository: + default: "greptime/greptimedb" + description: "Image repository" + image-tag: + required: true + description: 'Image tag' + +runs: + using: composite + steps: + - name: Install greptime operator + shell: bash + run: | + helm repo add greptime https://greptimeteam.github.io/helm-charts/ + helm repo update + helm upgrade \ + --install \ + --create-namespace \ + greptimedb-operator greptime/greptimedb-operator \ + -n greptimedb-admin + - name: Install etcd cluster + shell: bash + run: | + helm upgrade \ + --install etcd oci://registry-1.docker.io/bitnamicharts/etcd \ + --set replicaCount=${{ inputs.etcd-replica-count }} \ + --set auth.rbac.create=false \ + --set auth.rbac.token.enabled=false \ + --set persistence.size=1Gi \ + --create-namespace \ + -n etcd-cluster + - name: Wait for etcd + run: | + kubectl wait \ + --for=condition=Ready \ + pod -l app.kubernetes.io/instance=etcd \ + --timeout=120s \ + -n etcd-cluster + - name: Print etcd info + run: kubectl get all --show-labels -n etcd-cluster + - name: Install GreptimeDB cluster + shell: bash + run: | + helm upgrade \ + --install my-greptimedb \ + --set meta.etcdEndpoints=etcd.etcd-cluster.svc.cluster.local:2379 \ + --set image.registry=${{ inputs.image-registry }} \ + --set image.repository=${{ inputs.image-repository }} \ + --set image.tag=${{ inputs.image-tag }} \ + greptime/greptimedb-cluster \ + --create-namespace \ + -n my-greptimedb + - name: Wait for GreptimeDB + shell: bash + run: | + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-meta \ + --timeout=120s \ + -n my-greptimedb + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-datanode \ + --timeout=120s \ + -n my-greptimedb + kubectl wait \ + --for=condition=Ready \ + pod -l app.greptime.io/component=my-greptimedb-frontend \ + --timeout=120s \ + -n my-greptimedb + - name: Print GreptimeDB info + if: always() + shell: bash + run: | + kubectl get all --show-labels -n my-greptimedb + - name: Export kind logs + if: failure() + shell: bash + run: | + kind export logs /tmp/kind + - name: Upload logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: kind-logs + path: /tmp/kind + retention-days: 3 \ No newline at end of file diff --git a/.github/actions/setup-kind/action.yml b/.github/actions/setup-kind/action.yml new file mode 100644 index 000000000000..ae1b71ea4ad2 --- /dev/null +++ b/.github/actions/setup-kind/action.yml @@ -0,0 +1,16 @@ +name: Setup Kind +description: Deploy Kind +runs: + using: composite + steps: + - uses: actions/checkout@v4 + - name: Install Kind + shell: bash + run: | + [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64 + chmod +x ./kind + sudo mv ./kind /usr/local/bin/kind + - name: Create kind cluster + shell: bash + run: | + ./.github/scripts/kind-with-registry.sh \ No newline at end of file diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 31e7b3c1d035..61339087c607 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -231,86 +231,65 @@ jobs: path: /tmp/unstable-greptime/ retention-days: 3 + build-greptime-ci: + name: Build GreptimeDB binary (profile-CI) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-20.04 ] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + - uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: Swatinem/rust-cache@v2 + with: + # Shares across multiple jobs + shared-key: "build-greptime-ci" + - name: Install cargo-gc-bin + shell: bash + run: cargo install cargo-gc-bin + - name: Build greptime bianry + shell: bash + # `cargo gc` will invoke `cargo build` with specified args + run: cargo build --bin greptime --profile ci + - name: Pack greptime binary + shell: bash + run: | + mkdir bin && \ + mv ./target/ci/greptime bin + - name: Print greptime binaries info + run: ls -lh bin + - name: Upload artifacts + uses: ./.github/actions/upload-artifacts + with: + artifacts-dir: bin + version: current + e2e: runs-on: ubuntu-latest + needs: build-greptime-ci steps: - uses: actions/checkout@v4 - - name: Install Kind - run: | - [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64 - chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind - - name: Create kind cluster - run: | - ./.github/scripts/kind-with-registry.sh - - name: Install greptime operator - run: | - helm repo add greptime https://greptimeteam.github.io/helm-charts/ - helm repo update - helm upgrade \ - --install \ - --create-namespace \ - greptimedb-operator greptime/greptimedb-operator \ - -n greptimedb-admin - - name: Install etcd cluster - run: | - helm upgrade \ - --install etcd oci://registry-1.docker.io/bitnamicharts/etcd \ - --set replicaCount=1 \ - --set auth.rbac.create=false \ - --set auth.rbac.token.enabled=false \ - --set persistence.size=1Gi \ - --create-namespace \ - -n etcd-cluster - - name: Wait for etcd - run: | - kubectl wait \ - --for=condition=Ready \ - pod -l app.kubernetes.io/instance=etcd \ - --timeout=120s \ - -n etcd-cluster - - name: Print etcd info - run: kubectl get all --show-labels -n etcd-cluster - - name: Install GreptimeDB cluster - run: | - helm upgrade \ - --install my-greptimedb \ - --set meta.etcdEndpoints=etcd.etcd-cluster.svc.cluster.local:2379 \ - greptime/greptimedb-cluster \ - --create-namespace \ - -n my-greptimedb - - name: Wait for GreptimeDB - run: | - kubectl wait \ - --for=condition=Ready \ - pod -l app.greptime.io/component=my-greptimedb-meta \ - --timeout=120s \ - -n my-greptimedb - kubectl wait \ - --for=condition=Ready \ - pod -l app.greptime.io/component=my-greptimedb-datanode \ - --timeout=120s \ - -n my-greptimedb - kubectl wait \ - --for=condition=Ready \ - pod -l app.greptime.io/component=my-greptimedb-frontend \ - --timeout=120s \ - -n my-greptimedb - - name: Print GreptimeDB info - if: always() - run: | - kubectl get all --show-labels -n my-greptimedb - - name: Export kind logs - if: failure() - run: | - kind export logs /tmp/kind - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v4 + - name: Setup Kind + uses: ./.github/actions/setup-kind + - name: Download pre-built binariy + uses: actions/download-artifact@v4 with: - name: kind-logs - path: /tmp/kind - retention-days: 3 + name: bin + path: . + - name: Unzip binary + run: tar -xvf ./bin.tar.gz + - name: Build and push GreptimeDB image + uses: ./.github/actions/build-and-push-ci-image + - name: Setup GreptimeDB cluster + uses: ./.github/actions/setup-greptimedb-cluster + with: + image-registry: localhost:5001 sqlness: name: Sqlness Test diff --git a/Cargo.toml b/Cargo.toml index 1ece9e77fabc..e81050ddfb75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -246,6 +246,11 @@ lto = "thin" debug = false incremental = false +[profile.ci] +inherits = "dev" +debug = false +strip = true + [profile.dev.package.sqlness-runner] debug = false strip = true diff --git a/docker/ci/ubuntu/Dockerfile.ci b/docker/ci/ubuntu/Dockerfile.ci new file mode 100644 index 000000000000..247010f5ef04 --- /dev/null +++ b/docker/ci/ubuntu/Dockerfile.ci @@ -0,0 +1,16 @@ +FROM ubuntu:22.04 + +# The binary name of GreptimeDB executable. +# Defaults to "greptime", but sometimes in other projects it might be different. +ARG TARGET_BIN=greptime + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ca-certificates \ + curl + +ARG BINARY_PATH +ADD $BINARY_PATH/$TARGET_BIN /greptime/bin/ + +ENV PATH /greptime/bin/:$PATH + +ENTRYPOINT ["greptime"]