Skip to content

Commit

Permalink
Makefile modified
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhadapaithankar committed Aug 27, 2024
1 parent 3932312 commit dae1846
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
90 changes: 45 additions & 45 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ validate-fips:

.PHONY: unit-test-go
unit-test-go:
go run ${GOTESTSUM} --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
podman build -t my-image:latest .
podman create --name test-container my-image:latest
podman start test-container
podman exec test-container go run ${GOTESTSUM} --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
podman stop test-container
podman rm test-container

.PHONY: unit-test-go-coverpkg
unit-test-go-coverpkg:
Expand Down

0 comments on commit dae1846

Please sign in to comment.