Skip to content

Commit e168a9a

Browse files
committed
chore: refactor some scripts (#21)
Signed-off-by: Aviral Takkar <avtakkar@microsoft.com>
1 parent 763d0f0 commit e168a9a

File tree

15 files changed

+29
-38
lines changed

15 files changed

+29
-38
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ BIN_DIR = $(ROOT_DIR)/bin
1313
TEST_PKGS = $(shell go list ./...)
1414
TESTS_BIN_DIR = $(BIN_DIR)/tests
1515
COVERAGE_DIR=$(BIN_DIR)/coverage
16-
SCRIPTS_DIR=$(ROOT_DIR)/scripts
16+
SCRIPTS_DIR=$(ROOT_DIR)/build/ci/scripts
1717

1818
# Docker image variables.
1919
REGISTRY ?= localhost

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The `peerd` container image is available at `ghcr.io/azure/acr/peerd`. To deploy
5959
CLUSTER_CONTEXT=<your-cluster-context> && \
6060
TAG=v0.0.2-alpha && \
6161
HELM_RELEASE_NAME=peerd && \
62-
HELM_CHART_DIR=./build/ci/k8s/peerd-helm && \
62+
HELM_CHART_DIR=./build/package/peerd-helm && \
6363
helm --kube-context=$CLUSTER_CONTEXT install --wait $HELM_RELEASE_NAME $HELM_CHART_DIR \
6464
--set peerd.image.ref=ghcr.io/azure/acr/dev/peerd:$TAG
6565
```
@@ -71,7 +71,7 @@ as well, run the following.
7171
CLUSTER_CONTEXT=<your-cluster-context> && \
7272
TAG=v0.0.2-alpha && \
7373
HELM_RELEASE_NAME=peerd && \
74-
HELM_CHART_DIR=./build/ci/k8s/peerd-helm && \
74+
HELM_CHART_DIR=./build/package/peerd-helm && \
7575
helm --kube-context=$CLUSTER_CONTEXT install --wait $HELM_RELEASE_NAME $HELM_CHART_DIR \
7676
--set peerd.image.ref=ghcr.io/azure/acr/dev/peerd:$TAG
7777
--set peerd.hosts="mcr.microsoft.com ghcr.io docker.io"
@@ -279,7 +279,7 @@ integration with [Overlaybd].
279279
[DADI P2P Proxy]: https://github.com/data-accelerator/dadi-p2proxy
280280
[containerd hosts]: https://github.com/containerd/containerd/blob/main/docs/hosts.md
281281
[containerd-mirror]: ./internal/containerd/mirror.go
282-
[helm chart]: ./build/ci/k8s/peerd-helm
282+
[helm chart]: ./build/package/peerd-helm
283283
[CodeQL]: https://github.com/Azure/peerd/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main
284284
[code-ql]: https://github.com/Azure/peerd/actions/workflows/github-code-scanning/codeql
285285
[Azure Blob]: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction

build/ci/Makefile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
11
.PHONY: tests-deps-install
22
tests-deps-install: ## Install dependencies for testing (supported only on Ubuntu)
33
@echo "+ $@"
4-
sudo $(ROOT_DIR)/build/ci/scripts/install-deps.sh
4+
sudo $(SCRIPTS_DIR)/install-deps.sh
55

66
.PHONY: kind-create
77
kind-create: ## Creates a kind cluster
88
@echo "+ $@"
9-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh cluster create -y )
9+
@( $(SCRIPTS_DIR)/kind.sh cluster create -y )
1010

1111
.PHONY: kind-get
1212
kind-get: ## Shows the current kind cluster
1313
@echo "+ $@"
14-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh cluster get -y )
14+
@( $(SCRIPTS_DIR)/kind.sh cluster get -y )
1515

1616
.PHONY: kind-delete
1717
kind-delete: ## Deletes kind cluster
1818
@echo "+ $@"
19-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh cluster delete -y )
19+
@( $(SCRIPTS_DIR)/kind.sh cluster delete -y )
2020

2121
.PHONY: kind-deploy
2222
kind-deploy: ## Deploys the p2p application to kind cluster
2323
@echo "+ $@"
2424
ifndef CONTAINER_REGISTRY
2525
$(eval CONTAINER_REGISTRY := $(shell echo "localhost"))
2626
endif
27-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh app deploy -y $(CONTAINER_REGISTRY)/peerd:dev )
27+
@( $(SCRIPTS_DIR)/kind.sh app deploy -y $(CONTAINER_REGISTRY)/peerd:dev )
2828

2929
.PHONY: kind-test-ctr
3030
kind-test-ctr: ## Deploys test 'ctr' to the kind cluster
3131
@echo "+ $@"
32-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh test ctr -y )
32+
@( $(SCRIPTS_DIR)/kind.sh test ctr -y )
3333

3434
.PHONY: kind-test-random
3535
kind-test-random: ## Deploys test 'random' to the kind cluster
3636
@echo "+ $@"
3737
ifndef CONTAINER_REGISTRY
3838
$(eval CONTAINER_REGISTRY := $(shell echo "localhost"))
3939
endif
40-
@( $(ROOT_DIR)/build/ci/scripts/kind.sh test random -y $(CONTAINER_REGISTRY)/random:dev )
40+
@( $(SCRIPTS_DIR)/kind.sh test random -y $(CONTAINER_REGISTRY)/random:dev )
41+
42+
.PHONY: tests-ci-aks
43+
tests-ci-aks: ## Run CI in AKS
44+
@echo "+ $@"
45+
ifndef NODEPOOL
46+
$(eval NODEPOOL := $(shell date +"p2p%y%m%d"))
47+
endif
48+
ifndef PEERD_IMAGE_TAG
49+
$(eval PEERD_IMAGE_TAG := "dev")
50+
endif
51+
@echo "\033[92mRunning CI NODEPOOL: $(NODEPOOL)\033[0m"
52+
@( PEERD_IMAGE_TAG=$(PEERD_IMAGE_TAG) $(SCRIPTS_DIR)/azure.sh nodepool up -y $(NODEPOOL) )
53+
@( $(SCRIPTS_DIR)/azure.sh test ctr -y $(NODEPOOL) )
54+
@( $(SCRIPTS_DIR)/azure.sh nodepool delete -y $(NODEPOOL) )

build/ci/k8s/test-random.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ spec:
1414
labels:
1515
app: *name
1616
spec:
17-
# affinity:
18-
# nodeAffinity:
19-
# requiredDuringSchedulingIgnoredDuringExecution:
20-
# nodeSelectorTerms:
21-
# - matchExpressions:
22-
# - key: p2p-nodepool
23-
# operator: In
24-
# values:
25-
# - 'true'
2617
containers:
2718
- image: $TEST_RANDOM_CONTAINER_IMAGE
2819
imagePullPolicy: Never

scripts/azure.sh renamed to build/ci/scripts/azure.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55
source $SCRIPT_DIR/env.sh
66

7-
PEERD_HELM_CHART="$SCRIPT_DIR/../build/ci/k8s/peerd-helm"
7+
PEERD_HELM_CHART="$SCRIPT_DIR/../build/package/peerd-helm"
88
TESTS_AZURE_CLI_DEPLOY_TEMPLATE=$SCRIPT_DIR/../build/ci/k8s/azure-cli.yml
99

1010
show_help() {
@@ -112,7 +112,7 @@ wait_for_peerd_pods() {
112112
fi
113113

114114
# Loop until all pods are connected or an error occurs.
115-
for ((i=1; i<=100; i++)); do
115+
for ((i=1; i<=10; i++)); do
116116
# Initialize a counter for connected pods.
117117
found=0
118118

@@ -131,7 +131,7 @@ wait_for_peerd_pods() {
131131
echo "Success: All pods have event '$event'."
132132
break
133133
else
134-
echo "Waiting: $found out of $total pods have event '$event'. Attempt $i of 100."
134+
echo "Waiting: $found out of $total pods have event '$event'. Attempt $i of 10."
135135
sleep 15
136136
fi
137137
done
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/ci/scripts/kind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55
KIND_CLUSTER_NAME="p2p"
66
KIND_CLUSTER_CONTEXT="kind-$KIND_CLUSTER_NAME"
77
CLUSTER_CONFIG_FILE="$SCRIPT_DIR/../k8s/kind-cluster.yml"
8-
HELM_CHART_DIR="$SCRIPT_DIR/../k8s/peerd-helm"
8+
HELM_CHART_DIR="$SCRIPT_DIR/../../package/peerd-helm"
99
HELM_RELEASE_NAME="peerd"
1010
export GIT_ROOT="$(git rev-parse --show-toplevel)"
1111

tests/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,3 @@ ifndef CONTAINER_REGISTRY
1818
$(eval CONTAINER_REGISTRY := localhost)
1919
endif
2020
$(call build-image-internal,$(ROOT_DIR)/tests/dockerfiles/random.Dockerfile,random,$(ROOT_DIR))
21-
22-
.PHONY: tests-ci-aks
23-
tests-ci-aks: ## Run CI in AKS
24-
@echo "+ $@"
25-
ifndef NODEPOOL
26-
$(eval NODEPOOL := $(shell date +"p2p%y%m%d"))
27-
endif
28-
ifndef PEERD_IMAGE_TAG
29-
$(eval PEERD_IMAGE_TAG := "dev")
30-
endif
31-
@echo "\033[92mRunning CI NODEPOOL: $(NODEPOOL)\033[0m"
32-
@( PEERD_IMAGE_TAG=$(PEERD_IMAGE_TAG) $(ROOT_DIR)/scripts/azure.sh nodepool up -y $(NODEPOOL) )
33-
@( $(ROOT_DIR)/scripts/azure.sh test ctr -y $(NODEPOOL) )
34-
@( $(ROOT_DIR)/scripts/azure.sh nodepool delete -y $(NODEPOOL) )

0 commit comments

Comments
 (0)