[WIP] k8s workflow tests #2
Workflow file for this run
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: K8S DEVNET - REGRESSION DETECTOR | ||
on: | ||
push: | ||
release: | ||
types: [prereleased] | ||
# forward-looking, devs could manually trigger this action (via github UI) and easily spin up / stress test devnets for ad hoc testing | ||
jobs: | ||
deploy_devnet: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.before }} | ||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Setup Google Cloud SDK | ||
uses: 'google-github-actions/setup-gcloud@v2' | ||
with: | ||
version: '>= 363.0.0' | ||
- uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
project_id: 'prj-polygonlabs-devtools-dev' | ||
- name: Install kubectl and gcloud kubectl auth plugin | ||
run: | | ||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \ | ||
&& sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && gcloud components install gke-gcloud-auth-plugin | ||
- name: Install tomlq for config file preparation | ||
run: | | ||
pip3 install tomlq | ||
- name: Clone private polygon-devnets repo | ||
run: | | ||
eval `ssh-agent -s` | ||
ssh-add - <<< '${{ secrets.SSH_PRIVATE_KEY }}' | ||
git clone -b fix/pos_k8s_devnets [email protected]:maticnetwork/polygon-devnets.git | ||
- name: Clone private panoptichain repo | ||
run: | | ||
eval `ssh-agent -s` | ||
ssh-add - <<< '${{ secrets.SSH_PRIVATE_KEY_PANOPTICHAIN }}' | ||
git clone -b dan/k8s_panoptichain [email protected]:0xPolygon/panoptichain.git | ||
- name: Deploy PoS devnet to isolated GKE namespace | ||
run: | | ||
mkdir -p ~/.kube | ||
echo "${{ secrets.GKE_CLUSTER_CREDENTIALS }}" > ~/.kube/regression-cluster.yaml | ||
export KUBECONFIG=~/.kube/regression-cluster.yaml | ||
# cd polygon-devnets/kubernetes/pos | ||
# kubectl apply -k overlays/gcr --namespace=pos --context=gke_prj-polygonlabs-devtools-dev_europe-west2_ci-cluster-1 | ||
# | ||
# - name: Deploy panoptichain, prometheus, grafana stack for metric tracking | ||
# run: | | ||
# cd panoptichain | ||
# export KUBECONFIG=~/.kube/regression-cluster.yaml | ||
# kubectl apply -f grafana-service.yaml,panoptichain-service.yaml,prometheus-service.yaml,grafana-deployment.yaml,grafana-claim0-persistentvolumeclaim.yaml,panoptichain-deployment.yaml,prometheus-deployment.yaml,prometheus-claim0-persistentvolumeclaim.yaml --namespace=pos --context=gke_prj-polygonlabs-devtools-dev_europe-west2_ci-cluster-1 | ||
# | ||
# - name: Finally, deploy datadog-agent via helm chart | ||
# run: | | ||
# cd panoptichain/terraform | ||
# terraform init | ||
# terraform apply -auto-approve -target=helm_release.datadog_agent -var="datadog_api_key=${{ secrets.DATADOG_API_KEY }}" -var="coralogix_api_key=${{ secrets.CORALOGIX_API_KEY }}" | ||
# | ||
# - name: Auto-apply load and report any regressions here | ||
# run: | | ||
# MONITOR_ID="140974014" # K8S DEVNET: COMPOSITE MONITOR ID | ||
# DATADOG_API_KEY="${{ secrets.DATADOG_API_KEY }}" | ||
# DATADOG_APP_KEY="${{ secrets.DATADOG_APP_KEY }}" | ||
# | ||
# end_minute=$(( $(date +'%M') + 1)) # Calculate the end minute | ||
# | ||
# while [ $(date +'%M') -lt $end_minute ]; do | ||
# STATUS=$(curl -X GET "https://api.datadoghq.com/api/v1/monitor/${MONITOR_ID}" \ | ||
# -H "Content-Type: application/json" \ | ||
# -H "DD-API-KEY: ${DATADOG_API_KEY}" \ | ||
# -H "DD-APPLICATION-KEY: ${DATADOG_APP_KEY}" \ | ||
# -s \ | ||
# | jq -r '.overall_state') | ||
# echo "K8S DEVNET HEALTH STATUS: $STATUS" | ||
# echo "Review your devnet health dashboard here: https://app.datadoghq.com/dashboard/fqu-nh2-bzd?fromUser=false&refresh_mode=sliding&view=spans&from_ts=1709886652761&to_ts=1709890252761&live=true" | ||
# sleep 60 | ||
# done | ||
# | ||
# # After stress tests, cleanup all ephemeral K8S devnet resources | ||
# - name: Remove panoptichain, prometheus, and grafana resources | ||
# run: | | ||
# cd panoptichain | ||
# export KUBECONFIG=~/.kube/regression-cluster.yaml | ||
# kubectl delete -f grafana-service.yaml,panoptichain-service.yaml,prometheus-service.yaml,grafana-deployment.yaml,grafana-claim0-persistentvolumeclaim.yaml,panoptichain-deployment.yaml,prometheus-deployment.yaml,prometheus-claim0-persistentvolumeclaim.yaml --namespace=pos --context=gke_prj-polygonlabs-devtools-dev_europe-west2_ci-cluster-1 | ||
- name: Remove all datadog agent resources | ||
register: tf_result | ||
retries: 3 | ||
delay: 5 | ||
until: tf_result is not failed | ||
ansible.builtin.shell: | ||
cmd: | | ||
cd panoptichain/terraform | ||
terraform init | ||
terraform destroy -auto-approve -target=helm_release.datadog_agent -var="datadog_api_key=${{ secrets.DATADOG_API_KEY }}" -var="coralogix_api_key=${{ secrets.CORALOGIX_API_KEY }}" | ||
- name: Finally, remove pos devnet resources and return to clean slate GKE environment | ||
run: | | ||
cd polygon-devnets/kubernetes/pos | ||
export KUBECONFIG=~/.kube/regression-cluster.yaml | ||
kubectl delete -k overlays/gcr --namespace=pos --context=gke_prj-polygonlabs-devtools-dev_europe-west2_ci-cluster-1 |