Skip to content

Commit 0407af0

Browse files
authored
Merge branch 'dev' into feature/python-tool-build-apps-with-firebase
2 parents 47828b6 + cd61ff2 commit 0407af0

File tree

3 files changed

+113
-64
lines changed

3 files changed

+113
-64
lines changed

.github/workflows/cpp-packaging.yml

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
description: 'public version # to test against'
1616
downloadPreviousRun:
1717
description: 'previous run # to test against'
18+
runIntegrationTests:
19+
description: 'run integration tests?'
20+
default: 0
1821

1922
env:
2023
# Packaging prerequisites
@@ -601,45 +604,75 @@ jobs:
601604
firebase-cpp-sdk-android-c++-package
602605
failOnError: false
603606

604-
run_integration_tests:
605-
name: run-integration-tests
607+
tests:
606608
needs: [merge_packages, download_sdk_package]
607-
if: always()
608-
runs-on: ubuntu-latest
609+
if: github.event.inputs.runIntegrationTests != 0 && !cancelled()
610+
runs-on: ${{ matrix.os }}
611+
strategy:
612+
matrix:
613+
os: [ubuntu-latest, macos-latest, windows-latest]
614+
target_platform: [Desktop, Android, iOS]
615+
exclude:
616+
- os: ubuntu-latest
617+
target_platform: iOS
618+
- os: windows-latest
619+
target_platform: iOS
620+
fail-fast: false
621+
env:
622+
apis: admob,analytics,auth,database,dynamic_links,firestore,functions,instance_id,messaging,remote_config,storage
623+
android_device: flame
624+
android_api: 29
625+
ios_device: iphone11pro
626+
ios_version: 13.3
609627
steps:
610-
- name: setup Xcode version (macos)
611-
if: runner.os == 'macOS'
612-
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
613-
614-
- name: download SDK zip
615-
uses: actions/download-artifact@v2
616-
with:
617-
name: firebase_cpp_sdk.zip
618-
path: .
619-
620-
- name: download hash
621-
uses: actions/download-artifact@v2
622-
with:
623-
name: firebase_cpp_sdk_hash.txt
624-
path: .
625-
626-
- name: List binary SDK files.
627-
run: |
628-
# Verify zipfile hash first.
629-
${{ env.hashCommand }} -c --quiet firebase_cpp_sdk_hash.txt
628+
- name: Checkout repo
629+
uses: actions/[email protected]
630+
with:
631+
ref: ${{ github.event.inputs.commitIdToPackage }}
632+
- name: Setup Xcode version (macos)
633+
if: runner.os == 'macOS'
634+
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
635+
- name: Download Firebase C++ SDK
636+
uses: actions/download-artifact@v2
637+
with:
638+
name: firebase_cpp_sdk.zip
639+
- name: Unzip Firebase C++ SDK
640+
shell: bash
641+
run: |
642+
ls
643+
if [ "$RUNNER_OS" == "Windows" ]; then
644+
7z x firebase_cpp_sdk.zip
645+
else
630646
unzip -q firebase_cpp_sdk.zip
631-
find . -print
632-
633-
- name: Verify SDK package files.
634-
run: |
635-
if [[ -r firebase_cpp_sdk/file_hashes.txt ]]; then
636-
${{ env.hashCommand }} -c --quiet firebase_cpp_sdk/file_hashes.txt
637-
else
638-
echo "::warning ::SDK package does not contain file_hashes.txt, cannot verify files in package."
639-
fi
640-
641-
- name: fetch integration test source
642-
uses: actions/[email protected]
643-
with:
644-
path: src
645-
ref: ${{ github.event.inputs.commitIdToPackage }}
647+
fi
648+
- name: Setup python
649+
uses: actions/setup-python@v2
650+
with:
651+
python-version: '3.7'
652+
- name: Add msbuild to PATH (windows)
653+
if: runner.os == 'Windows'
654+
uses: microsoft/[email protected]
655+
- name: Prepare for integration tests
656+
run: |
657+
pip install -r scripts/gha/requirements.txt
658+
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
659+
- name: Build integration tests (and run Desktop tests)
660+
run: |
661+
python scripts/gha/build_testapps.py --t ${{ env.apis }} --p ${{ matrix.target_platform }} --sdk_dir firebase_cpp_sdk --output_directory ${{ github.workspace }} --execute_desktop_testapp --noadd_timestamp
662+
663+
# Workaround for https://github.com/GoogleCloudPlatform/github-actions/issues/100
664+
# Must be run after the Python setup action
665+
- name: Set CLOUDSDK_PYTHON (Windows)
666+
if: runner.os == 'Windows' && !cancelled()
667+
run: echo "CLOUDSDK_PYTHON=${{env.pythonLocation}}\python.exe" >> $GITHUB_ENV
668+
- name: Install Cloud SDK
669+
if: ${{ !cancelled() }}
670+
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
671+
- name: Upload Desktop Artifacts to GCS
672+
if: ${{ !cancelled() }}
673+
run: |
674+
python scripts/gha/gcs_uploader.py --testapp_dir testapps --key_file scripts/gha-encrypted/gcs_key_file.json
675+
- name: Run mobile integration tests
676+
if: matrix.target_platform != 'Desktop' && !cancelled()
677+
run: |
678+
python scripts/gha/test_lab.py --android_model ${{ env.android_device }} --android_api ${{ env.android_api }} --ios_model ${{ env.ios_device }} --ios_version ${{ env.ios_version }} --testapp_dir testapps --code_platform cpp --key_file scripts/gha-encrypted/gcs_key_file.json

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
inputs:
66
platforms:
77
description: 'CSV of Desktop, Android and/or iOS'
8-
default: 'Desktop'
8+
default: 'Desktop,Android,iOS'
99
required: true
1010
apis:
1111
description: 'CSV of apis to build and test'
@@ -117,9 +117,6 @@ jobs:
117117
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
118118
119119
- name: Build integration tests (and run Desktop tests)
120-
# The set up script for Android will download the NDK here.
121-
env:
122-
NDK_ROOT: '/tmp/android-ndk-r16b'
123120
run: |
124121
python scripts/gha/build_testapps.py --t ${{ github.event.inputs.apis }} --p ${{ matrix.target_platform }} --output_directory ${{ github.workspace }} --use_vcpkg --execute_desktop_testapp --noadd_timestamp
125122

