From da2acf064b890836f064ff63dd265768efa144a3 Mon Sep 17 00:00:00 2001 From: Shubhada Date: Tue, 27 Aug 2024 13:18:14 -0700 Subject: [PATCH] Makefile modified --- .pipelines/ci.yml | 117 ++++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 45 deletions(-) diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index 8107d9bdd1b..567e88c155b 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -121,50 +121,6 @@ stages: make lint-admin-portal displayName: 🧹 Lint Admin Portal - - job: Pull_And_Push_Image_To_ACR - pool: - vmImage: 'ubuntu-latest' - variables: - ob_outputDirectory: '$(Build.SourcesDirectory)/out' - IMAGE_TAG: $(Build.SourceBranchName) - REPOSITORY: 'my-image-repo' - ACR_FQDN: 'arosvcdev.azurecr.io' # ACR FQDN - steps: - - checkout: self - - # Authenticate with Azure using the Managed Identity service connection - - task: AzureCLI@2 - inputs: - azureSubscription: 'ado-pipeline-dev-image-push' # Service connection name - scriptType: 'bash' - scriptLocation: 'inlineScript' - inlineScript: | - az acr login --name ${ACR_FQDN%%.*} - docker login ${ACR_FQDN} -u "00000000-0000-0000-0000-000000000000" -p "$(az acr login --name ${ACR_FQDN%%.*} --expose-token --output tsv --query accessToken)" - mkdir -p "${ob_outputDirectory}" - docker pull ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} || echo "Image not found." - if [ -f "${ob_outputDirectory}/image.tar" ]; then - docker save ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} -o ${ob_outputDirectory}/image.tar - fi - displayName: 'Pulling Docker Image using Docker' - - # Push the Docker image to ACR - - task: AzureCLI@2 - inputs: - azureSubscription: 'ado-pipeline-dev-image-push' # Service connection name - scriptType: 'bash' - scriptLocation: 'inlineScript' - inlineScript: | - if [ -f "${ob_outputDirectory}/image.tar" ]; then - docker load -i ${ob_outputDirectory}/image.tar - docker tag ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} ${ACR_FQDN}/${REPOSITORY}:latest - docker push ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} - docker push ${ACR_FQDN}/${REPOSITORY}:latest - else - echo "Image tar file not found, skipping push." - fi - displayName: 'Pushing Docker Image to ACR' - - stage: Containerized dependsOn: [] jobs: @@ -239,7 +195,51 @@ stages: make test-python [[ -z "$(git status -s)" ]] target: python - + + - job: Pull_And_Push_Image_To_ACR + pool: + vmImage: 'ubuntu-latest' + variables: + ob_outputDirectory: '$(Build.SourcesDirectory)/out' + IMAGE_TAG: $(Build.SourceBranchName) + REPOSITORY: 'my-image-repo' + ACR_FQDN: 'arosvcdev.azurecr.io' # ACR FQDN + steps: + - checkout: self + + # Authenticate with Azure using the Managed Identity service connection + - task: AzureCLI@2 + inputs: + azureSubscription: 'ado-pipeline-dev-image-push' # Service connection name + scriptType: 'bash' + scriptLocation: 'inlineScript' + inlineScript: | + az acr login --name ${ACR_FQDN%%.*} + docker login ${ACR_FQDN} -u "00000000-0000-0000-0000-000000000000" -p "$(az acr login --name ${ACR_FQDN%%.*} --expose-token --output tsv --query accessToken)" + mkdir -p "${ob_outputDirectory}" + docker pull ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} || echo "Image not found." + if [ -f "${ob_outputDirectory}/image.tar" ]; then + docker save ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} -o ${ob_outputDirectory}/image.tar + fi + displayName: 'Pulling Docker Image using Docker' + + # Push the Docker image to ACR + - task: AzureCLI@2 + inputs: + azureSubscription: 'ado-pipeline-dev-image-push' # Service connection name + scriptType: 'bash' + scriptLocation: 'inlineScript' + inlineScript: | + if [ -f "${ob_outputDirectory}/image.tar" ]; then + docker load -i ${ob_outputDirectory}/image.tar + docker tag ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} ${ACR_FQDN}/${REPOSITORY}:latest + docker push ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG} + docker push ${ACR_FQDN}/${REPOSITORY}:latest + else + echo "Image tar file not found, skipping push." + fi + displayName: 'Pushing Docker Image to ACR' + - job: Extract_Coverage_Report pool: vmImage: 'ubuntu-latest' @@ -280,3 +280,30 @@ stages: codeCoverageTool: Cobertura summaryFileLocation: $(Build.SourcesDirectory)/cover.out displayName: 'Publish Code Coverage Results' + + - job: Golang_Unit_Tests_Containerized + pool: + name: 1es-aro-ci-pool + steps: + - template: ./templates/template-checkout.yml + + - script: | + set -xe + + # Install podman for containerized testing + sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + sudo dnf install -y podman + + # Ensure podman is available in the current shell session + export PATH=$PATH:/usr/bin:/usr/local/bin + which podman + podman --version + + # run build + export PODMAN_REMOTE_ARGS="-r --url=tcp://localhost:8888" + + # Stop podman + kill_podman + # Run unit tests + make unit-test-go + target: ubi8