diff --git a/.circleci/python_job.bash b/.circleci/python_job.bash index d804f2b27f..34d84e6aaf 100644 --- a/.circleci/python_job.bash +++ b/.circleci/python_job.bash @@ -84,17 +84,22 @@ function run_build_glean { set -x glean_parser translate --format python_server --output ${OUTPUT_FOLDER} ${INPUT_YAML} black ${OUTPUT_FOLDER} + { set +x; } 2>/dev/null case "$OSTYPE" in darwin* | bsd*) echo "Using BSD sed"; + set -x; sed -i '' \ -e 's/^AUTOGENERATED BY glean_parser \(.* DO NOT EDIT.\) DO NOT COMMIT.$/AUTOGENERATED BY glean_parser \1 To recreate, run:\n\nbash .circleci\/python_job.bash run build_glean/' \ - ${OUTPUT_FOLDER}/server_events.py;; + ${OUTPUT_FOLDER}/server_events.py; + { set +x; } 2>/dev/null;; linux*) echo "Using GNU sed"; + set -x; sed -i \ -e 's/^AUTOGENERATED BY glean_parser \(.* DO NOT EDIT.\) DO NOT COMMIT.$/AUTOGENERATED BY glean_parser \1 To recreate, run:\n\nbash .circleci\/python_job.bash run build_glean/' \ - ${OUTPUT_FOLDER}/server_events.py;; + ${OUTPUT_FOLDER}/server_events.py; + { set +x; } 2>/dev/null;; *) echo "Unknown OSTYPE '${OSTYPE}'";; esac @@ -107,19 +112,27 @@ function run_check_glean { echo "Re-running glean_parser..." echo run_build_glean $GLEAN_TEST_FOLDER - set +x + { set +x; } 2>/dev/null echo echo "Checking new files against checked-in files..." local HAS_DIFFS=0 local HAS_FILES=0 local EXIT_CODE=0 - for FILENAME in `find ${GLEAN_TEST_FOLDER} -type f -exec basename \{\} \;` + for FILENAME in `find ${GLEAN_TEST_FOLDER} -type f -name '*.py' -exec basename \{\} \;` do HAS_FILES=1 - if [[ 0 -ne `cmp --silent "${GLEAN_TEST_FOLDER}/${FILENAME}" "${GLEAN_OUTPUT_FOLDER}/${FILENAME}"` ]] + RETVAL=0 + /usr/bin/cmp --silent "${GLEAN_TEST_FOLDER}/${FILENAME}" "${GLEAN_OUTPUT_FOLDER}/${FILENAME}" || RETVAL=$? + if [ $RETVAL -eq 1 ] then HAS_DIFFS=1 + elif [ $RETVAL -gt 1 ] + then + echo "cmp returned $RETVAL!" + set -x + /usr/bin/cmp --silent "${GLEAN_TEST_FOLDER}/${FILENAME}" "${GLEAN_OUTPUT_FOLDER}/${FILENAME}" + exit 1 fi done if [ $HAS_FILES -eq 0 ] @@ -130,7 +143,8 @@ function run_check_glean { if [ $HAS_DIFFS -eq 1 ] then echo "*** Differences detected - need to re-run glean_parser ***" - diff $GLEAN_OUTPUT_FOLDER $GLEAN_TEST_FOLDER + diff --exclude '__pycache__' $GLEAN_OUTPUT_FOLDER $GLEAN_TEST_FOLDER || true + echo "*** End of differences***" EXIT_CODE=1 fi if [ "$GLEAN_TEST_FOLDER" != "" ] @@ -141,6 +155,15 @@ function run_check_glean { if [ $EXIT_CODE -eq 0 ] then echo "✓ Files are identical" + elif [ $HAS_DIFFS -eq 1 ] + then + echo + echo "To fix, run:" + echo + echo " bash .circleci/python_job.bash run build_glean" + echo + echo "and add as a commit to this pull request." + exit 1 else exit 1 fi diff --git a/privaterelay/glean/server_events.py b/privaterelay/glean/server_events.py index ad575caf47..cf36cc8a4f 100644 --- a/privaterelay/glean/server_events.py +++ b/privaterelay/glean/server_events.py @@ -3,7 +3,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -AUTOGENERATED BY glean_parser v12.0.1. DO NOT EDIT. To recreate, run: +AUTOGENERATED BY glean_parser v13.0.0. DO NOT EDIT. To recreate, run: bash .circleci/python_job.bash run build_glean """ @@ -48,7 +48,7 @@ def _record(self, user_agent: str, ip_address: str, event: dict[str, Any]) -> No # `Unknown` fields below are required in the Glean schema, however they are # not useful in server context "client_info": { - "telemetry_sdk_build": "glean_parser v12.0.1", + "telemetry_sdk_build": "glean_parser v13.0.0", "first_run_date": "Unknown", "os": "Unknown", "os_version": "Unknown", diff --git a/requirements.txt b/requirements.txt index 9e4cdad35f..d4cc90731b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ django-waffle==4.1.0 dockerflow==2024.3.0 drf-spectacular==0.27.1 drf-spectacular-sidecar==2024.3.1 -glean_parser==12.0.1 +glean_parser==13.0.0 google-measurement-protocol==1.1.0 google-cloud-profiler==4.1.0 gunicorn==21.2.0