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 07f515a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 46 deletions.
118 changes: 73 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 Expand Up @@ -280,3 +280,31 @@ 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

Check failure on line 307 in .pipelines/ci.yml

View workflow job for this annotation

GitHub Actions / mega-linter-yaml

307:1 [trailing-spaces] trailing spaces
# Run unit tests
make unit-test-go
target: ubi8
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ validate-fips:

.PHONY: unit-test-go
unit-test-go:
go run ${GOTESTSUM} --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
podman exec test-container go run ${GOTESTSUM} --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...


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

0 comments on commit 07f515a

Please sign in to comment.