Skip to content

Commit 2c8ddbe

Browse files
authored
Remove unused/redundant steps in Integration Test CI (#996)
1 parent 158465f commit 2c8ddbe

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

.github/workflows/integration_tests.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -409,22 +409,6 @@ jobs:
409409
name: log-artifact
410410
path: build-results-desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}*
411411
retention-days: ${{ env.artifactRetentionDays }}
412-
- name: Cleanup Local Copies of Uploaded Artifacts
413-
shell: bash
414-
run: |
415-
rm -rf testapps-desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}
416-
- name: Set CLOUDSDK_PYTHON (Windows)
417-
shell: bash
418-
if: startsWith(matrix.os, 'windows') && !cancelled()
419-
run: echo "CLOUDSDK_PYTHON=${{env.pythonLocation}}\python.exe" >> $GITHUB_ENV
420-
- name: Install Cloud SDK
421-
if: ${{ !cancelled() }}
422-
uses: google-github-actions/setup-gcloud@v0
423-
- name: Upload Desktop Artifacts to GCS
424-
shell: bash
425-
if: ${{ !cancelled() }}
426-
run: |
427-
python scripts/gha/gcs_uploader.py --testapp_dir ta --key_file scripts/gha-encrypted/gcs_key_file.json
428412
- name: Download log artifacts
429413
if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }}
430414
uses: actions/download-artifact@v3
@@ -900,7 +884,6 @@ jobs:
900884
shell: bash
901885
command: |
902886
pip install -r scripts/gha/requirements.txt
903-
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}" --artifact "testapps/testapps-desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}"
904887
- name: Setup java
905888
uses: actions/setup-java@v3
906889
with:
@@ -1178,12 +1161,12 @@ jobs:
11781161
timeout-minutes: 60
11791162
if: steps.get-device-type.outputs.device_type == 'real'
11801163
run: |
1181-
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
11821164
python scripts/gha/test_lab.py --testapp_dir testapps \
11831165
--android_device "${{ matrix.android_device }}" \
11841166
--logfile_name "android-${{ matrix.build_os }}-${{ matrix.android_device }}" \
11851167
--code_platform cpp \
1186-
--key_file scripts/gha-encrypted/gcs_key_file.json
1168+
--key_file_encrypted scripts/gha-encrypted/gcs_key_file.json.gpg \
1169+
--key_file_passphrase "${{ secrets.TEST_SECRET }}"
11871170
- name: Prepare results summary artifact
11881171
if: ${{ !cancelled() }}
11891172
shell: bash
@@ -1289,12 +1272,12 @@ jobs:
12891272
timeout-minutes: 60
12901273
if: steps.get-device-type.outputs.device_type == 'real'
12911274
run: |
1292-
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
12931275
python scripts/gha/test_lab.py --testapp_dir testapps \
12941276
--ios_device "${{ matrix.ios_device }}" \
12951277
--logfile_name "ios-${{ matrix.build_os }}-${{ matrix.ios_device }}" \
12961278
--code_platform cpp \
1297-
--key_file scripts/gha-encrypted/gcs_key_file.json
1279+
--key_file_encrypted scripts/gha-encrypted/gcs_key_file.json.gpg \
1280+
--key_file_passphrase "${{ secrets.TEST_SECRET }}"
12981281
- name: Prepare results summary artifact
12991282
if: ${{ !cancelled() }}
13001283
shell: bash

scripts/gha/build_testapps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ def _collect_integration_tests(testapps, root_output_dir, output_dir, artifact_n
437437
desktop_testapp_name += ".exe"
438438

439439
testapp_paths = []
440+
testapp_google_services = {}
440441
for file_dir, directories, file_names in os.walk(output_dir):
441442
for directory in directories:
442443
if directory.endswith(ios_simualtor_testapp_extension):
@@ -446,6 +447,8 @@ def _collect_integration_tests(testapps, root_output_dir, output_dir, artifact_n
446447
or file_name.endswith(android_testapp_extension)
447448
or file_name.endswith(ios_testapp_extension)):
448449
testapp_paths.append(os.path.join(file_dir, file_name))
450+
if (file_name == "google-services.json"):
451+
testapp_google_services[file_dir.split(os.path.sep)[-2]] = os.path.join(file_dir, file_name)
449452

450453
artifact_path = os.path.join(root_output_dir, testapps_artifact_dir)
451454
_rm_dir_safe(artifact_path)
@@ -456,6 +459,8 @@ def _collect_integration_tests(testapps, root_output_dir, output_dir, artifact_n
456459
if testapp in path:
457460
if os.path.isfile(path):
458461
shutil.copy(path, os.path.join(artifact_path, testapp))
462+
if path.endswith(desktop_testapp_name) and testapp_google_services.get(testapp):
463+
shutil.copy(testapp_google_services[testapp], os.path.join(artifact_path, testapp))
459464
else:
460465
dir_util.copy_tree(path, os.path.join(artifact_path, testapp, os.path.basename(path)))
461466
break

scripts/gha/test_lab.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
from integration_testing import gcs
7979
from integration_testing import test_validation
8080
from print_matrix_configuration import TEST_DEVICES
81+
import restore_secrets
8182

8283
_ANDROID = "android"
8384
_IOS = "ios"
@@ -93,6 +94,11 @@
9394
" Used to choose the validation logic to process the log output.")
9495
flags.DEFINE_string(
9596
"key_file", None, "Path to key file authorizing use of the GCS bucket.")
97+
flags.DEFINE_string(
98+
"key_file_encrypted", None, "Path to encrypted key file authorizing use "
99+
"of the GCS bucket.")
100+
flags.DEFINE_string(
101+
"key_file_passphrase", None, "Use with FLAG key_file_encrypted.")
96102
flags.DEFINE_string(
97103
"android_device", None,
98104
"Model_id and API_level for desired device. See module docstring for details "
@@ -127,7 +133,15 @@ def main(argv):
127133
raise app.UsageError("Too many command-line arguments.")
128134

129135
testapp_dir = _fix_path(FLAGS.testapp_dir)
130-
key_file_path = _fix_path(FLAGS.key_file)
136+
if FLAGS.key_file:
137+
key_file_path = _fix_path(FLAGS.key_file)
138+
elif FLAGS.key_file_encrypted and FLAGS.key_file_passphrase:
139+
key_file_encrypted_path = _fix_path(FLAGS.key_file_encrypted)
140+
decrypted_text = restore_secrets._decrypt(key_file_encrypted_path, FLAGS.key_file_passphrase)
141+
key_file_path = key_file_encrypted_path.replace(".gpg", "")
142+
with open(key_file_path, "w") as f:
143+
f.write(decrypted_text)
144+
131145
code_platform = FLAGS.code_platform
132146

133147
if not os.path.exists(key_file_path):
@@ -383,5 +397,4 @@ def get_gcloud_flags(self):
383397
if __name__ == "__main__":
384398
flags.mark_flag_as_required("testapp_dir")
385399
flags.mark_flag_as_required("code_platform")
386-
flags.mark_flag_as_required("key_file")
387400
app.run(main)

0 commit comments

Comments
 (0)