update GO and operator versions #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
- push | |
- workflow_dispatch | |
env: | |
GO_VERSION: "1.21.5" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go | |
uses: actions/[email protected] | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Checkout Repository | |
uses: actions/[email protected] | |
- name: Module and build cache | |
uses: actions/[email protected] | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-pkg-mod-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ env.GO_VERSION }} | |
- name: Set up Kubernetes using kind | |
uses: engineerd/[email protected] | |
with: | |
config: bootstrap/kind-config.yml | |
version: v0.18.0 | |
- name: Test Kubernetes | |
run: kubectl cluster-info | |
- name: Install Redis Enterprise operator | |
run: | | |
curl --silent --fail https://raw.githubusercontent.com/RedisLabs/redis-enterprise-k8s-docs/v7.2.4-12/bundle.yaml | kubectl apply -f - | |
kubectl rollout status deployment/redis-enterprise-operator --watch --timeout=5m || kubectl describe pod -lname=redis-enterprise-operator | |
- name: Install cluster | |
timeout-minutes: 10 | |
run: | | |
cat <<EOF | | |
apiVersion: "app.redislabs.com/v1" | |
kind: "RedisEnterpriseCluster" | |
metadata: | |
name: "test-cluster" | |
spec: | |
nodes: 3 | |
redisEnterpriseNodeResources: | |
limits: | |
cpu: 1000m | |
memory: 2Gi | |
requests: | |
cpu: 25m | |
memory: 2Gi | |
EOF | |
kubectl apply -f - | |
while [[ "$(kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status.state}')" != "Running" ]]; do | |
echo "waiting for the cluster to be running" | |
kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status}{"\n"}' | |
sleep 5; | |
done | |
echo "waiting loop has finished." | |
sleep 5; | |
kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status}{"\n"}' | |
- name: Install a service to expose the Redis cluster on a port | |
run: | | |
cat <<EOF | | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
app: redis-enterprise | |
redis.io/cluster: test-cluster | |
name: external-access | |
spec: | |
ports: | |
- name: api | |
port: 9443 | |
protocol: TCP | |
targetPort: 9443 | |
nodePort: 30000 | |
selector: | |
app: redis-enterprise | |
redis.io/cluster: test-cluster | |
redis.io/role: node | |
sessionAffinity: None | |
type: NodePort | |
EOF | |
kubectl apply -f - | |
- name: Set username | |
run: echo "TEST_USERNAME=$(kubectl get secret test-cluster --output jsonpath='{.data.username}' | base64 -d)" >> $GITHUB_ENV | |
- name: Set password | |
run: echo "TEST_PASSWORD=$(kubectl get secret test-cluster --output jsonpath='{.data.password}' | base64 -d)" >> $GITHUB_ENV | |
- name: Set URL | |
run: echo "TEST_DB_URL=https://localhost:$(kubectl get svc external-access --output jsonpath='{.spec.ports[].nodePort}')" >> $GITHUB_ENV | |
- name: Create role | |
timeout-minutes: 5 | |
run: | | |
curl --insecure "${TEST_DB_URL}/v1/roles" \ | |
--header "Content-Type: application/json" \ | |
-u "${TEST_USERNAME}:${TEST_PASSWORD}" \ | |
--data "{ | |
\"name\": \"DB Member\", | |
\"management\": \"db_member\" | |
}" | |
- name: Create ACL | |
timeout-minutes: 5 | |
run: | | |
curl --insecure "${TEST_DB_URL}/v1/redis_acls" \ | |
--header "Content-Type: application/json" \ | |
-u "${TEST_USERNAME}:${TEST_PASSWORD}" \ | |
--data "{ | |
\"name\": \"Not Dangerous\", | |
\"acl\": \"+@all -@dangerous ~*\" | |
}" | |
- name: Install database | |
timeout-minutes: 5 | |
run: | | |
cat <<EOF | | |
apiVersion: app.redislabs.com/v1alpha1 | |
kind: RedisEnterpriseDatabase | |
metadata: | |
name: mydb | |
spec: | |
memorySize: 100MB | |
redisEnterpriseCluster: | |
name: test-cluster | |
rolesPermissions: | |
- type: redis-enterprise | |
role: "DB Member" | |
acl: "Not Dangerous" | |
EOF | |
kubectl apply -f - | |
while [[ "$(kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status.status}')" != "active" ]]; do | |
echo "waiting for the database to be running" | |
kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status}{"\n"}' | |
sleep 5; | |
done | |
echo "waiting loop has finished." | |
sleep 5; | |
kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status}{"\n"}' | |
# This check is ensure that the cluster is running and accessible so the CI fails fast, | |
# rather than waiting several minutes for all of the Go tests to eventually time out | |
- name: Check cluster access | |
timeout-minutes: 2 | |
run: | | |
curl --silent --fail --insecure "${TEST_DB_URL}/v1/bdbs" --user "${TEST_USERNAME}:${TEST_PASSWORD}" | |
- name: Build | |
run: make |