ARO-RP/Makefile

213 строки
8.3 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
2019-11-30 16:51:47 +03:00
# fluentbit version must also be updated in RP code, see pkg/util/version/const.go
FLUENTBIT_VERSION = 1.9.9-1
2021-11-16 21:29:01 +03:00
FLUENTBIT_IMAGE ?= ${RP_IMAGE_ACR}.azurecr.io/fluentbit:$(FLUENTBIT_VERSION)
2022-08-04 14:32:20 +03:00
AUTOREST_VERSION = 3.6.2
2022-08-31 05:18:07 +03:00
AUTOREST_IMAGE = quay.io/openshift-on-azure/autorest:${AUTOREST_VERSION}
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
ARO_IMAGE ?= $(ARO_IMAGE_BASE):$(VERSION)
build-all:
go build -tags aro,containers_image_openpgp ./...
2019-12-22 20:47:29 +03:00
aro: generate
go build -tags aro,containers_image_openpgp,codec.safe -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro
runlocal-rp:
go run -tags aro,containers_image_openpgp -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro rp
2019-11-18 09:24:26 +03:00
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
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
2019-12-11 15:06:19 +03:00
client: generate
2022-07-06 00:35:51 +03:00
hack/build-client.sh "${AUTOREST_IMAGE}" 2020-04-30 2021-09-01-preview 2022-04-01 2022-09-04
2019-12-03 14:33:55 +03:00
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to
# override COMMIT.
deploy:
go run -tags aro,containers_image_openpgp -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro deploy dev-config.yaml ${LOCATION}
dev-config.yaml:
go run ./hack/gendevconfig >dev-config.yaml
discoverycache:
$(MAKE) admin.kubeconfig
KUBECONFIG=admin.kubeconfig go run ./hack/gendiscoverycache
$(MAKE) generate
2019-12-11 15:06:19 +03:00
generate:
go generate ./...
image-aro: aro e2e.test
docker pull $(REGISTRY)/ubi8/ubi-minimal
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
2019-12-29 17:49:38 +03:00
image-aro-multistage:
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-multistage -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
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
2020-02-28 07:04:37 +03:00
image-fluentbit:
docker build --platform=linux/amd64 --network=host --no-cache --build-arg VERSION=$(FLUENTBIT_VERSION) --build-arg REGISTRY=$(REGISTRY) -f Dockerfile.fluentbit -t $(FLUENTBIT_IMAGE) .
2020-02-28 07:04:37 +03:00
2019-12-29 17:49:38 +03:00
image-proxy: 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) .
publish-image-aro: image-aro
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
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
2021-08-13 19:47:17 +03:00
publish-image-autorest: image-autorest
docker push ${AUTOREST_IMAGE}
publish-image-fluentbit: image-fluentbit
2021-11-16 21:29:01 +03:00
docker push $(FLUENTBIT_IMAGE)
publish-image-proxy: image-proxy
docker push ${RP_IMAGE_ACR}.azurecr.io/proxy:latest
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
run-portal:
go run -tags aro,containers_image_openpgp -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=$(VERSION)" ./cmd/aro portal
build-portal:
cd portal/v1 && npm install && npm run build && cd ../v2 && npm install && npm run build
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 . && \
sed -i -e "s|^dev_sources = $(PWD)$$|dev_sources = $(PWD)/python|" ~/.azure/config
2019-12-16 19:52:17 +03:00
2019-12-04 16:17:27 +03:00
secrets:
2020-02-27 16:34:46 +03:00
@[ "${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
secrets-update:
2020-02-27 16:34:46 +03:00
@[ "${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
tunnel:
go run ./hack/tunnel $(shell az network public-ip show -g ${RESOURCEGROUP} -n rp-pip --query 'ipAddress')
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
test-e2e: e2e.test
./e2e.test $(E2E_FLAGS)
2020-01-23 09:25:27 +03:00
test-go: generate build-all validate-go lint-go unit-test-go
validate-go:
2020-01-24 02:55:22 +03:00
gofmt -s -w cmd hack pkg test
go run ./vendor/golang.org/x/tools/cmd/goimports -w -local=github.com/Azure/ARO-RP cmd hack pkg test
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)
2022-06-17 17:48:04 +03:00
go vet -tags containers_image_openpgp ./...
go test -tags e2e -run ^$$ ./test/e2e/...
validate-go-action:
go run ./hack/licenses -validate -ignored-go vendor,pkg/client,.git -ignored-python python/client,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)
validate-fips:
hack/fips/validate-fips.sh
unit-test-go:
go run ./vendor/gotest.tools/gotestsum/main.go --format pkgname --junitfile report.xml -- -tags=aro,containers_image_openpgp -coverprofile=cover.out ./...
2019-11-21 05:32:34 +03:00
2020-11-14 03:07:17 +03:00
lint-go:
hack/lint-go.sh
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
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
shared-cluster-login:
@oc login ${SHARED_CLUSTER_API} -u kubeadmin -p ${SHARED_CLUSTER_KUBEADMIN_PASSWORD}
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
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
aks.kubeconfig:
hack/get-admin-aks-kubeconfig.sh
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
2022-06-02 10:47:53 +03:00
.PHONY: admin.kubeconfig aks.kubeconfig aro az clean client deploy dev-config.yaml discoverycache generate image-aro image-aro-multistage image-fluentbit image-proxy lint-go runlocal-rp proxy publish-image-aro publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips