Issue 240: Updating go version #369
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
# workflow name | |
name: CI | |
# on events | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
env: | |
PACKET_TOKEN: ${{ secrets.PACKET_TOKEN }} | |
# jobs to run | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.21 | |
uses: actions/setup-go@v2 | |
with: | |
go-version: "1.21" | |
id: go | |
- name: Set up Go for root | |
run: | | |
sudo ln -sf `which go` `sudo which go` || true | |
sudo go version | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" | |
- name: Get output | |
run: echo ${{ steps.date.outputs.date }} | |
- name: Set env | |
run: echo "CLUSTER_NAME=bookkeeper-operator-travis-${{ steps.date.outputs.date }}" >> $GITHUB_ENV | |
- name: Test | |
run: echo $CLUSTER_NAME | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Gofmt and License checks | |
run: make check | |
- name: unit tests | |
run: make test-unit | |
- name: Codecov | |
uses: codecov/codecov-action@v1.0.12 | |
- name: Installing Packet-cli | |
run: curl -Lo packet-cli https://github.com/packethost/packet-cli/releases/download/0.0.7/packet-linux-amd64 && chmod +x packet-cli && sudo mv packet-cli /usr/local/bin/ | |
- name: Installing ssh keys | |
run: | | |
ssh-keygen -f ~/.ssh/id_rsa -P "" | |
pub_key=$(cat ~/.ssh/id_rsa.pub) | |
echo "publc key is $pub_key" | |
echo "packet-cli ssh-key create --key \"$(cat ~/.ssh/id_rsa.pub)\" --label \"pravega\"" | |
packet-cli ssh-key create --key "$(cat ~/.ssh/id_rsa.pub)" --label "pravega-travis" | |
- name: Creating nodes | |
run: | | |
cd .. && tar -czvf bookkeeper-operator.tar.gz bookkeeper-operator | |
packet-cli device create -H $CLUSTER_NAME"-master" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11 | |
packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}' | |
CLUSTER_ID=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}' | tr -d ' ') | |
echo "cluster id is $CLUSTER_ID" | |
packet-cli device create -H $CLUSTER_NAME"-worker1" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11 | |
packet-cli device create -H $CLUSTER_NAME"-worker2" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11 | |
MASTER_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' ') | |
while [ "$MASTER_STATE" != "active" ]; do MASTER_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' '`;sleep 30;done | |
CLUSTER_IP=$(packet-cli device get -i $CLUSTER_ID -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' ') | |
echo "Cluster IP is $CLUSTER_IP" | |
WORKER1_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $10}' | tr -d ' ') | |
while [ "$WORKER1_STATE" != "active" ]; do WORKER1_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $10}' | tr -d ' '`;sleep 30;done | |
WORKER2_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $10}' | tr -d ' ') | |
while [ "$WORKER2_STATE" != "active" ]; do WORKER2_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $10}' | tr -d ' '`;sleep 30;done | |
echo "CLUSTER_ID=$CLUSTER_ID" >> $GITHUB_ENV | |
echo "CLUSTER_IP=$CLUSTER_IP" >> $GITHUB_ENV | |
pwd;ls | |
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r bookkeeper-operator.tar.gz root@$CLUSTER_IP:/root/ | |
- name: Setup k8 | |
run: | | |
pwd;ls | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "sudo apt-get update;tar -xzvf /root/bookkeeper-operator.tar.gz; ls /root/; ls /root/bookkeeper-operator/test/e2e/resources" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP sudo chmod +x /root/bookkeeper-operator/test/e2e/resources/kubernetes_master_install.sh | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP /root/bookkeeper-operator/test/e2e/resources/kubernetes_master_install.sh | |
CLUSTER_ID1=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $2}' | tr -d ' '` | |
CLUSTER_IP1=`packet-cli device get -i $CLUSTER_ID1 -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' '` | |
CLUSTER_ID2=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $2}' | tr -d ' '` | |
CLUSTER_IP2=`packet-cli device get -i $CLUSTER_ID2 -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' '` | |
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r ../bookkeeper-operator.tar.gz root@$CLUSTER_IP1:/root/ | |
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r ../bookkeeper-operator.tar.gz root@$CLUSTER_IP2:/root/ | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 "sudo apt-get update;tar -xzvf /root/bookkeeper-operator.tar.gz" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 "sudo apt-get update;tar -xzvf /root/bookkeeper-operator.tar.gz" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 sudo chmod +x /root/bookkeeper-operator/test/e2e/resources/kubernetes_slave_install.sh | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 /root/bookkeeper-operator/test/e2e/resources/kubernetes_slave_install.sh | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 sudo chmod +x /root/bookkeeper-operator/test/e2e/resources/kubernetes_slave_install.sh | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 /root/bookkeeper-operator/test/e2e/resources/kubernetes_slave_install.sh | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP 'kubeadm token create --print-join-command | head -2' >JOIN | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 $(cat JOIN) | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 $(cat JOIN) | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl get nodes" | |
echo "CLUSTER_ID1=$CLUSTER_ID1" >> $GITHUB_ENV | |
echo "CLUSTER_ID2=$CLUSTER_ID2" >> $GITHUB_ENV | |
- name: Make setup before running e2e | |
run: | | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "mkdir /data;kubectl create -f /root/bookkeeper-operator/test/e2e/resources/local-storage.yaml" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "curl -L https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/bookkeeper-operator/test/e2e/resources/zookeeper_crd.yaml" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/bookkeeper-operator/test/e2e/resources/zookeeper.yaml" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl apply -f \"https://github.com/jetstack/cert-manager/releases/download/v1.7.0/cert-manager.crds.yaml\"" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "helm repo add jetstack https://charts.jetstack.io" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "helm repo update" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create namespace cert-manager;helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.7.0 --wait" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=testbkop --docker-password=08d50da6-61bd-4953-a2ce-7d7a0e3835bc --docker-email=testbkop@gmail.com" | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer);source /root/.gvm/scripts/gvm;gvm install go1.21.0 --binary;gvm use go1.21.0 --default;git config --global --add safe.directory /root/bookkeeper-operator" | |
- name: Running e2e | |
run: | | |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/bookkeeper-operator;source /root/.gvm/scripts/gvm;make test-e2e" | |
- name: Deleting cluster | |
if: ${{ always() }} | |
run: | | |
SSHKEY=`packet-cli ssh-key get | grep "pravega-travis" | awk '{print $2}' | tr -d ' '` | |
echo y | packet-cli ssh-key delete -i $SSHKEY | |
echo y | packet-cli device delete -i $CLUSTER_ID | |
echo y | packet-cli device delete -i $CLUSTER_ID1 | |
echo y | packet-cli device delete -i $CLUSTER_ID2 |