scripts/gha/build_testapps.py

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def main(argv):
195195

196196
if update_pod_repo and _IOS in platforms:
197197
_run(["pod", "repo", "update"])
198-
198+
199199
config = config_reader.read_config()
200200
cmake_flags = _get_desktop_compiler_flags(FLAGS.compiler, config.compilers)
201201
if _DESKTOP in platforms and FLAGS.use_vcpkg:
@@ -226,7 +226,7 @@ def main(argv):
226226

227227

228228
def _build(
229-
testapp, platforms, api_config, output_dir, sdk_dir, ios_framework_exist,
229+
testapp, platforms, api_config, output_dir, sdk_dir, ios_framework_exist,
230230
timestamp, root_dir, ios_sdk, cmake_flags, execute_desktop_testapp):
231231
"""Builds one testapp on each of the specified platforms."""
232232
testapp_dir = os.path.join(root_dir, api_config.testapp_path)
@@ -362,31 +362,46 @@ def _validate_android_environment_variables():
362362
"""Checks environment variables that may be required for Android."""
363363
# Ultimately we let the gradle build be the source of truth on what env vars
364364
# are required, but try to repair holes and log warnings if we can't.
365-
logging.info("Checking environment variables for the Android build")
366-
if not os.environ.get(_ANDROID_NDK_HOME):
367-
ndk_root = os.environ.get(_NDK_ROOT)
368-
if ndk_root: # Use NDK_ROOT as a backup for ANDROID_NDK_HOME
369-
os.environ[_ANDROID_NDK_HOME] = ndk_root
370-
logging.info("%s not found, using %s", _ANDROID_NDK_HOME, _NDK_ROOT)
371-
else:
372-
logging.warning("Neither %s nor %s is set.", _ANDROID_NDK_HOME, _NDK_ROOT)
365+
android_home = os.environ.get(_ANDROID_HOME)
373366
if not os.environ.get(_JAVA_HOME):
374367
logging.warning("%s not set", _JAVA_HOME)
375368
if not os.environ.get(_ANDROID_SDK_HOME):
376-
android_home = os.environ.get(_ANDROID_HOME)
377369
if android_home: # Use ANDROID_HOME as backup for ANDROID_SDK_HOME
378370
os.environ[_ANDROID_SDK_HOME] = android_home
379371
logging.info("%s not found, using %s", _ANDROID_SDK_HOME, _ANDROID_HOME)
380372
else:
381-
logging.warning(
382-
"Neither %s nor %s is set", _ANDROID_SDK_HOME, _ANDROID_HOME)
373+
logging.warning("Missing: %s and %s", _ANDROID_SDK_HOME, _ANDROID_HOME)
374+
# Different environments may have different NDK env vars specified. We look
375+
# for these, in this order, and set the others to the first found.
376+
# If none are set, we check the default location for the ndk.
377+
ndk_path = None
378+
ndk_vars = [_NDK_ROOT, _ANDROID_NDK_HOME]
379+
for env_var in ndk_vars:
380+
val = os.environ.get(env_var)
381+
if val:
382+
ndk_path = val
383+
break
384+
if not ndk_path:
385+
if android_home:
386+
default_ndk_path = os.path.join(android_home, "ndk-bundle")
387+
if os.path.isdir(default_ndk_path):
388+
ndk_path = default_ndk_path
389+
if ndk_path:
390+
logging.info("Found ndk: %s", ndk_path)
391+
for env_var in ndk_vars:
392+
if os.environ.get(env_var) != ndk_path:
393+
logging.info("Setting %s to %s", env_var, ndk_path)
394+
os.environ[env_var] = ndk_path
395+
else:
396+
logging.warning("No NDK env var set. Set one of %s", ", ".join(ndk_vars))
383397

