-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) · 2.09 KB
/
Makefile
File metadata and controls
51 lines (41 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.PHONY: test-env test test-coverage test-coverage-html test-clean build gcp-login gcp-push gcp-restart gcp-deploy
# Build the container image
build:
podman build -t shareabouts-api -f Containerfile .
# Authenticate podman to GCP Container Registry
gcp-login:
gcloud auth print-access-token | podman login -u oauth2accesstoken --password-stdin gcr.io
# Push image to GCP Container Registry
# Requires: PROJECT_ID, ENVIRONMENT_NAME environment variables
gcp-push: gcp-login
@if [ -z "$(PROJECT_ID)" ]; then echo "Error: PROJECT_ID is not set"; exit 1; fi
@if [ -z "$(ENVIRONMENT_NAME)" ]; then echo "Error: ENVIRONMENT_NAME is not set"; exit 1; fi
podman tag shareabouts-api gcr.io/$(PROJECT_ID)/shareabouts-api:latest-$(ENVIRONMENT_NAME)
podman push gcr.io/$(PROJECT_ID)/shareabouts-api:latest-$(ENVIRONMENT_NAME)
# Restart the Cloud Run service with the latest image
# Requires: PROJECT_ID, ENVIRONMENT_NAME, SERVICE_NAME, REGION environment variables
gcp-restart:
@if [ -z "$(PROJECT_ID)" ]; then echo "Error: PROJECT_ID is not set"; exit 1; fi
@if [ -z "$(ENVIRONMENT_NAME)" ]; then echo "Error: ENVIRONMENT_NAME is not set"; exit 1; fi
@if [ -z "$(SERVICE_NAME)" ]; then echo "Error: SERVICE_NAME is not set"; exit 1; fi
@if [ -z "$(REGION)" ]; then echo "Error: REGION is not set"; exit 1; fi
gcloud run services update $(SERVICE_NAME)-$(ENVIRONMENT_NAME) \
--region $(REGION) \
--image gcr.io/$(PROJECT_ID)/shareabouts-api:latest-$(ENVIRONMENT_NAME)
# Full deployment: build, push, and restart
gcp-deploy: build gcp-push gcp-restart
# Stub .env file
test-env:
cp .env.template .env
# Run tests in a clean container environment
test: test-env test-clean
podman-compose run --rm test pytest
# Run tests with coverage report
test-coverage: test-env test-clean
podman-compose run --rm test pytest --cov=sa_api_v2 --cov-report=term-missing
# Run tests with HTML coverage report (outputs to htmlcov/)
test-coverage-html: test-env test-clean
podman-compose run --rm test pytest --cov=sa_api_v2 --cov-report=html
# Just clean up containers
test-clean:
podman-compose down --remove-orphans 2>/dev/null || true