From 234cc043f0588a97b6de314f238d1ccb3fba3636 Mon Sep 17 00:00:00 2001
From: Yaroslav Stefinko <ext-yaroslav.stefinko@here.com>
Date: Mon, 18 Mar 2024 00:18:28 +0200
Subject: [PATCH] Fix FV/MV jobs

Fix minor CI jobs:
 - switch to latest ubuntu and macos
 - remove hardcoded git plugin version

Resolves: MINOR-FIX

Signed-off-by: Yaroslav Stefinko <ext-yaroslav.stefinko@here.com>
---
 .github/workflows/fv_pipelines.yml            | 41 -----------------
 .github/workflows/mv_pipelines.yml            | 44 +++++++++++++++++++
 scripts/android/build-test-emulator.sh        | 14 ++++--
 .../ios/fv/gh-actions-build-with-tests-fv.sh  | 16 +++----
 .../fv/gh-actions-functional-network-test.sh  |  2 +-
 5 files changed, 63 insertions(+), 54 deletions(-)
 delete mode 100644 .github/workflows/fv_pipelines.yml
 create mode 100644 .github/workflows/mv_pipelines.yml

diff --git a/.github/workflows/fv_pipelines.yml b/.github/workflows/fv_pipelines.yml
deleted file mode 100644
index 65c49e6f0..000000000
--- a/.github/workflows/fv_pipelines.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-name: FV_Pipelines
-
-on:
-    schedule:
-    # temporary run job only once a month.
-    - cron: '* 5 1 * *'
-
-env:
-  LD_PRELOAD: /lib/x86_64-linux-gnu/libSegFault.so
-  SEGFAULT_SIGNALS: all
-
-jobs:
-  fv-build-ios-network-test:
-    name: FV / iOS clang / Network tests
-    runs-on: macos-10.15
-    env:
-      BUILD_TYPE: RelWithDebInfo
-    steps:
-      - name: Check out repository
-        uses: actions/checkout@v2
-      - name: Build with tests
-        run: ./scripts/ios/fv/gh-actions-build-with-tests-fv.sh
-        shell: bash
-      - name: Test FV Network
-        run: ./scripts/ios/fv/gh-actions-functional-network-test.sh
-        shell: bash
-
-  fv-android-amulator-build-test:
-    name: MV.Android.Emulator.Build.Test.API21.ABIx86_64.NDK-Latest.
-    runs-on: ubuntu-20.04
-    env:
-      ANDROID_NDK_HOME: $(ANDROID_HOME)/ndk-bundle
-    steps:
-    - name: Check out repository
-      uses: actions/checkout@v2
-    - name: Verification of cmake script
-      run: ls -la $(ANDROID_NDK_HOME)/build/cmake/android.toolchain.cmake
-      shell: bash
-    - name: Android Emulator Test
-      run: ANDROID_NDK_HOME=$(ANDROID_NDK_HOME) && scripts/android/build-test-emulator.sh
-      shell: bash
\ No newline at end of file
diff --git a/.github/workflows/mv_pipelines.yml b/.github/workflows/mv_pipelines.yml
new file mode 100644
index 000000000..0d015d49d
--- /dev/null
+++ b/.github/workflows/mv_pipelines.yml
@@ -0,0 +1,44 @@
+name: MV_Pipelines
+
+on:
+  push:
+    branches:
+      - '*'
+#  workflow_dispatch
+#      branches:
+#        - '*'
+#    schedule:
+    # MV(as well as FV) Android and iOS only once a month.
+#      - cron: '* 5 1 * *'
+
+jobs:
+  mv-build-ios-network-test:
+    name: MV / iOS clang / Network tests
+    runs-on: macos-latest
+    env:
+      BUILD_TYPE: RelWithDebInfo
+    steps:
+      - name: Check out repository
+        uses: actions/checkout@v4
+      - name: Build with tests
+        run: ./scripts/ios/fv/gh-actions-build-with-tests-fv.sh
+        shell: bash
+      - name: Test MV Network
+        run: ./scripts/ios/fv/gh-actions-functional-network-test.sh
+        shell: bash
+
+  mv-android-emulator-build-test:
+    name: MV.Android.Emulator.Build.Test.API21.ABIx86_64.NDK-Latest.
+    runs-on: ubuntu-latest
+    env:
+      #ANDROID_NDK_HOME: $(ANDROID_HOME)/ndk-bundle
+      SEGFAULT_SIGNALS: all
+      BUILD_TYPE: RelWithDebInfo
+    steps:
+    - name: Check out repository
+      uses: actions/checkout@v4
+    - name: Verification of cmake script
+      run: ls -la ${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake  &&  ls -la ${ANDROID_NDK_HOME}/prebuilt &&  ls -la ${ANDROID_NDK_HOME}/ndk-build
+    - name: Android Emulator Test
+      run: scripts/android/build-test-emulator.sh
+      shell: bash
\ No newline at end of file
diff --git a/scripts/android/build-test-emulator.sh b/scripts/android/build-test-emulator.sh
index 5ea1fef35..149655771 100755
--- a/scripts/android/build-test-emulator.sh
+++ b/scripts/android/build-test-emulator.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -ex
 #
-# Copyright (C) 2020-2021 HERE Europe B.V.
+# Copyright (C) 2020-2024 HERE Europe B.V.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -24,17 +24,25 @@
 export ANDROID_ABI="x86_64"
 export ANDROID_API=21
 
-export NDK_ROOT=$ANDROID_HOME/ndk-bundle                            # This var is not exist on Azure MacOS image, step can be skipped on GitLab
+export NDK_ROOT=$ANDROID_NDK_ROOT/ndk-bundle             # This var is not exist on Azure MacOS image, step can be skipped on GitLab
 echo "NDK_ROOT is ${NDK_ROOT} , ANDROID_HOME is ${ANDROID_HOME} "   # as we already set this var inside docker image.
 ls -la $ANDROID_HOME
 export PATH=$PATH:$ANDROID_HOME/tools/bin/:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools
 
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;22.1.7171670" --sdk_root=${ANDROID_HOME} >/dev/null
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-21"
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-21;default;x86_64"
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "sources;android-21"
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk-bundle;22.1.7171670"
+${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --list
+
 mkdir -p build && cd build
 
 echo ""
 echo ""
 echo "*************** $VARIANT Build SDK for C++ ********** Start ***************"
-CMAKE_COMMAND="cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
+CMAKE_COMMAND="cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TYPE=${BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
 -DANDROID_PLATFORM=android-$ANDROID_API -DANDROID_STL=c++_static -DANDROID_ABI=$ANDROID_ABI"
 BUILD_COMMAND="cmake --build . -- -j4"
 
diff --git a/scripts/ios/fv/gh-actions-build-with-tests-fv.sh b/scripts/ios/fv/gh-actions-build-with-tests-fv.sh
index 12121a053..30f88eb1e 100755
--- a/scripts/ios/fv/gh-actions-build-with-tests-fv.sh
+++ b/scripts/ios/fv/gh-actions-build-with-tests-fv.sh
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 #
-# Copyright (C) 2021 HERE Europe B.V.
+# Copyright (C) 2021-2024 HERE Europe B.V.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,19 +17,17 @@
 # SPDX-License-Identifier: Apache-2.0
 # License-Filename: LICENSE
 
-mkdir -p build && cd build
+# Getting rid of boost installed to the CI image (not clear when it appeared)
+# asciidoc and source-highlight are using it so dependencies are ignored.
+# Sometimes there is no boost and there is no need to fail in this case.
+brew uninstall --ignore-dependencies boost || true
 
-xcode-select -p
-if [[ ${GITHUB_RUN_ID} != "" ]]; then
-    # Run on GH Actions CI
-    # Using Xcode_11 pre-installed on node. Otherwise, compilation may fail.
-    sudo xcode-select -s /Applications/Xcode_11.2.1.app
-fi
-xcode-select -p
+mkdir -p build && cd build
 
 cmake ../ -GXcode \
     -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/iOS.cmake \
     -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
+    -DBUILD_TYPE=${BUILD_TYPE} \
     -DPLATFORM=iphoneos \
     -DOLP_SDK_ENABLE_TESTING=ON \
     -DSIMULATOR=YES \
diff --git a/scripts/ios/fv/gh-actions-functional-network-test.sh b/scripts/ios/fv/gh-actions-functional-network-test.sh
index dfc5c92f8..98751378b 100755
--- a/scripts/ios/fv/gh-actions-functional-network-test.sh
+++ b/scripts/ios/fv/gh-actions-functional-network-test.sh
@@ -63,7 +63,7 @@ else
       echo ">>> Installing mock server SSL certificate into OS... >>>"
       # Import and Make trusted
       sudo security import mock-server-cert.pem
-      sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain mock-server-cert.pem
+      sudo security authorizationdb write com.apple.trust-settings.admin allow; sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain mock-server-cert.pem ; sudo security authorizationdb remove com.apple.trust-settings.admin || true
       # Validate cert: if trusted - succeeded , if not trusted - fails
       sudo security verify-cert -c mock-server-cert.pem
       echo ">>> Starting Mock Server... >>>"