384398

385-
# If sdk_dir contains no framework, consider it is Github repo, then
399+
# If sdk_dir contains no framework, consider it is Github repo, then
386400
# generate makefiles for ios frameworks
387401
def _generate_makefiles_from_repo(sdk_dir):
402+
"""Generates cmake makefiles for building iOS frameworks from SDK source."""
388403
ios_framework_builder = os.path.join(
389-
sdk_dir, "build_scripts", "ios", "build.sh")
404+
sdk_dir, "build_scripts", "ios", "build.sh")
390405

391406
framework_builder_args = [
392407
ios_framework_builder,
@@ -399,16 +414,19 @@ def _generate_makefiles_from_repo(sdk_dir):
399414

400415
# build required ios frameworks based on makefiles
401416
def _build_ios_framework_from_repo(sdk_dir, api_config):
417+
"""Builds iOS framework from SDK source."""
402418
ios_framework_builder = os.path.join(
403-
sdk_dir, "build_scripts", "ios", "build.sh")
404-
419+
sdk_dir, "build_scripts", "ios", "build.sh")
420+
405421
# build only required targets to save time
406422
target = set()
423+
407424
for framework in api_config.frameworks:
425+
# firebase_analytics.framework -> firebase_analytics
408426
target.add(os.path.splitext(framework)[0])
409427
# firebase is not a target in CMake, firebase_app is the target
410-
# firebase_app will be built by other target as well
411-
target.remove("firebase")
428+
# firebase_app will be built by other target as well
429+
target.remove("firebase")
412430

413431
framework_builder_args = [
414432
ios_framework_builder,
@@ -421,10 +439,10 @@ def _build_ios_framework_from_repo(sdk_dir, api_config):
421439

422440
def _build_ios(
423441
sdk_dir, ios_framework_exist, project_dir, root_dir, api_config, ios_sdk):
442+
"""Builds an iOS application (.app, .ipa or both)."""
424443
if not ios_framework_exist:
425444
_build_ios_framework_from_repo(sdk_dir, api_config)
426445

427-
"""Builds an iOS application (.app, .ipa or both)."""
428446
build_dir = os.path.join(project_dir, "ios_build")
429447
os.makedirs(build_dir)
430448

@@ -487,7 +505,8 @@ def _build_ios(
487505
ios_sdk=_IOS_SDK_DEVICE,
488506
configuration="Debug"))
489507

490-
xcodebuild.generate_unsigned_ipa(output_dir=build_dir, configuration="Debug")
508+
xcodebuild.generate_unsigned_ipa(
509+
output_dir=build_dir, configuration="Debug")
491510

492511

493512
# This script is responsible for copying shared files into the integration

0 commit comments

Comments
 (0)