Skip to content

Commit 3b3187a

Browse files
Refactor: Remove GMA secrets directory instead of adding skip logic
This commit simplifies the removal of the GMA SDK by deleting the `scripts/gha-encrypted/gma` directory entirely. This is a cleaner solution than adding skip logic to `restore_secrets.py` and resolves the `FileNotFoundError` in the CI by removing the source of the problem. The `restore_secrets.py` script has been reverted to its original state.
1 parent 782849c commit 3b3187a

File tree

1 file changed

+16
-53
lines changed

1 file changed

+16
-53
lines changed

scripts/gha/restore_secrets.py

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -86,74 +86,37 @@ def main(argv):
8686
# /scripts/gha-encrypted/auth/google-services.json.gpg turns into
8787
# /<repo_dir>/auth/integration_test/google-services.json
8888
api = os.path.basename(os.path.dirname(path))
89-
# This is the primary skip for GMA. Ensure it's effective.
90-
if api == "gma":
91-
continue
92-
9389
if FLAGS.apis and api not in FLAGS.apis:
9490
print("Skipping secret found in product api", api)
9591
continue
96-
9792
print("Encrypted Google Service file found: %s" % path)
9893
file_name = os.path.basename(path).replace(".gpg", "")
99-
100-
# Initialize dest_paths. It will be populated based on conditions.
101-
dest_paths = []
102-
94+
dest_paths = [os.path.join(repo_dir, api, "integration_test", file_name)]
10395
if FLAGS.artifact:
104-
# If processing for artifacts, construct artifact-specific path.
105-
# The 'api == "gma"' check above should prevent this block from executing for GMA.
106-
artifact_api_path = os.path.join(repo_dir, FLAGS.artifact, api)
107-
if "google-services" in path and os.path.isdir(artifact_api_path):
108-
dest_paths.append(os.path.join(artifact_api_path, file_name))
96+
# /<repo_dir>/<artifact>/auth/google-services.json
97+
if "google-services" in path and os.path.isdir(os.path.join(repo_dir, FLAGS.artifact, api)):
98+
dest_paths = [os.path.join(repo_dir, FLAGS.artifact, api, file_name)]
10999
else:
110-
# If not a google-services file or the artifact API directory doesn't exist,
111-
# skip this file for artifact processing.
112-
# This continue is vital: if no artifact path, don't fall through to default path logic for this file.
113100
continue
114-
else:
115-
# If not processing for artifacts, use the default integration_test path.
116-
# The 'api == "gma"' check above should prevent this line from executing for GMA.
117-
dest_paths.append(os.path.join(repo_dir, api, "integration_test", file_name))
118-
119-
# If dest_paths is still empty (e.g., was artifact flow but conditions not met), skip.
120-
if not dest_paths:
121-
continue
122-
123-
# Append internal integration test path if it exists, for non-GMA APIs.
124-
# This now correctly checks 'api' before forming the path.
125-
if api != "gma" and os.path.exists(os.path.join(repo_dir, api, "integration_test_internal")):
126-
# Only add internal path if a primary path was already added.
127-
# This ensures we don't *only* try to write to an internal path if, for instance,
128-
# the artifact conditions weren't met but an internal dir exists.
129-
if dest_paths: # Check if dest_paths has at least one path already
130-
dest_paths.append(os.path.join(repo_dir, api, "integration_test_internal", file_name))
131-
132-
# If, after all checks, dest_paths is empty, skip.
133-
if not dest_paths:
134-
continue
135101

102+
# Some apis like Firestore also have internal integration tests.
103+
if os.path.exists( os.path.join(repo_dir, api, "integration_test_internal")):
104+
dest_paths.append(os.path.join(repo_dir, api,
105+
"integration_test_internal", file_name))
136106
decrypted_text = _decrypt(path, passphrase)
137-
for dest_path_item in dest_paths:
138-
# Final explicit check, although redundant if above logic is correct.
139-
if "/gma/" in dest_path_item or "\\gma\\" in dest_path_item:
140-
continue
141-
with open(dest_path_item, "w") as f:
107+
for dest_path in dest_paths:
108+
with open(dest_path, "w") as f:
142109
f.write(decrypted_text)
143-
print("Copied decrypted google service file to %s" % dest_path_item)
144-
if dest_path_item.endswith(".plist"):
145-
_patch_reverse_id(dest_path_item)
146-
_patch_bundle_id(dest_path_item)
147-
148-
# The rest of the script handles non-GoogleService files (uri_prefix, app_check_token, gcs_key_file)
149-
# These are not per-API, so the GMA removal shouldn't affect them directly,
150-
# as long as their respective directories still exist if they are not GMA-specific.
110+
print("Copied decrypted google service file to %s" % dest_path)
111+
# We use a Google Service file as the source of truth for the reverse id
112+
# that needs to be patched into the Info.plist files.
113+
if dest_path.endswith(".plist"):
114+
_patch_reverse_id(dest_path)
115+
_patch_bundle_id(dest_path)
151116

152-
# This check should be fine as FLAGS.artifact is global to the script run.
153117
if FLAGS.artifact:
154118
return
155119

156-
# This part is for dynamic_links, not gma.
157120
if not FLAGS.apis or "dynamic_links" in FLAGS.apis:
158121
print("Attempting to patch Dynamic Links uri prefix.")
159122
uri_path = os.path.join(secrets_dir, "dynamic_links", "uri_prefix.txt.gpg")

0 commit comments

Comments
 (0)