Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(Makefile): use make to run kokoro tests #10938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 29, 2024
5 changes: 4 additions & 1 deletion 5 .kokoro/tests/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ else
fi

# Use nox to execute the tests for the project.
nox -s "$RUN_TESTS_SESSION"
test_subdir=$(realpath --relative-to ${PROJECT_ROOT} ${PWD})
pushd $PROJECT_ROOT
RUN_TESTS_SESSION=${RUN_TESTS_SESSION} make test dir=${test_subdir}
EXIT=$?
popd

echo "PWD: ${PWD}"

Expand Down
26 changes: 19 additions & 7 deletions 26 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,37 @@
# dir will use repo root as working directory if not specified.
dir ?= $(shell pwd)
# python version: defaults to 3.11
py ?= "3.11"
py ?= 3.11

INTERFACE_ACTIONS="build test lint"
repo_root = $(shell pwd)
.ONESHELL: #ease subdirectory work by using the same subshell for all commands
.-PHONY: *

# Export env vars used to determine cloud project.
export GOOGLE_CLOUD_PROJECT ?= ${GOOGLE_SAMPLES_PROJECT}
export BUILD_SPECIFIC_GCLOUD_PROJECT ?= ${GOOGLE_SAMPLES_PROJECT}
# GOOGLE_SAMPLES_PROJECT takes precedence over GOOGLE_CLOUD_PROJECT
PROJECT_ID = ${GOOGLE_SAMPLES_PROJECT}
ifeq (${PROJECT_ID},)
PROJECT_ID = ${GOOGLE_CLOUD_PROJECT}
endif
# export our project ID as GOOGLE_CLOUD_PROJECT in the action environment
override GOOGLE_CLOUD_PROJECT := ${PROJECT_ID}
export GOOGLE_CLOUD_PROJECT
export BUILD_SPECIFIC_GCLOUD_PROJECT ?= ${PROJECT_ID}

build: check-env
pip install nox
cd ${dir}
pip install -r requirements.txt

test: check-env build noxfile.py
# kokoro uses $RUN_TESTS_SESSION to indicate which session to run.
# for local use, use a suitable default.
ifndef RUN_TESTS_SESSION
cd ${dir}
nox -s py-$(py)
else
cd ${dir}
nox -s ${RUN_TESTS_SESSION}
endif

lint: check-env noxfile.py
pip install nox black
Expand All @@ -41,8 +53,8 @@ noxfile.py:
cp -n ${repo_root}/noxfile-template.py noxfile.py

check-env:
ifndef GOOGLE_SAMPLES_PROJECT
$(error GOOGLE_SAMPLES_PROJECT must be set to the name of a GCP project to use.)
ifndef PROJECT_ID
$(error At least one of the following env vars must be set: GOOGLE_SAMPLES_PROJECT, GOOGLE_CLOUD_PROJECT.)
endif
ifndef VIRTUAL_ENV
$(warning Use of a Python Virtual Environment is recommended. See README.md for details.)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.