Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Change CI paths to varibles #200

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vpp_ligato_latest_container()
{
IMAGE="ligato/vpp-base:latest"

cd $USERSPACEDIR
cd ${USERSPACEDIR}

echo "Changing to latest tag in dockerfile"
sed -i "s|\(FROM\).*\(as builder\)|\1 $IMAGE \2|g" ./docker/userspacecni/Dockerfile
Expand All @@ -23,13 +23,13 @@ grep -n "$IMAGE" ./ci/vpp_test_setup/vpp_host.sh
}

install_go_kubectl_kind(){
wget -qO- https://golang.org/dl/go1.20.1.linux-amd64.tar.gz |tar -C /home/runner -xz
export PATH="${PATH}:/home/runner/go/bin"
echo "export PATH=\"${PATH}:/home/runner/go/bin/:home/runner/.local/bin/\"" >>~/.bashrc
wget -qO- https://golang.org/dl/go1.20.1.linux-amd64.tar.gz |tar -C "$HOME" -xz
export PATH="${PATH}:${HOME}/go/bin"
echo "export PATH=\"${PATH}:${HOME}/go/bin/:${HOME}.local/bin/\"" >>~/.bashrc
go install sigs.k8s.io/[email protected]

wget -q https://dl.k8s.io/release/v1.27.3/bin/linux/amd64/kubectl -O /home/runner/go/bin/kubectl
chmod +x /home/runner/go/bin/kubectl
wget -q https://dl.k8s.io/release/v1.27.3/bin/linux/amd64/kubectl -O "${HOME}/go/bin/kubectl"
chmod +x "${HOME}/go/bin/kubectl"
}

create_kind_cluster(){
Expand All @@ -43,12 +43,14 @@ kubectl get all --all-namespaces

#docker run -itd --device=/dev/hugepages:/dev/hugepages --privileged -v "$(pwd)/docker/vpp-centos-userspace-cni/:/etc/vpp/" --name vpp ligato/vpp-base
sleep 10
cd /runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/
cd $USERSPACEDIR

docker build . -f ./docker/userspacecni/Dockerfile -t userspacecni:latest
# gets path for one directopry above, needed for mkdir with docker cp below
mkdir_var=$(dirname ${USERSPACEDIR})
kind load docker-image userspacecni
docker exec -i kind-control-plane bash -c "mkdir -p '/runner/_work/userspace-cni-network-plugin/'"
docker cp "/runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/" "kind-control-plane:/runner/_work/userspace-cni-network-plugin/"
docker exec -i kind-control-plane bash -c "mkdir -p $mkdir_var"
docker cp "${USERSPACEDIR}" "kind-control-plane:${USERSPACEDIR}"
}

deploy_multus(){
Expand Down
5 changes: 4 additions & 1 deletion ci/vpp_test_setup/vpp_host.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

# Set USERSPACEDIR if not defined in parent script
USERSPACEDIR="${USERSPACEDIR:=/runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/}"

kubectl delete ns vpp
kubectl create ns vpp
kubectl create -n vpp configmap vpp-startup-config --from-file=/runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/docker/vpp-centos-userspace-cni/startup.conf
kubectl create -n vpp configmap vpp-startup-config --from-file="${USERSPACEDIR}/docker/vpp-centos-userspace-cni/startup.conf"

worker="kind-control-plane"

Expand Down
9 changes: 5 additions & 4 deletions ci/vpp_test_setup/vpp_pod.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

CI_DIR="/runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/ci/"
kubectl apply -f $CI_DIR/vpp_test_setup/network_attachment_definition.yaml
kubectl create -n vpp configmap vpp-app-startup-config --from-file=$CI_DIR/vpp_test_setup/startup.conf
# set CI_DIR if not defined in parent script
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should a default just be set in parent dir instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more modular for end user, allows user to run this script without the others

CI_DIR="${CI_DIR:=/runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/ci/}"
kubectl apply -f "$CI_DIR/vpp_test_setup/network_attachment_definition.yaml"
kubectl create -n vpp configmap vpp-app-startup-config --from-file="$CI_DIR/vpp_test_setup/startup.conf"
worker="kind-control-plane"
numbers=("1" "2")

Expand Down Expand Up @@ -74,6 +75,6 @@ spec:
path: /run/vpp/app$number
- name: scripts
hostPath:
path: /runner/_work/userspace-cni-network-plugin/userspace-cni-network-plugin/ci/vpp_test_setup/
path: $CI_DIR/vpp_test_setup/
EOF
done