Skip to content

Commit

Permalink
added the port to fix the Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhadapaithankar committed Aug 28, 2024
1 parent a0a50b5 commit e6055ac
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ megalinter-reports/
/jq
/portalauth
.kiota.log
podmanlog
155 changes: 136 additions & 19 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,177 @@ pr:
exclude:
- docs/*

variables:
- template: vars.yml

resources:
containers:
- container: golang
image: registry.access.redhat.com/ubi8/go-toolset:1.21.11-1.1720406008
options: --user=0
- container: python
image: registry.access.redhat.com/ubi8/python-39:latest
options: --user=0
- container: ubi8
image: registry.access.redhat.com/ubi8/toolbox:8.8
options: --user=0 --privileged -v /dev/shm:/dev/shm --device /dev/net/tun --name vpn

variables:
- template: vars.yml

stages:
- stage: NEW_HOTNESS
- stage: NotContainerized
dependsOn: Containerized
jobs:
- job: Build_Lint_Test_RP_And_Portal
- job: Python_Unit_Tests
pool:
name: 1es-aro-ci-pool
variables:
HOME: $(Agent.BuildDirectory)

steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
export NO_CACHE=true
make ci-rp
make test-python
[[ -z "$(git status -s)" ]]
displayName: 🧪Run Python Unit Tests
target: python
- job: Build_and_Test_Az_ARO_Extension
- job: Golang_Unit_Tests
pool:
name: 1es-aro-ci-pool
variables:
GOCACHE: /tmp/gocache
steps:
- template: ./templates/template-checkout.yml

- script: |
set -xe
go version
go env
displayName: Print Go version & env
target: golang
- script: |
set -xe
make generate
[[ -z "$(git status -s)" ]]
displayName: ⚙️ Run Golang code generate
target: golang
- script: |
set -xe
make build-all
[[ -z "$(git status -s)" ]]
displayName: 🕵️ Build Golang code
target: golang
- script: |
set -xe
make unit-test-go
displayName: 🧪 Run Golang unit tests
target: golang
- task: PublishTestResults@2
displayName: 📊 Publish tests results
inputs:
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
condition: succeededOrFailed()

- script: |
set -xe
go run github.com/axw/gocov/[email protected] convert cover.out | go run github.com/AlekSi/[email protected] > coverage.xml
displayName: ⚙️ Process Reports
condition: succeededOrFailed()
target: golang
- task: PublishCodeCoverageResults@1
displayName: 📈 Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
failIfCoverageEmpty: false
condition: succeededOrFailed()
target: golang

- job: Lint_Admin_Portal
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make lint-admin-portal
displayName: 🧹 Lint Admin Portal
- stage: Containerized
dependsOn: []
jobs:
- job: Build_Lint_Test_RP_And_Portal
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
export NO_CACHE=true
make azext-aro
- job: Lint_Az_ARO_Extension
# Install podman
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y podman make
which podman
podman --version
whoami
# Start podman service
. ./hack/e2e/utils.sh
run_podman
validate_podman_running
# run build
export PODMAN_REMOTE_ARGS="-r --url=tcp://localhost:8888"
make ci-rp
# Stop podman
kill_podman
target: ubi8
- job: Build_and_Test_Az_ARO_Extension
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make test-python
export NO_CACHE=true
- stage: Golang_Code_Generation
jobs:
- job: Run_Golang_Code_Generate
displayName: "⚙️ Run Golang code generate"
# Install podman
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y podman make
which podman
podman --version
whoami
# Start podman service
. ./hack/e2e/utils.sh
run_podman
validate_podman_running
# run build
export PODMAN_REMOTE_ARGS="-r --url=tcp://localhost:8888"
make azext-aro
# Stop podman
kill_podman
target: ubi8
- job: Lint_Az_ARO_Extension
pool:
name: 1es-aro-ci-pool
container: golang
variables:
GOCACHE: /tmp/gocache # Set the Go build cache to a writable directory
HOME: $(Agent.BuildDirectory)
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make generate
export AZDEV_CONFIG_DIR=$(Agent.BuildDirectory)/azdev-config
make test-python
[[ -z "$(git status -s)" ]]
displayName: "Run Golang Code Generate"
target: python
35 changes: 28 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ runlocal-rp: ci-rp podman-secrets
--secret proxy-client.key,target=/app/secrets/proxy-client.key \
--secret proxy-client.crt,target=/app/secrets/proxy-client.crt \
--secret proxy.crt,target=/app/secrets/proxy.crt \
$(LOCAL_ARO_RP_IMAGE):$(VERSION) rp
$(LOCAL_ARO_RP_IMAGE):$(VERSION): rp

.PHONY: az
az: pyenv
Expand Down Expand Up @@ -198,6 +198,8 @@ client: generate

.PHONY: ci-rp
ci-rp: fix-macos-vendor
# Build the RP image
@echo "Building the RP image..."
podman $(PODMAN_REMOTE_ARGS) \
build . \
-f Dockerfile.ci-rp \
Expand All @@ -206,12 +208,31 @@ ci-rp: fix-macos-vendor
--build-arg ARO_VERSION=$(VERSION) \
--no-cache=$(NO_CACHE) \
-t $(LOCAL_ARO_RP_IMAGE):$(VERSION)
podman $(PODMAN_REMOTE_ARGS) tag \
$(shell podman image ls --filter label=stage=portal-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1) \
$(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION)
podman $(PODMAN_REMOTE_ARGS) tag \
$(shell podman image ls --filter label=stage=rp-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1) \
$(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION)

# Debug: List all images and labels before tagging
@echo "Listing all images and their labels..."
@podman $(PODMAN_REMOTE_ARGS) images --format "{{.ID}}: {{.Labels}}"

# Tag the portal build image if it exists
@PORTAL_IMAGE_ID=$(shell podman $(PODMAN_REMOTE_ARGS) image ls --filter label=aro-portal-build=true --noheading --format "{{.Id}}" | tail -n 1); \
if [ -n "$$PORTAL_IMAGE_ID" ]; then \
echo "Tagging Portal Image $$PORTAL_IMAGE_ID as $(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION)"; \
podman $(PODMAN_REMOTE_ARGS) tag $$PORTAL_IMAGE_ID $(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION); \
else \
echo "No Portal Image found with label aro-portal-build=true. Exiting."; \
exit 1; \
fi

# Tag the RP build image if it exists
@RP_IMAGE_ID=$(shell podman $(PODMAN_REMOTE_ARGS) image ls --filter label=stage=rp-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1); \
if [ -n "$$RP_IMAGE_ID" ]; then \
echo "Tagging RP Image $$RP_IMAGE_ID as $(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION)"; \
podman $(PODMAN_REMOTE_ARGS) tag $$RP_IMAGE_ID $(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION); \
else \
echo "No RP Image found with label stage=rp-build-cache-layer. Exiting."; \
exit 1; \
fi


.PHONY: ci-tunnel
ci-tunnel: fix-macos-vendor
Expand Down
39 changes: 1 addition & 38 deletions hack/e2e/run-rp-and-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [[ $CI ]]; then
set -o pipefail

. secrets/env
. hack/e2e/utils.sh
echo "##vso[task.setvariable variable=RP_MODE]$RP_MODE"

set -a
Expand Down Expand Up @@ -102,44 +103,6 @@ kill_vpn() {
while read pid; do sudo kill $pid; done <vpnpid
}

run_podman() {
echo "########## 🚀 Run Podman in background ##########"
podman --log-level=debug system service --time=0 tcp://127.0.0.1:8888 >podmanlog &
}

kill_podman() {
echo "podman logs:"
cat podmanlog
echo "########## Kill the podman running in background ##########"
rppid=$(lsof -t -i :8888)
kill $rppid
wait $rppid
}

validate_podman_running() {
echo "########## ?Checking podman Status ##########"
ELAPSED=0
while true; do
sleep 5
http_code=$(curl -k -s -o /dev/null -w '%{http_code}' http://localhost:8888/v1.30/_ping || true)
case $http_code in
"200")
echo "########## ✅ Podman Running ##########"
break
;;
*)
echo "Attempt $ELAPSED - podman is NOT up. Code : $http_code, waiting"
sleep 2
# after 40 secs return exit 1 to not block ci
ELAPSED=$((ELAPSED + 1))
if [ $ELAPSED -eq 20 ]; then
exit 1
fi
;;
esac
done
}

run_selenium() {
echo "########## 🚀 Run Selenium in background ##########"
podman -r --url tcp://localhost:8888 pull docker.io/selenium/standalone-edge:4.10.0-20230607
Expand Down
54 changes: 54 additions & 0 deletions hack/e2e/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash -e

run_podman() {
echo "########## 🚀 Run Podman in background ##########"
podman --log-level=debug system service --time=0 tcp://127.0.0.1:8888 > podmanlog 2>&1 &
PODMAN_PID=$!
echo "Podman PID: $PODMAN_PID"
}

validate_podman_running() {
echo "########## ?Checking podman Status ##########"
ELAPSED=0
while true; do
sleep 5
http_code=$(curl -k -s -o /dev/null -w '%{http_code}' http://localhost:8888/v1.30/_ping || true)
case $http_code in
"200")
echo "########## ✅ Podman Running ##########"
break
;;
*)
echo "Attempt $ELAPSED - podman is NOT up. Code : $http_code, waiting"
sleep 2
# after 40 secs return exit 1 to not block ci
ELAPSED=$((ELAPSED + 1))
if [ $ELAPSED -eq 20 ]; then
echo "########## ❌ Podman failed to start within timeout ##########"
kill_podman
exit 1
fi
;;
esac
done
}

kill_podman() {
echo "podman logs:"
cat podmanlog
echo "########## Kill the podman running in background ##########"

if [ -n "$PODMAN_PID" ]; then
kill $PODMAN_PID 2>/dev/null
wait $PODMAN_PID 2>/dev/null || echo "Podman process $PODMAN_PID was not a child of this shell."
else
echo "No PODMAN_PID found. Attempting to kill by port."
rppid=$(lsof -t -i :8888)
if [ -n "$rppid" ]; then
kill $rppid
echo "Killed podman running on port 8888 with PID $rppid."
else
echo "No process found running on port 8888."
fi
fi
}

0 comments on commit e6055ac

Please sign in to comment.