<commit_before>ifdef FORCE_REBUILD
	DOCKER_FLAGS = --no-cache --pull
endif

ifndef IMAGE_NAME
$(error IMAGE_NAME is not set; invoke make with something like IMAGE_NAME=google/python:2017-01-02_03_45)
endif

.PHONY: all
all: cloud-test

## Files that must be refreshed every build

.PHONY: cloudbuild.yaml # Force reevaluation of env vars every time
cloudbuild.yaml: cloudbuild.yaml.in
	envsubst < $< > $@


.PHONY: tests/google-cloud-python/Dockerfile # Force reevaluation of env vars every time
tests/google-cloud-python/Dockerfile: tests/google-cloud-python/Dockerfile.in
	envsubst < $< > $@

.PHONY: ext_run.sh # Force refetch every time
ext_run.sh:
	curl https://raw.githubusercontent.com/GoogleCloudPlatform/runtimes-common/master/structure_tests/ext_run.sh > ext_run.sh
	chmod +x ext_run.sh

## Build using Google Container Builder service

.PHONY: cloud-build
cloud-build: cloudbuild.yaml tests/google-cloud-python/Dockerfile
	gcloud alpha container builds create . --config=cloudbuild.yaml

.PHONY: cloud-test
# structure-tests and google-cloud-python-tests are implicit in cloud-build
cloud-test: cloud-build integration-tests

## Build using local Docker daemon

.PHONY: local-build
local-build: local-build-interpreters
	docker build $(DOCKER_FLAGS) -t "$(IMAGE_NAME)" .

.PHONY: local-build-interpreters
local-build-interpreters:
	export DOCKER_FLAGS
	make -C python-interpreter-builder build

.PHONY: local-test
local-test: local-build local-structure-tests local-google-cloud-python-tests integration-tests

.PHONY: local-structure-tests
local-structure-tests: local-build ext_run.sh
	make -C tests structure-tests

# Unit tests for Google Cloud Client Library for Python
.PHONY: local-google-cloud-python-tests
local-google-cloud-python-tests: tests/google-cloud-python/Dockerfile
	make -C tests google-cloud-python

## Always local

.PHONY: integration-tests
integration-tests: google-cloud-python-system-tests benchmarks

# System tests for Google Cloud Client Library for Python.
# They require gcloud auth and network access.
.PHONY: google-cloud-python-system-tests
google-cloud-python-system-tests:
	make -C system_tests

.PHONY: benchmarks
benchmarks:
	make -C tests benchmarks
<commit_msg>Do not cache Docker layers and base images by default<commit_after>ifneq ($(FORCE_REBUILD),0)
	export DOCKER_FLAGS=--no-cache --pull
endif

ifndef IMAGE_NAME
$(error IMAGE_NAME is not set; invoke make with something like IMAGE_NAME=google/python:2017-01-02_03_45)
endif

.PHONY: all
all: cloud-test

## Files that must be refreshed every build

.PHONY: cloudbuild.yaml # Force reevaluation of env vars every time
cloudbuild.yaml: cloudbuild.yaml.in
	envsubst < $< > $@


.PHONY: tests/google-cloud-python/Dockerfile # Force reevaluation of env vars every time
tests/google-cloud-python/Dockerfile: tests/google-cloud-python/Dockerfile.in
	envsubst < $< > $@

.PHONY: ext_run.sh # Force refetch every time
ext_run.sh:
	curl https://raw.githubusercontent.com/GoogleCloudPlatform/runtimes-common/master/structure_tests/ext_run.sh > ext_run.sh
	chmod +x ext_run.sh

## Build using Google Container Builder service

.PHONY: cloud-build
cloud-build: cloudbuild.yaml tests/google-cloud-python/Dockerfile
	gcloud alpha container builds create . --config=cloudbuild.yaml

.PHONY: cloud-test
# structure-tests and google-cloud-python-tests are implicit in cloud-build
cloud-test: cloud-build integration-tests

## Build using local Docker daemon

.PHONY: local-build
local-build: local-build-interpreters
	docker build $(DOCKER_FLAGS) -t "$(IMAGE_NAME)" .

.PHONY: local-build-interpreters
local-build-interpreters:
	make -C python-interpreter-builder build

.PHONY: local-test
local-test: local-build local-structure-tests local-google-cloud-python-tests integration-tests

.PHONY: local-structure-tests
local-structure-tests: local-build ext_run.sh
	make -C tests structure-tests

# Unit tests for Google Cloud Client Library for Python
.PHONY: local-google-cloud-python-tests
local-google-cloud-python-tests: tests/google-cloud-python/Dockerfile
	make -C tests google-cloud-python

## Always local

.PHONY: integration-tests
integration-tests: google-cloud-python-system-tests benchmarks

# System tests for Google Cloud Client Library for Python.
# They require gcloud auth and network access.
.PHONY: google-cloud-python-system-tests
google-cloud-python-system-tests:
	make -C system_tests

.PHONY: benchmarks
benchmarks:
	make -C tests benchmarks

{'fraction_non_alphanumeric': 0.09831649831649832, 'fraction_numerical': 0.005611672278338945, 'mean_word_length': 4.757105943152455, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1125186', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1423, 'n_words': 385}