2021-09-23 17:27:06 +00:00
|
|
|
REGISTRY := public.ecr.aws/zero-downtime
|
2022-07-15 12:35:27 +00:00
|
|
|
IMAGE := cloudbender
|
2022-02-08 12:49:08 +00:00
|
|
|
REGION := us-east-1
|
|
|
|
|
|
|
|
# Parse version from latest git semver tag
|
|
|
|
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
|
|
|
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
|
|
|
|
|
2022-07-15 12:35:27 +00:00
|
|
|
ifneq ($(TRIVY_REMOTE),)
|
|
|
|
TRIVY_OPTS := --server ${TRIVY_REMOTE}
|
2022-02-08 12:49:08 +00:00
|
|
|
endif
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
.PHONY: pytest pybuild test_upload upload all build test push scan
|
2019-06-18 16:48:39 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
all: pytest pybuild
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
pytest:
|
2022-02-22 10:04:29 +00:00
|
|
|
flake8 cloudbender tests
|
2019-06-18 16:48:39 +00:00
|
|
|
TEST=True pytest --log-cli-level=DEBUG
|
2019-02-07 22:05:33 +00:00
|
|
|
|
|
|
|
clean:
|
2019-09-02 11:13:40 +00:00
|
|
|
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
2019-06-18 16:48:39 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
pybuild:
|
2022-06-28 11:15:45 +00:00
|
|
|
hatchling build
|
2019-02-07 22:05:33 +00:00
|
|
|
|
2022-06-30 15:42:49 +00:00
|
|
|
test_upload: pybuild
|
|
|
|
twine upload --repository-url https://test.pypi.org/legacy/ --non-interactive dist/cloudbender-*.whl
|
2019-02-07 22:05:33 +00:00
|
|
|
|
2022-06-30 15:42:49 +00:00
|
|
|
upload: pybuild
|
|
|
|
twine upload -r pypi --non-interactive dist/cloudbender-*.whl
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
build:
|
2022-07-15 12:35:27 +00:00
|
|
|
podman build --rm -t $(IMAGE):$(TAG) -t $(IMAGE):latest .
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
test:
|
2022-02-08 13:14:24 +00:00
|
|
|
@echo "Not implemented (yet)"
|
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
push:
|
2022-02-08 12:49:08 +00:00
|
|
|
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
2022-07-15 12:35:27 +00:00
|
|
|
podman tag $(IMAGE):latest $(REGISTRY)/$(IMAGE):$(TAG) $(REGISTRY)/$(IMAGE):latest
|
|
|
|
podman push $(REGISTRY)/$(IMAGE):$(TAG)
|
|
|
|
podman push $(REGISTRY)/$(IMAGE):latest
|
|
|
|
|
2022-07-15 12:38:22 +00:00
|
|
|
scan:
|
2022-07-15 12:35:27 +00:00
|
|
|
trivy image $(TRIVY_OPTS) $(IMAGE):$(TAG)
|
|
|
|
|
|
|
|
# Delete all untagged images
|
|
|
|
.PHONY: rm-remote-untagged
|
|
|
|
rm-remote-untagged:
|
|
|
|
@echo "Removing all untagged images from $(IMAGE) in $(REGION)"
|
|
|
|
@aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$(for image in $$(aws ecr-public describe-images --repository-name $(IMAGE) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done)
|