Skip to content

Commit 591aa7d

Browse files
feat: add release version substitution to run configuration and update cloudbuild environment variables
1 parent 16862db commit 591aa7d

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

cloudbuild.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,24 @@ steps:
2626
- '-c'
2727
- |
2828
set -e
29+
30+
# Determine Release Version
31+
if [[ '$_PR_LABELS' =~ 'autorelease: triggered' ]]; then
32+
if [[ '$_PR_TITLE' =~ release\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
33+
export RELEASE_VERSION="$${BASH_REMATCH[1]}"
34+
else
35+
export RELEASE_VERSION="unknown"
36+
fi
37+
else
38+
export RELEASE_VERSION="unknown"
39+
fi
40+
2941
# Workaround for evalbench bug: settings are only applied if path basename matches extension ID
3042
ln -s /workspace /workspace/cloud-sql-postgresql
3143
cd /evalbench
3244
3345
export EVAL_GCP_PROJECT_ID=$PROJECT_ID
34-
export EVAL_GCP_PROJECT_REGION=us-central1
46+
export EVAL_GCP_PROJECT_REGION=$_CLOUD_SQL_REGION
3547
export GOOGLE_CLOUD_PROJECT=$PROJECT_ID
3648
export CLOUD_SQL_POSTGRES_PROJECT=$PROJECT_ID
3749
export CLOUD_SQL_POSTGRES_INSTANCE=$_CLOUD_SQL_INSTANCE

evals/run_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
extension_id: cloud-sql-postgresql
16+
release_version: ${RELEASE_VERSION}
1617

1718
dataset_config: /workspace/evals/dataset.json
1819
dataset_format: gemini-cli-format

evals/substitute_env.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
import re
33

44
def main():
5-
yaml_path = '/workspace/evals/model_config.yaml'
6-
if os.path.exists(yaml_path):
7-
with open(yaml_path, 'r') as f:
8-
content = f.read()
9-
content = re.sub(r'\${(\w+)}', lambda m: os.environ.get(m.group(1), m.group(0)), content)
10-
with open(yaml_path, 'w') as f:
11-
f.write(content)
12-
print(f"Successfully substituted environment variables in {yaml_path}")
13-
else:
14-
print(f"File not found: {yaml_path}")
5+
yaml_paths = ['/workspace/evals/model_config.yaml', '/workspace/evals/run_config.yaml']
6+
for yaml_path in yaml_paths:
7+
if os.path.exists(yaml_path):
8+
with open(yaml_path, 'r') as f:
9+
content = f.read()
10+
content = re.sub(r'\${(\w+)}', lambda m: os.environ.get(m.group(1), m.group(0)), content)
11+
with open(yaml_path, 'w') as f:
12+
f.write(content)
13+
print(f"Successfully substituted environment variables in {yaml_path}")
14+
else:
15+
print(f"File not found: {yaml_path}")
1516

1617
if __name__ == '__main__':
1718
main()

0 commit comments

Comments
 (0)