ARO-RP/Makefile

461 строка
16 KiB
Makefile
Исходник Постоянная ссылка Обычный вид История

2021-07-20 22:59:48 +03:00
SHELL = /bin/bash
TAG ?= $(shell git describe --exact-match 2>/dev/null)
COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty)
ARO_IMAGE_BASE = ${RP_IMAGE_ACR}.azurecr.io/aro
E2E_FLAGS ?= -test.v --ginkgo.v --ginkgo.timeout 180m --ginkgo.flake-attempts=2 --ginkgo.junit-report=e2e-report.xml
E2E_LABEL ?= !smoke&&!regressiontest
GO_FLAGS ?= -tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper
OC ?= oc
export GOFLAGS=$(GO_FLAGS)
2019-11-30 16:51:47 +03:00
# fluentbit version must also be updated in RP code, see pkg/util/version/const.go
MARINER_VERSION = 20240301
FLUENTBIT_VERSION = 1.9.10
FLUENTBIT_IMAGE ?= ${RP_IMAGE_ACR}.azurecr.io/fluentbit:$(FLUENTBIT_VERSION)-cm$(MARINER_VERSION)
AUTOREST_VERSION = 3.6.3
AUTOREST_IMAGE = quay.io/openshift-on-azure/autorest:${AUTOREST_VERSION}
GATEKEEPER_VERSION = v3.15.1
# Golang version go mod tidy compatibility
GOLANG_VERSION ?= 1.21
include .bingo/Variables.mk
ifneq ($(shell uname -s),Darwin)
export CGO_CFLAGS=-Dgpgme_off_t=off_t
endif
2020-08-10 15:25:30 +03:00
ifeq ($(TAG),)
VERSION = $(COMMIT)
else
VERSION = $(TAG)
endif
# default to registry.access.redhat.com for build images on local builds and CI builds without $RP_IMAGE_ACR set.
ifeq ($(RP_IMAGE_ACR),arointsvc)
REGISTRY = arointsvc.azurecr.io
else ifeq ($(RP_IMAGE_ACR),arosvc)
REGISTRY = arosvc.azurecr.io
else ifeq ($(RP_IMAGE_ACR),)
REGISTRY = registry.access.redhat.com
else
REGISTRY = $(RP_IMAGE_ACR)
endif
# prod images
ARO_IMAGE ?= $(ARO_IMAGE_BASE):$(VERSION)
GATEKEEPER_IMAGE ?= ${REGISTRY}/gatekeeper:$(GATEKEEPER_VERSION)
2024-06-12 18:30:56 +03:00
.PHONY: check-release
check-release:
# Check that VERSION is a valid tag when building an official release (when RELEASE=true).
ifeq ($(RELEASE), true)
ifeq ($(TAG), $(VERSION))
@echo Building release version $(VERSION)
else
$(error $(shell git describe --exact-match) Ensure there is an annotated tag (git tag -a) for git commit $(COMMIT))
endif
endif
2024-06-12 18:30:56 +03:00
.PHONY: build-all
build-all:
go build ./...
2024-06-12 18:30:56 +03:00
.PHONY: aro
aro: check-release generate
go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro
.PHONY: runlocal-rp
runlocal-rp:
go run -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro rp
2024-06-12 18:30:56 +03:00
.PHONY: az
az: pyenv
. pyenv/bin/activate && \
cd python/az/aro && \
python3 ./setup.py bdist_egg && \
python3 ./setup.py bdist_wheel || true && \
2021-08-16 15:44:58 +03:00
rm -f ~/.azure/commandIndex.json # https://github.com/Azure/azure-cli/issues/14997
2024-06-12 18:30:56 +03:00
.PHONY: clean
2019-11-18 09:24:26 +03:00
clean:
2019-12-22 20:47:29 +03:00
rm -rf python/az/aro/{aro.egg-info,build,dist} aro
find python -type f -name '*.pyc' -delete
find python -type d -name __pycache__ -delete
find -type d -name 'gomock_reflect_[0-9]*' -exec rm -rf {} \+ 2>/dev/null
2019-11-18 09:24:26 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: client
client: generate $(GOIMPORTS)
hack/build-client.sh "${AUTOREST_IMAGE}" 2020-04-30 2021-09-01-preview 2022-04-01 2022-09-04 2023-04-01 2023-07-01-preview 2023-09-04 2023-11-22 2024-08-12-preview
2019-12-03 14:33:55 +03:00
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to
# override COMMIT.
2024-06-12 18:30:56 +03:00
.PHONY: deploy
deploy:
go run -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro deploy dev-config.yaml ${LOCATION}
2024-06-12 18:30:56 +03:00
.PHONY: dev-config.yaml
dev-config.yaml:
go run ./hack/gendevconfig >dev-config.yaml
2024-06-12 18:30:56 +03:00
.PHONY: discoverycache
discoverycache:
$(MAKE) admin.kubeconfig
KUBECONFIG=admin.kubeconfig go run ./hack/gendiscoverycache
$(MAKE) generate
2024-06-12 18:30:56 +03:00
.PHONY: generate
generate: install-tools
2019-12-11 15:06:19 +03:00
go generate ./...
# TODO: This does not work outside of GOROOT. We should replace all usage of the
# clientset with controller-runtime so we don't need to generate it.
2024-06-12 18:30:56 +03:00
.PHONY: generate-operator-apiclient
generate-operator-apiclient: $(GOIMPORTS) $(CLIENT_GEN)
$(CLIENT_GEN) --clientset-name versioned --input-base ./pkg/operator/apis --input aro.openshift.io/v1alpha1,preview.aro.openshift.io/v1alpha1 --output-package ./pkg/operator/clientset --go-header-file ./hack/licenses/boilerplate.go.txt
gofmt -s -w ./pkg/operator/clientset
$(GOIMPORTS) -local=github.com/Azure/ARO-RP -e -w ./pkg/operator/clientset ./pkg/operator/apis
2024-06-12 18:30:56 +03:00
.PHONY: generate-guardrails
Guardrails policies (M1) (#2970) * Revert "temporarily remove policies other than the machine one as the example and test policy to create a base code pr" This reverts commit 08d377d4b81d022729bdf1f464da37c9c3d2a5d9. * extracted shared rego resources to a separate lib * improvement: rego unit test and gator test polishing (#2767) * rego unit test and gator test polishing * lint fix * rego lint fix * adjusted user id related judgement plus match kinds for resources other than pod * added test cases for priv'd ns to cover pull-secret deletion * add new policy for machine config modification (#2879) * add new policy for machine config modification * reformat yaml * revise api group logic * added pod host path policy * dont run guardrails if a standard gatekeeper instance is already started * comment out corresponding gator tests as r/w PV check is temporarily removed * satisfy mega linter * temporarily backoff the standard gatekeeper check * enable standard gatekeeper check with proper test case modifications * comment out non-namespaced resources * add k8s specific namespaces to the priv'd list * update README plus add two SA to allowed list * update Guardrails README * a typo in README * allow policies to enforce on openshift-azure-guardrails namespace * added group support for user validation * update: Guardrail policy scripts and doc updates (#2941) * update generate.sh to support single dir gen * update scripts to support params * update README * added usage print for scripts * change to flexible mode for username, group and SA name validation * update get func to print more debug info * rely solely on userInfo for user authentication * extend audit-interval to slow down the audit run, plus display more violations * roll back a temp change for local test * dont allow updates for machine and machineset * removed MachineSet * unified the constraint filename and resource name to make the config easier * adjust constraint and template name and kind as per convention * update gatekeeper params, affinity and tolerations * log violations * white list more user and group * extend priv'd ns protection to ns itself * add guardrails policy generate entry in makefile * make gator in README lower cased to keep consistent with official doc --------- Co-authored-by: Arris Li <huili@redhat.com>
2023-07-18 07:04:40 +03:00
generate-guardrails:
cd pkg/operator/controllers/guardrails/policies && ./scripts/generate.sh > /dev/null
2024-06-12 18:30:56 +03:00
.PHONY: generate-kiota
generate-kiota: $(GOIMPORTS)
2023-08-25 05:21:10 +03:00
kiota generate --clean-output -l go -o ./pkg/util/graph/graphsdk -n "github.com/Azure/ARO-RP/pkg/util/graph/graphsdk" -d hack/graphsdk/openapi.yaml -c GraphBaseServiceClient --additional-data=False --backing-store=True
find ./pkg/util/graph/graphsdk -type f -name "*.go" -exec sed -i'' -e 's\github.com/azure/aro-rp\github.com/Azure/ARO-RP\g' {} +
gofmt -s -w pkg/util/graph/graphsdk
$(GOIMPORTS) -w -local=github.com/Azure/ARO-RP pkg/util/graph/graphsdk
2023-08-25 05:21:10 +03:00
go run ./hack/validate-imports pkg/util/graph/graphsdk
go run ./hack/licenses -dirs ./pkg/util/graph/graphsdk
2024-06-12 18:30:56 +03:00
.PHONY: init-contrib
init-contrib:
install -v hack/git/hooks/* .git/hooks/
2024-06-12 18:30:56 +03:00
.PHONY: image-aro-multistage
image-aro-multistage:
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-multistage -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
2024-06-12 18:30:56 +03:00
.PHONY: image-autorest
2021-08-13 19:47:17 +03:00
image-autorest:
docker build --platform=linux/amd64 --network=host --no-cache --build-arg AUTOREST_VERSION="${AUTOREST_VERSION}" --build-arg REGISTRY=$(REGISTRY) -f Dockerfile.autorest -t ${AUTOREST_IMAGE} .
2021-08-13 19:47:17 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: image-fluentbit
2020-02-28 07:04:37 +03:00
image-fluentbit:
2023-03-30 06:42:59 +03:00
docker build --platform=linux/amd64 --network=host --build-arg VERSION=$(FLUENTBIT_VERSION) --build-arg MARINER_VERSION=$(MARINER_VERSION) -f Dockerfile.fluentbit -t $(FLUENTBIT_IMAGE) .
2020-02-28 07:04:37 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: image-proxy
2023-03-15 02:29:57 +03:00
image-proxy:
docker pull $(REGISTRY)/ubi8/ubi-minimal
docker build --platform=linux/amd64 --no-cache -f Dockerfile.proxy -t $(REGISTRY)/proxy:latest --build-arg REGISTRY=$(REGISTRY) .
2024-06-12 18:30:56 +03:00
.PHONY: image-gatekeeper
image-gatekeeper:
docker build --platform=linux/amd64 --network=host --build-arg GATEKEEPER_VERSION=$(GATEKEEPER_VERSION) --build-arg REGISTRY=$(REGISTRY) -f Dockerfile.gatekeeper -t $(GATEKEEPER_IMAGE) .
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-aro-multistage
publish-image-aro-multistage: image-aro-multistage
docker push $(ARO_IMAGE)
ifeq ("${RP_IMAGE_ACR}-$(BRANCH)","arointsvc-master")
docker tag $(ARO_IMAGE) arointsvc.azurecr.io/aro:latest
docker push arointsvc.azurecr.io/aro:latest
endif
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-autorest
2021-08-13 19:47:17 +03:00
publish-image-autorest: image-autorest
docker push ${AUTOREST_IMAGE}
2021-08-13 19:47:17 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-fluentbit
publish-image-fluentbit: image-fluentbit
2021-11-16 21:29:01 +03:00
docker push $(FLUENTBIT_IMAGE)
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-proxy
publish-image-proxy: image-proxy
docker push ${RP_IMAGE_ACR}.azurecr.io/proxy:latest
2019-12-29 17:49:38 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-gatekeeper
publish-image-gatekeeper: image-gatekeeper
docker push $(GATEKEEPER_IMAGE)
2024-06-12 18:30:56 +03:00
.PHONY: image-e2e
image-e2e:
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-e2e -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
2024-06-12 18:30:56 +03:00
.PHONY: publish-image-e2e
publish-image-e2e: image-e2e
docker push $(ARO_IMAGE)
2024-06-12 18:30:56 +03:00
.PHONY: extract-aro-docker
extract-aro-docker:
hack/ci-utils/extractaro.sh ${ARO_IMAGE}
2024-06-12 18:30:56 +03:00
.PHONY: proxy
2019-12-29 17:49:38 +03:00
proxy:
CGO_ENABLED=0 go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./hack/proxy
2019-11-18 09:24:26 +03:00
.PHONY: runlocal-portal
runlocal-portal:
go run -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro portal
2024-06-12 18:30:56 +03:00
.PHONY: build-portal
build-portal:
cd portal/v2 && npm install && npm run build
2024-06-12 18:30:56 +03:00
.PHONY: pyenv
2020-10-08 03:04:39 +03:00
pyenv:
python3 -m venv pyenv
2020-10-08 03:04:39 +03:00
. pyenv/bin/activate && \
pip install -U pip && \
pip install -r requirements.txt && \
azdev setup -r .
2019-12-16 19:52:17 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: secrets
2019-12-04 16:17:27 +03:00
secrets:
@[ "${SECRET_SA_ACCOUNT_NAME}" ] || ( echo ">> SECRET_SA_ACCOUNT_NAME is not set"; exit 1 )
2019-12-04 16:17:27 +03:00
rm -rf secrets
az storage blob download -n secrets.tar.gz -c secrets -f secrets.tar.gz --account-name ${SECRET_SA_ACCOUNT_NAME} >/dev/null
2020-02-27 16:35:25 +03:00
tar -xzf secrets.tar.gz
rm secrets.tar.gz
2019-12-04 16:17:27 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: secrets-update
2019-12-04 16:17:27 +03:00
secrets-update:
@[ "${SECRET_SA_ACCOUNT_NAME}" ] || ( echo ">> SECRET_SA_ACCOUNT_NAME is not set"; exit 1 )
2020-02-27 16:35:25 +03:00
tar -czf secrets.tar.gz secrets
az storage blob upload -n secrets.tar.gz -c secrets -f secrets.tar.gz --overwrite --account-name ${SECRET_SA_ACCOUNT_NAME} >/dev/null
2020-02-27 16:34:46 +03:00
rm secrets.tar.gz
2019-12-04 16:17:27 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: tunnel
tunnel:
go run ./hack/tunnel $(shell az network public-ip show -g ${RESOURCEGROUP} -n rp-pip --query 'ipAddress')
2024-06-12 18:30:56 +03:00
.PHONY: e2e.test
e2e.test:
2022-06-15 03:10:42 +03:00
go test ./test/e2e/... -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" -o e2e.test
2024-06-12 18:30:56 +03:00
.PHONY: e2etools
e2etools:
CGO_ENABLED=0 go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./hack/cluster
CGO_ENABLED=0 go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./hack/db
CGO_ENABLED=0 go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./hack/portalauth
$(BINGO) get -l gojq
2024-06-12 18:30:56 +03:00
.PHONY: test-e2e
test-e2e: e2e.test
2024-07-03 18:29:36 +03:00
./e2e.test $(E2E_FLAGS) --ginkgo.label-filter="$(E2E_LABEL)"
2020-01-23 09:25:27 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: test-go
test-go: generate build-all validate-go lint-go unit-test-go
2024-06-12 18:30:56 +03:00
.PHONY: validate-go
validate-go: $(GOIMPORTS)
2020-01-24 02:55:22 +03:00
gofmt -s -w cmd hack pkg test
$(GOIMPORTS) -w -local=github.com/Azure/ARO-RP cmd hack pkg test
2020-01-24 02:55:22 +03:00
go run ./hack/validate-imports cmd hack pkg test
go run ./hack/licenses
@[ -z "$$(ls pkg/util/*.go 2>/dev/null)" ] || (echo error: go files are not allowed in pkg/util, use a subpackage; exit 1)
@[ -z "$$(find -name "*:*")" ] || (echo error: filenames with colons are not allowed on Windows, please rename; exit 1)
2019-12-02 14:04:46 +03:00
@sha256sum --quiet -c .sha256sum || (echo error: client library is stale, please run make client; exit 1)
go test -tags e2e -run ^$$ ./test/e2e/...
2024-06-12 18:30:56 +03:00
.PHONY: validate-go-action
validate-go-action:
go run ./hack/licenses -validate -ignored-go vendor,pkg/client,.git -ignored-python python/client,python/az/aro/azext_aro/aaz,vendor,.git
go run ./hack/validate-imports cmd hack pkg test
@[ -z "$$(ls pkg/util/*.go 2>/dev/null)" ] || (echo error: go files are not allowed in pkg/util, use a subpackage; exit 1)
@[ -z "$$(find -name "*:*")" ] || (echo error: filenames with colons are not allowed on Windows, please rename; exit 1)
@sha256sum --quiet -c .sha256sum || (echo error: client library is stale, please run make client; exit 1)
2024-06-12 18:30:56 +03:00
.PHONY: validate-fips
validate-fips: $(BINGO)
$(BINGO) get -l fips-detect
$(BINGO) get -l gojq
hack/fips/validate-fips.sh ./aro
2024-06-12 18:30:56 +03:00
.PHONY: unit-test-go
unit-test-go: $(GOTESTSUM)
$(GOTESTSUM) --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
2019-11-21 05:32:34 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: unit-test-go-coverpkg
unit-test-go-coverpkg: $(GOTESTSUM)
$(GOTESTSUM) --format pkgname --junitfile report.xml -- -coverpkg=./... -coverprofile=cover_coverpkg.out ./...
2024-06-12 18:30:56 +03:00
.PHONY: lint-go
2020-11-14 03:07:17 +03:00
lint-go:
$(GOLANGCI_LINT) run --verbose
2024-06-12 18:30:56 +03:00
.PHONY: lint-admin-portal
lint-admin-portal:
2022-09-13 03:13:51 +03:00
docker build --platform=linux/amd64 --build-arg REGISTRY=$(REGISTRY) -f Dockerfile.portal_lint . -t linter:latest --no-cache
docker run --platform=linux/amd64 -t --rm linter:latest
2024-06-12 18:30:56 +03:00
.PHONY: test-python
test-python: pyenv az
2020-10-08 03:04:39 +03:00
. pyenv/bin/activate && \
azdev linter && \
improve Python unit testing and refactor _validators.py (#2120) * refactor: apply Guard clauses in _validators.py to simplify code * fix _validators.py trailing whitespace * improve python test tructure, include execution of unit tests in make test-python * crate make directive to run python unit tests, add unit tests for azext_aro._validators.validate_cidr * add tests for test_validate_client_id and include test cases description * add unit tests for validate_client_secret from azext_aro._validators * add explicit fields to named tuple in test cases in test_validators.py * add two test scenarios for validate_cluster_resource_group * simplify mocks * add test case for test_validate_cluster_resource_group * improve test descriptions * add test_validate_disk_encryption_set test to test validate_disk_encryption_set * add test cases to test_validate_disk_encryption_set() * refactor test_validator.py to use classes instead of namedtuples. Use mocks instead of specific defined classes * refactor (simplify code): remove explicit assignemnt to None when it is the default value * create test_validate_domain() with 1st test case * add test case, domain with '_' * explicit import of unittest.TestCase * fix test message in test_validate_domain * finish test_validate_domain() * finish test_validate_sdn() and test_validate_pull_secret() * create test_validate_subnet() with first test case * finish test_validate_subnet() and minor refactor in _validators.py * create test_validate_subnets() and add first test case * finish validate_vnet_resource_group_name() * finish test_validate_worker_count() of test_validators.py and simple refactor in _validators.py * finish test_validate_worker_vm_disk_size_gb() * refactor _validators.py * add test_validate_refresh_cluster_credentials() and minor refactor of test_validators() * refactor _test_validators.py to use pytest, create script and invoke it from Makefile * simplify test_validate_cidr() using pytest.mark.parametrize * simplify some tests using pytest.mark.parametrize * finish applying pytest.mark.parametrize * clean up Makefile test-python * add blank line to hack/unit-test-python.sh * fix typo in test case * fix mega-linter error, blank space * fix test case to fail due to invalid range * fix typo in beeing to be being * remove redundant test case * reformat code for better readability * add missing license to __init__.py files
2022-06-09 10:24:31 +03:00
azdev style && \
hack/unit-test-python.sh
2024-06-12 18:30:56 +03:00
.PHONY: shared-cluster-login
shared-cluster-login:
@oc login $(shell az aro show -g sre-shared-cluster -n sre-shared-cluster -ojson --query apiserverProfile.url) \
-u kubeadmin \
-p $(shell az aro list-credentials -g sre-shared-cluster -n sre-shared-cluster -ojson --query "kubeadminPassword")
2024-06-12 18:30:56 +03:00
.PHONY: shared-cluster-create
shared-cluster-create:
./hack/shared-cluster.sh create
2024-06-12 18:30:56 +03:00
.PHONY: shared-cluster-delete
shared-cluster-delete:
./hack/shared-cluster.sh delete
2024-06-12 18:30:56 +03:00
.PHONY: unit-test-python
improve Python unit testing and refactor _validators.py (#2120) * refactor: apply Guard clauses in _validators.py to simplify code * fix _validators.py trailing whitespace * improve python test tructure, include execution of unit tests in make test-python * crate make directive to run python unit tests, add unit tests for azext_aro._validators.validate_cidr * add tests for test_validate_client_id and include test cases description * add unit tests for validate_client_secret from azext_aro._validators * add explicit fields to named tuple in test cases in test_validators.py * add two test scenarios for validate_cluster_resource_group * simplify mocks * add test case for test_validate_cluster_resource_group * improve test descriptions * add test_validate_disk_encryption_set test to test validate_disk_encryption_set * add test cases to test_validate_disk_encryption_set() * refactor test_validator.py to use classes instead of namedtuples. Use mocks instead of specific defined classes * refactor (simplify code): remove explicit assignemnt to None when it is the default value * create test_validate_domain() with 1st test case * add test case, domain with '_' * explicit import of unittest.TestCase * fix test message in test_validate_domain * finish test_validate_domain() * finish test_validate_sdn() and test_validate_pull_secret() * create test_validate_subnet() with first test case * finish test_validate_subnet() and minor refactor in _validators.py * create test_validate_subnets() and add first test case * finish validate_vnet_resource_group_name() * finish test_validate_worker_count() of test_validators.py and simple refactor in _validators.py * finish test_validate_worker_vm_disk_size_gb() * refactor _validators.py * add test_validate_refresh_cluster_credentials() and minor refactor of test_validators() * refactor _test_validators.py to use pytest, create script and invoke it from Makefile * simplify test_validate_cidr() using pytest.mark.parametrize * simplify some tests using pytest.mark.parametrize * finish applying pytest.mark.parametrize * clean up Makefile test-python * add blank line to hack/unit-test-python.sh * fix typo in test case * fix mega-linter error, blank space * fix test case to fail due to invalid range * fix typo in beeing to be being * remove redundant test case * reformat code for better readability * add missing license to __init__.py files
2022-06-09 10:24:31 +03:00
unit-test-python:
hack/unit-test-python.sh
2024-06-12 18:30:56 +03:00
.PHONY: admin.kubeconfig
2020-03-12 05:45:32 +03:00
admin.kubeconfig:
hack/get-admin-kubeconfig.sh /subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${RESOURCEGROUP}/providers/Microsoft.RedHatOpenShift/openShiftClusters/${CLUSTER} >admin.kubeconfig
2020-03-11 01:22:20 +03:00
2024-06-12 18:30:56 +03:00
.PHONY: aks.kubeconfig
aks.kubeconfig:
hack/get-admin-aks-kubeconfig.sh
.PHONY: go-tidy
go-tidy: # Run go mod tidy - add missing and remove unused modules.
go mod tidy -compat=${GOLANG_VERSION}
.PHONY: go-vendor
go-vendor: # Run go mod vendor - only modules that are used in the source code will be vendored in (make vendored copy of dependencies).
go mod vendor
.PHONY: go-verify
go-verify: go-tidy go-vendor # Run go mod verify - verify dependencies have expected content
go mod verify
2024-06-12 18:30:56 +03:00
.PHONY: vendor
vendor:
2021-05-19 16:08:23 +03:00
# See comments in the script for background on why we need it
2020-11-17 12:55:24 +03:00
hack/update-go-module-dependencies.sh
$(MAKE) go-verify
.PHONY: xmlcov
xmlcov: $(GOCOV) $(GOCOV_XML)
$(GOCOV) convert cover.out | $(GOCOV_XML) > coverage.xml
.PHONY: install-tools
install-tools: $(BINGO)
$(BINGO) get -l
# Fixes https://github.com/uber-go/mock/issues/185 for MacOS users
ifeq ($(shell uname -s),Darwin)
codesign -f -s - ${GOPATH}/bin/mockgen
endif
###############################################################################
# Containerized CI/CD RP
###############################################################################
###############################################################################
# Config
###############################################################################
# REGISTRY is used from above, and defines what base images are used in the
# build process
# VERSION is used from above, and is used during binary compile time and for
# all image tags.
# Configures use of podman build cache. Likely you want `false` locally. Always
# `true` in CI.
NO_CACHE ?= true
# Useful for CI pipelines where we need to run podman as a service, and specify
# that service as a URL (see .pipelines/ci.yml). This should be invoked on all
# use of `podman` in the Makefile.
PODMAN_REMOTE_ARGS ?=
DOCKER_BUILD_CI_ARGS ?=
# Image names that will be found in the local podman image registry after build
# (tags are always VERSION).
LOCAL_ARO_RP_IMAGE ?= aro
LOCAL_ARO_PORTAL_BUILD_IMAGE ?= $(LOCAL_ARO_RP_IMAGE)-portal-build
LOCAL_ARO_RP_BUILD_IMAGE ?= $(LOCAL_ARO_RP_IMAGE)-build
LOCAL_AZ_EXT_ARO_IMAGE ?= azext-aro
LOCAL_TUNNEL_IMAGE ?= aro-tunnel
###############################################################################
# Targets
###############################################################################
.PHONY: ci-azext-aro
ci-azext-aro:
docker build . $(DOCKER_BUILD_CI_ARGS) \
-f Dockerfile.ci-azext-aro \
--platform=linux/amd64 \
--no-cache=$(NO_CACHE) \
-t $(LOCAL_AZ_EXT_ARO_IMAGE):$(VERSION)
.PHONY: ci-clean
ci-clean:
$(shell podman $(PODMAN_REMOTE_ARGS) ps --external --format "{{.Command}} {{.ID}}" | grep buildah | cut -d " " -f 2 | xargs podman $(PODMAN_REMOTE_ARGS) rm -f > /dev/null)
podman $(PODMAN_REMOTE_ARGS) \
image prune --all --filter="label=aro-*=true"
.PHONY: ci-rp
ci-rp: fix-macos-vendor
docker build . ${DOCKER_BUILD_CI_ARGS} \
-f Dockerfile.ci-rp \
--ulimit=nofile=4096:4096 \
--build-arg REGISTRY=${REGISTRY} \
--build-arg ARO_VERSION=${VERSION} \
--no-cache=${NO_CACHE} \
--target=builder \
-t ${LOCAL_ARO_RP_BUILD_IMAGE}:${VERSION}
docker compose build rp
# Extract test coverage files from build to local filesystem
docker create --name extract_cover_out ${LOCAL_ARO_RP_BUILD_IMAGE}:${VERSION}; \
docker cp extract_cover_out:/app/report.xml ./report.xml; \
docker cp extract_cover_out:/app/coverage.xml ./coverage.xml; \
docker rm extract_cover_out;
.PHONY: ci-tunnel
ci-tunnel: fix-macos-vendor
podman $(PODMAN_REMOTE_ARGS) \
build . \
-f Dockerfile.ci-tunnel \
--ulimit=nofile=4096:4096 \
--build-arg REGISTRY=$(REGISTRY) \
--build-arg ARO_VERSION=$(VERSION) \
--no-cache=$(NO_CACHE) \
-t $(LOCAL_TUNNEL_IMAGE):$(VERSION)
# MacOS is a case insensitive filesystem. Linux is case sensitive. This target
# makes podman builds possible on MacOS.
.PHONY: fix-macos-vendor
fix-macos-vendor:
ifeq ($(shell uname -s),Darwin)
mv ./vendor/github.com/Microsoft ./vendor/github.com/temp-microsoft && mv ./vendor/github.com/temp-microsoft ./vendor/github.com/microsoft || true
endif
.PHONY: run-portal
run-portal:
docker compose up portal
# run-rp executes the RP locally as similarly as possible to production. That
# includes the use of Hive, meaning you need a VPN connection.
.PHONY: run-rp
run-rp: aks.kubeconfig
docker compose rm -sf rp
docker compose up rp
.PHONY: run-selenium
run-selenium:
docker compose up selenium
.PHONY: validate-roledef
validate-roledef:
go run ./hack/role -verified-version "$(OCP_VERSION)" -oc-bin=$(OC)