Skip to content

Commit

Permalink
fixede the makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhadapaithankar committed Aug 27, 2024
1 parent e917862 commit ed88d9b
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 143 deletions.
202 changes: 79 additions & 123 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,136 +25,92 @@ resources:
- 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

variables:
- template: vars.yml

jobs:
- job: Python_Unit_Tests
pool:
name: 1es-aro-ci-pool
variables:
HOME: $(Agent.BuildDirectory)

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

- job: Lint_Az_ARO_Extension
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make test-python
- script: |
set -xe
go version
go env
displayName: Print Go version & env
target: golang
- 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
- script: |
set -xe
make generate
[[ -z "$(git status -s)" ]]
displayName: ⚙️ Run Golang code generate
target: golang
- 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'
- script: |
set -xe
make build-all
[[ -z "$(git status -s)" ]]
displayName: 🕵️ Build Golang code
target: golang
- 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'
variables:
ACR_FQDN: 'arosvcdev.azurecr.io' # ACR FQDN
REPOSITORY: 'my-image-repo'
IMAGE_TAG: $(Build.SourceBranchName)
steps:
- checkout: self
- script: |
set -xe
make unit-test-go
displayName: 🧪 Run Golang unit tests
target: golang
- 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)"
- task: PublishTestResults@2
displayName: 📊 Publish tests results
inputs:
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
condition: succeededOrFailed()

- script: |
set -eux
if docker pull ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG}; then
docker create --name coverage-container ${ACR_FQDN}/${REPOSITORY}:${IMAGE_TAG}
docker cp coverage-container:/go/src/ARO-RP/cover.out $(Build.SourcesDirectory)/cover.out || {
echo "Coverage file not found in container."
exit 1
}
docker rm coverage-container
else
echo "Image with tag ${IMAGE_TAG} not found in ${ACR_FQDN}/${REPOSITORY}"
exit 0 # Gracefully skip the coverage extraction if the image is not found
fi
displayName: 'Extract Coverage Report from Container'
- 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
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/cover.out
displayName: 'Publish Code Coverage Results'
- task: PublishCodeCoverageResults@1
displayName: 📈 Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
failIfCoverageEmpty: false
condition: succeededOrFailed()
target: golang

- stage: Golang_Code_Generation
jobs:
- job: Run_Golang_Code_Generate
displayName: "⚙️ Run Golang code generate"
pool:
name: 1es-aro-ci-pool
container: golang
variables:
GOCACHE: /tmp/gocache
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make generate
[[ -z "$(git status -s)" ]]
displayName: "Run Golang Code Generate"
- 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
Loading

0 comments on commit ed88d9b

Please sign in to comment.