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

Commit da907f0

Browse filesBrowse files
muncusm-strzelczyk
andauthored
feat(Makefile): use make to run kokoro tests (GoogleCloudPlatform#10938)
* feat(Makefile): use make to run kokoro tests * use GOOGLE_CLOUD_PROJECT as fallback if GOOGLE_SAMPLES_PROJECT is unset * fix env check, and directory stack, so noxfiles can be cleaned up. * let nox do the package installs in its venv THis avoids package conflicts and incompatible packages. * fix conditional project ID --------- Co-authored-by: Maciej Strzelczyk <strzelczyk@google.com>
1 parent f5d89fc commit da907f0
Copy full SHA for da907f0

File tree

Expand file treeCollapse file tree

2 files changed

+23
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+23
-8
lines changed

‎.kokoro/tests/run_single_test.sh

Copy file name to clipboardExpand all lines: .kokoro/tests/run_single_test.sh
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ else
3838
fi
3939

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

4447
echo "PWD: ${PWD}"
4548

‎Makefile

Copy file name to clipboardExpand all lines: Makefile
+19-7Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,37 @@
99
# dir will use repo root as working directory if not specified.
1010
dir ?= $(shell pwd)
1111
# python version: defaults to 3.11
12-
py ?= "3.11"
12+
py ?= 3.11
1313

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

19-
# Export env vars used to determine cloud project.
20-
export GOOGLE_CLOUD_PROJECT ?= ${GOOGLE_SAMPLES_PROJECT}
21-
export BUILD_SPECIFIC_GCLOUD_PROJECT ?= ${GOOGLE_SAMPLES_PROJECT}
19+
# GOOGLE_SAMPLES_PROJECT takes precedence over GOOGLE_CLOUD_PROJECT
20+
PROJECT_ID = ${GOOGLE_SAMPLES_PROJECT}
21+
ifeq (${PROJECT_ID},)
22+
PROJECT_ID = ${GOOGLE_CLOUD_PROJECT}
23+
endif
24+
# export our project ID as GOOGLE_CLOUD_PROJECT in the action environment
25+
override GOOGLE_CLOUD_PROJECT := ${PROJECT_ID}
26+
export GOOGLE_CLOUD_PROJECT
27+
export BUILD_SPECIFIC_GCLOUD_PROJECT ?= ${PROJECT_ID}
2228

2329
build: check-env
2430
pip install nox
2531
cd ${dir}
26-
pip install -r requirements.txt
2732

2833
test: check-env build noxfile.py
34+
# kokoro uses $RUN_TESTS_SESSION to indicate which session to run.
35+
# for local use, use a suitable default.
36+
ifndef RUN_TESTS_SESSION
2937
cd ${dir}
3038
nox -s py-$(py)
39+
else
40+
cd ${dir}
41+
nox -s ${RUN_TESTS_SESSION}
42+
endif
3143

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

4355
check-env:
44-
ifndef GOOGLE_SAMPLES_PROJECT
45-
$(error GOOGLE_SAMPLES_PROJECT must be set to the name of a GCP project to use.)
56+
ifndef PROJECT_ID
57+
$(error At least one of the following env vars must be set: GOOGLE_SAMPLES_PROJECT, GOOGLE_CLOUD_PROJECT.)
4658
endif
4759
ifndef VIRTUAL_ENV
4860
$(warning Use of a Python Virtual Environment is recommended. See README.md for details.)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.