From f8e75a499d0aac77448374794a9201fbf013f368 Mon Sep 17 00:00:00 2001 From: Shubhada Date: Thu, 22 Aug 2024 10:22:19 -0700 Subject: [PATCH] added the port to fix the Makefile --- .pipelines/ci.yml | 155 ++++++++++++++++++++++++++++++++----- hack/e2e/run-rp-and-e2e.sh | 39 +--------- hack/e2e/utils.sh | 54 +++++++++++++ 3 files changed, 189 insertions(+), 59 deletions(-) create mode 100644 hack/e2e/utils.sh diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index 38277d9e51d..e1c94600db0 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -20,29 +20,110 @@ 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/gocov@v1.1.0 convert cover.out | go run github.com/AlekSi/gocov-xml@v1.1.0 > 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: @@ -50,30 +131,62 @@ stages: - 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 steps: - template: ./templates/template-checkout.yml - script: | set -xe - make generate - [[ -z "$(git status -s)" ]] - displayName: "Run Golang Code Generate" + export NO_CACHE=true + make test-python + #target: python \ No newline at end of file diff --git a/hack/e2e/run-rp-and-e2e.sh b/hack/e2e/run-rp-and-e2e.sh index 5dc1878642f..c20f67c4c6f 100755 --- a/hack/e2e/run-rp-and-e2e.sh +++ b/hack/e2e/run-rp-and-e2e.sh @@ -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 @@ -102,44 +103,6 @@ kill_vpn() { while read pid; do sudo kill $pid; done 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 diff --git a/hack/e2e/utils.sh b/hack/e2e/utils.sh new file mode 100644 index 00000000000..4423055484e --- /dev/null +++ b/hack/e2e/utils.sh @@ -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 +}