Skip to content

Commit

Permalink
ci: refactor e2e cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed May 20, 2024
1 parent c95eb7c commit 306500f
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 75 deletions.
18 changes: 18 additions & 0 deletions .github/actions/build-and-push-ci-image/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
105 changes: 105 additions & 0 deletions .github/actions/setup-greptimedb-cluster/action.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .github/actions/setup-kind/action.yml
Original file line number Diff line number Diff line change
@@ -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
129 changes: 54 additions & 75 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions docker/ci/ubuntu/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 306500f

Please sign in to comment.