<commit_before>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if ! command -v microk8s.kubectl >/dev/null; then
  echo "You need to install microk8s"
  exit 1
fi

tag="test_$(git rev-parse --abbrev-ref HEAD)"
# In CircleCI, PR branches that come from forks have the format "pull/n", where
# n is the PR number. "/" is not accepted in docker tags, so we need to replace
# it.
tag=$(echo "$tag" | tr / -)

microk8s.kubectl apply -f https://github.com/knative/serving/releases/download/v0.9.0/serving-core.yaml || true
mkdir -p "$HOME"/.kube/
microk8s.kubectl config view --raw >"$HOME"/.kube/config
chown -R circleci "$HOME"/.kube

#Builds the kourier image and imports into the k8s cluster
docker build -t 3scale-kourier:"$tag" ./
docker image save 3scale-kourier:"$tag" >image.tar
microk8s.ctr -n k8s.io images import image.tar

#Builds the gateway image and imports into the k8s cluster
docker build -f Dockerfile.gateway -t 3scale-kourier-gateway:"$tag" ./
docker image save 3scale-kourier-gateway:"$tag" >image.tar
microk8s.ctr -n k8s.io images import image.tar

# Enable the microk8s DNS plugin
microk8s.enable dns

# Deploys kourier and patches it.
microk8s.kubectl apply -f deploy/kourier-knative.yaml
microk8s.kubectl patch deployment 3scale-kourier-control -n knative-serving --patch "{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"kourier-control\",\"image\": \"3scale-kourier:$tag\",\"imagePullPolicy\": \"IfNotPresent\"}]}}}}"
microk8s.kubectl patch deployment 3scale-kourier-gateway -n knative-serving --patch "{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"kourier-gateway\",\"image\": \"3scale-kourier-gateway:$tag\",\"imagePullPolicy\": \"IfNotPresent\"}]}}}}"
microk8s.kubectl patch configmap/config-domain -n knative-serving --type merge -p '{"data":{"127.0.0.1.nip.io":""}}'
microk8s.kubectl patch configmap/config-network -n knative-serving --type merge -p '{"data":{"clusteringress.class":"kourier.ingress.networking.knative.dev","ingress.class":"kourier.ingress.networking.knative.dev"}}'

retries=0
while [[ $(microk8s.kubectl get pods -n knative-serving -l app=3scale-kourier-control -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do
  echo "Waiting for kourier control pod to be ready "
  sleep 10
  if [ $retries -ge 7 ]; then
    echo "timed out waiting for kourier control pod"
    exit 1
  fi
  retries=$((retries + 1))<commit_msg>utils/setup-circleci: use --namespace instead of -n<commit_after>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if ! command -v microk8s.kubectl >/dev/null; then
  echo "You need to install microk8s"
  exit 1
fi

tag="test_$(git rev-parse --abbrev-ref HEAD)"
# In CircleCI, PR branches that come from forks have the format "pull/n", where
# n is the PR number. "/" is not accepted in docker tags, so we need to replace
# it.
tag=$(echo "$tag" | tr / -)

microk8s.kubectl apply -f https://github.com/knative/serving/releases/download/v0.9.0/serving-core.yaml || true
mkdir -p "$HOME"/.kube/
microk8s.kubectl config view --raw >"$HOME"/.kube/config
chown -R circleci "$HOME"/.kube

#Builds the kourier image and imports into the k8s cluster
docker build -t 3scale-kourier:"$tag" ./
docker image save 3scale-kourier:"$tag" >image.tar
microk8s.ctr --namespace k8s.io images import image.tar

#Builds the gateway image and imports into the k8s cluster
docker build -f Dockerfile.gateway -t 3scale-kourier-gateway:"$tag" ./
docker image save 3scale-kourier-gateway:"$tag" >image.tar
microk8s.ctr --namespace k8s.io images import image.tar

# Enable the microk8s DNS plugin
microk8s.enable dns

# Deploys kourier and patches it.
microk8s.kubectl apply -f deploy/kourier-knative.yaml
microk8s.kubectl patch deployment 3scale-kourier-control -n knative-serving --patch "{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"kourier-control\",\"image\": \"3scale-kourier:$tag\",\"imagePullPolicy\": \"IfNotPresent\"}]}}}}"
microk8s.kubectl patch deployment 3scale-kourier-gateway -n knative-serving --patch "{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"kourier-gateway\",\"image\": \"3scale-kourier-gateway:$tag\",\"imagePullPolicy\": \"IfNotPresent\"}]}}}}"
microk8s.kubectl patch configmap/config-domain -n knative-serving --type merge -p '{"data":{"127.0.0.1.nip.io":""}}'
microk8s.kubectl patch configmap/config-network -n knative-serving --type merge -p '{"data":{"clusteringress.class":"kourier.ingress.networking.knative.dev","ingress.class":"kourier.ingress.networking.knative.dev"}}'

retries=0
while [[ $(microk8s.kubectl get pods -n knative-serving -l app=3scale-kourier-control -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do
  echo "Waiting for kourier control pod to be ready "
  sleep 10
  if [ $retries -ge 7 ]; then
    echo "timed out waiting for kourier control pod"
    exit 1
  fi
  retries=$((retries + 1))
{'fraction_non_alphanumeric': 0.1734527687296417, 'fraction_numerical': 0.01750814332247557, 'mean_word_length': 4.243329775880469, 'pattern_counts': {'":': 38, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2815381', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1737, 'n_words': 468}