Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This is the new CI-RP stage for the pipline #3768

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ megalinter-reports/
/jq
/portalauth
.kiota.log
podmanlog
244 changes: 162 additions & 82 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,89 +28,169 @@ resources:
- 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

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

steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make test-python
[[ -z "$(git status -s)" ]]
displayName: 🧪Run Python Unit Tests
target: python

- 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/[email protected] convert cover.out | go run github.com/AlekSi/[email protected] > 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
stages:
- stage: NotContainerized
dependsOn: Containerized
jobs:
- job: Python_Unit_Tests
pool:
name: 1es-aro-ci-pool
variables:
HOME: $(Agent.BuildDirectory)

steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
make test-python
[[ -z "$(git status -s)" ]]
displayName: 🧪Run Python Unit Tests
target: python

- 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/[email protected] convert cover.out | go run github.com/AlekSi/[email protected] > 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:
- template: ./templates/template-checkout.yml
- script: |
set -xe
export NO_CACHE=true

# 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
export NO_CACHE=true

# 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
variables:
HOME: $(Agent.BuildDirectory)
steps:
- template: ./templates/template-checkout.yml
- script: |
set -xe
export AZDEV_CONFIG_DIR=$(Agent.BuildDirectory)/azdev-config
make test-python
[[ -z "$(git status -s)" ]]
target: python
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ runlocal-rp: ci-rp podman-secrets
--secret proxy-client.key,target=/app/secrets/proxy-client.key \
--secret proxy-client.crt,target=/app/secrets/proxy-client.crt \
--secret proxy.crt,target=/app/secrets/proxy.crt \
$(LOCAL_ARO_RP_IMAGE):$(VERSION) rp
$(LOCAL_ARO_RP_IMAGE):$(VERSION): rp

.PHONY: az
az: pyenv
Expand Down Expand Up @@ -206,12 +206,25 @@ ci-rp: fix-macos-vendor
--build-arg ARO_VERSION=$(VERSION) \
--no-cache=$(NO_CACHE) \
-t $(LOCAL_ARO_RP_IMAGE):$(VERSION)
podman $(PODMAN_REMOTE_ARGS) tag \
$(shell podman image ls --filter label=stage=portal-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1) \
$(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION)
podman $(PODMAN_REMOTE_ARGS) tag \
$(shell podman image ls --filter label=stage=rp-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1) \
$(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION)

# Tag the portal build image if it exists
@PORTAL_IMAGE_ID=$(shell podman $(PODMAN_REMOTE_ARGS) image ls --filter label=stage=portal-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1); \
if [ -n "$$PORTAL_IMAGE_ID" ]; then \
echo "Tagging Portal Image $$PORTAL_IMAGE_ID as $(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION)"; \
podman $(PODMAN_REMOTE_ARGS) tag $$PORTAL_IMAGE_ID $(LOCAL_ARO_PORTAL_BUILD_IMAGE):$(VERSION); \
else \
echo "No Portal Image found with label stage=portal-build-cache-layer"; \
shubhadapaithankar marked this conversation as resolved.
Show resolved Hide resolved
fi

# Tag the RP build image if it exists
@RP_IMAGE_ID=$(shell podman $(PODMAN_REMOTE_ARGS) image ls --filter label=stage=rp-build-cache-layer --noheading --format "{{.Id}}" | tail -n 1); \
if [ -n "$$RP_IMAGE_ID" ]; then \
echo "Tagging RP Image $$RP_IMAGE_ID as $(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION)"; \
podman $(PODMAN_REMOTE_ARGS) tag $$RP_IMAGE_ID $(LOCAL_ARO_RP_BUILD_IMAGE):$(VERSION); \
else \
echo "No RP Image found with label stage=rp-build-cache-layer"; \
shubhadapaithankar marked this conversation as resolved.
Show resolved Hide resolved
fi


.PHONY: ci-tunnel
ci-tunnel: fix-macos-vendor
Expand Down
39 changes: 1 addition & 38 deletions hack/e2e/run-rp-and-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,44 +103,6 @@ kill_vpn() {
while read pid; do sudo kill $pid; done <vpnpid
}

run_podman() {
echo "########## 🚀 Run Podman in background ##########"
podman --log-level=debug system service --time=0 tcp://127.0.0.1:8888 >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
Expand Down
Loading
Loading