From ab3cc1fcc488436086407dd2127509e5b88d289d Mon Sep 17 00:00:00 2001 From: phlax Date: Tue, 23 May 2023 20:56:04 +0100 Subject: [PATCH] mobile/ci: Improve mobile jobs (#27404) Signed-off-by: Ryan Northey --- .github/workflows/env.yml | 64 ++++++++++++++ .github/workflows/mobile-android_build.yml | 81 ++++++------------ .github/workflows/mobile-android_tests.yml | 37 +++------ .github/workflows/mobile-asan.yml | 16 ++-- .github/workflows/mobile-cc_tests.yml | 10 ++- .../workflows/mobile-compile_time_options.yml | 37 +++------ .github/workflows/mobile-core.yml | 4 +- .github/workflows/mobile-coverage.yml | 18 ++-- .github/workflows/mobile-docs.yml | 4 +- .github/workflows/mobile-format.yml | 50 ++++------- .github/workflows/mobile-ios_build.yml | 83 +++++-------------- .github/workflows/mobile-ios_tests.yml | 27 +++--- .github/workflows/mobile-perf.yml | 12 +-- .../workflows/mobile-release_validation.yml | 19 ++--- .github/workflows/mobile-tsan.yml | 16 ++-- mobile/tools/should_run_ci.sh | 61 -------------- mobile/tools/what_to_run.sh | 52 ++++++++++++ 17 files changed, 260 insertions(+), 331 deletions(-) create mode 100644 .github/workflows/env.yml delete mode 100755 mobile/tools/should_run_ci.sh create mode 100755 mobile/tools/what_to_run.sh diff --git a/.github/workflows/env.yml b/.github/workflows/env.yml new file mode 100644 index 000000000000..a0caaa67cfb6 --- /dev/null +++ b/.github/workflows/env.yml @@ -0,0 +1,64 @@ +name: Environment + +on: + workflow_call: + outputs: + mobile_android_build: + value: ${{ jobs.mobile.outputs.mobile_android_build }} + mobile_android_build_all: + value: ${{ jobs.mobile.outputs.mobile_android_build_all }} + mobile_android_tests: + value: ${{ jobs.mobile.outputs.mobile_android_tests }} + mobile_asan: + value: ${{ jobs.mobile.outputs.mobile_asan }} + mobile_cc_tests: + value: ${{ jobs.mobile.outputs.mobile_cc_tests }} + mobile_compile_time_options: + value: ${{ jobs.mobile.outputs.mobile_compile_time_options }} + mobile_coverage: + value: ${{ jobs.mobile.outputs.mobile_coverage }} + mobile_formatting: + value: ${{ jobs.mobile.outputs.mobile_formatting }} + mobile_ios_build: + value: ${{ jobs.mobile.outputs.mobile_ios_build }} + mobile_ios_build_all: + value: ${{ jobs.mobile.outputs.mobile_ios_build_all }} + mobile_ios_tests: + value: ${{ jobs.mobile.outputs.mobile_ios_tests }} + mobile_release_validation: + value: ${{ jobs.mobile.outputs.mobile_release_validation }} + mobile_tsan: + value: ${{ jobs.mobile.outputs.mobile_tsan }} + +concurrency: + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }}-env + cancel-in-progress: true + +jobs: + mobile: + if: github.repository == 'envoyproxy/envoy' + runs-on: ubuntu-20.04 + outputs: + mobile_android_build: ${{ steps.should_run.outputs.mobile_android_build }} + mobile_android_build_all: ${{ steps.should_run.outputs.mobile_android_build_all }} + mobile_android_tests: ${{ steps.should_run.outputs.mobile_android_tests }} + mobile_asan: ${{ steps.should_run.outputs.mobile_asan }} + mobile_cc_tests: ${{ steps.should_run.outputs.mobile_cc_tests }} + mobile_compile_time_options: ${{ steps.should_run.outputs.mobile_compile_time_options }} + mobile_coverage: ${{ steps.should_run.outputs.mobile_coverage }} + mobile_formatting: ${{ steps.should_run.outputs.mobile_formatting }} + mobile_ios_build: ${{ steps.should_run.outputs.mobile_ios_build }} + mobile_ios_build_all: ${{ steps.should_run.outputs.mobile_ios_build_all }} + mobile_ios_tests: ${{ steps.should_run.outputs.mobile_ios_tests }} + mobile_release_validation: ${{ steps.should_run.outputs.mobile_release_validation }} + mobile_tsan: ${{ steps.should_run.outputs.mobile_tsan }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Add safe directory + run: git config --global --add safe.directory /__w/envoy/envoy + - id: should_run + name: 'Check what to run' + run: | + ./mobile/tools/what_to_run.sh diff --git a/.github/workflows/mobile-android_build.yml b/.github/workflows/mobile-android_build.yml index 4e1f8ec328e0..8f5c71a7d978 100644 --- a/.github/workflows/mobile-android_build.yml +++ b/.github/workflows/mobile-android_build.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + androidbuild: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_build == 'true' }} + needs: env name: android_build runs-on: ubuntu-20.04 timeout-minutes: 90 @@ -23,15 +29,9 @@ jobs: CXX: /opt/llvm/bin/clang++ steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Build envoy.aar distributable' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -40,31 +40,26 @@ jobs: --fat_apk_cpu=x86_64 \ --linkopt=-fuse-ld=lld \ //:android_dist + javahelloworld: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_build_all == 'true' }} + needs: + - env + - androidbuild name: java_helloworld - needs: androidbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - run: cd mobile && ./ci/mac_ci_setup.sh --android - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start emulator' with: timeout_minutes: 10 @@ -74,7 +69,6 @@ jobs: # cd mobile && ./bazelw mobile-install --fat_apk_cpu=x86_64 --start_app //examples/java/hello_world:hello_envoy # When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed. - name: 'Start java app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -85,7 +79,6 @@ jobs: adb install -r --no-incremental bazel-bin/examples/java/hello_world/hello_envoy.apk adb shell am start -n io.envoyproxy.envoymobile.helloenvoy/.MainActivity - name: 'Check connectivity' - if: steps.should_run.outputs.run_ci_job == 'true' run: | timeout 30 adb logcat -e "received headers with status 301" -m 1 || { echo "Failed checking for headers in adb logcat" >&2 @@ -95,30 +88,24 @@ jobs: exit 1 } kotlinhelloworld: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_build == 'true' }} + needs: + - env + - androidbuild name: kotlin_helloworld - needs: androidbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh --android - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start emulator' with: timeout_minutes: 10 @@ -128,7 +115,6 @@ jobs: # ./bazelw mobile-install --fat_apk_cpu=x86_64 --start_app //examples/kotlin/hello_world:hello_envoy_kt # When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed. - name: 'Start kotlin app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -139,7 +125,6 @@ jobs: adb install -r --no-incremental bazel-bin/examples/kotlin/hello_world/hello_envoy_kt.apk adb shell am start -n io.envoyproxy.envoymobile.helloenvoykotlin/.MainActivity - name: 'Check connectivity' - if: steps.should_run.outputs.run_ci_job == 'true' run: | timeout 30 adb logcat -e "received headers with status 200" -m 1 || { echo "Failed checking for headers in adb logcat" >&2 @@ -150,30 +135,24 @@ jobs: } kotlinbaselineapp: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_build_all == 'true' }} + needs: + - env + - androidbuild name: kotlin_baseline_app - needs: androidbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh --android - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start emulator' with: timeout_minutes: 10 @@ -183,7 +162,6 @@ jobs: # ./bazelw mobile-install --fat_apk_cpu=x86_64 --start_app //examples/kotlin/hello_world:hello_envoy_kt # When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed. - name: 'Start kotlin app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -194,7 +172,6 @@ jobs: adb install -r --no-incremental bazel-bin/test/kotlin/apps/baseline/hello_envoy_kt.apk adb shell am start -n io.envoyproxy.envoymobile.helloenvoybaselinetest/.MainActivity - name: 'Check connectivity' - if: steps.should_run.outputs.run_ci_job == 'true' run: | timeout 30 adb logcat -e "received headers with status 301" -m 1 || { echo "Failed checking for headers in adb logcat" >&2 @@ -204,30 +181,24 @@ jobs: exit 1 } kotlinexperimentalapp: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_build_all == 'true' }} + needs: + - env + - androidbuild name: kotlin_experimental_app - needs: androidbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh --android - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start emulator' with: timeout_minutes: 10 @@ -237,7 +208,6 @@ jobs: # ./bazelw mobile-install --fat_apk_cpu=x86_64 --start_app //examples/kotlin/hello_world:hello_envoy_kt # When https://github.com/envoyproxy/envoy-mobile/issues/853 is fixed. - name: 'Start kotlin app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -250,7 +220,6 @@ jobs: adb install -r --no-incremental bazel-bin/test/kotlin/apps/experimental/hello_envoy_kt.apk adb shell am start -n io.envoyproxy.envoymobile.helloenvoyexperimentaltest/.MainActivity - name: 'Check connectivity' - if: steps.should_run.outputs.run_ci_job == 'true' run: | timeout 30 adb logcat -e "received headers with status 200" -m 1 || { echo "Failed checking for headers in adb logcat" >&2 diff --git a/.github/workflows/mobile-android_tests.yml b/.github/workflows/mobile-android_tests.yml index f4b44217c0e7..9baf8b9922a7 100644 --- a/.github/workflows/mobile-android_tests.yml +++ b/.github/workflows/mobile-android_tests.yml @@ -7,12 +7,17 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + uses: ./.github/workflows/env.yml + secrets: inherit + kotlintestsmac: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_tests == 'true' }} + needs: env # revert to //test/kotlin/... once fixed # https://github.com/envoyproxy/envoy-mobile/issues/1932 name: kotlin_tests_mac @@ -20,13 +25,7 @@ jobs: timeout-minutes: 90 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Java setup' - if: steps.should_run.outputs.run_ci_job == 'true' uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: java-version: '8' @@ -34,10 +33,8 @@ jobs: architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh - name: 'Run Kotlin library tests' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -48,19 +45,14 @@ jobs: --define=signal_trace=disabled \ //test/kotlin/io/... javatestsmac: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_tests == 'true' }} + needs: env name: java_tests_mac runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Java setup' - if: steps.should_run.outputs.run_ci_job == 'true' uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 with: java-version: '8' @@ -68,10 +60,8 @@ jobs: architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh - name: 'Run Java library tests' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -85,7 +75,8 @@ jobs: --define=system-helper=android \ //test/java/... kotlintestslinux: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_android_tests == 'true' }} + needs: env # Only kotlin tests are executed since with linux: # https://github.com/envoyproxy/envoy-mobile/issues/1418. name: kotlin_tests_linux @@ -98,15 +89,9 @@ jobs: CXX: /opt/llvm/bin/clang++ steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run Kotlin library integration tests' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.github/workflows/mobile-asan.yml b/.github/workflows/mobile-asan.yml index 2681176bc068..e5a9378c262e 100644 --- a/.github/workflows/mobile-asan.yml +++ b/.github/workflows/mobile-asan.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + asan: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_asan == 'true' }} + needs: env name: asan runs-on: ubuntu-20.04 timeout-minutes: 180 @@ -23,17 +29,11 @@ jobs: CXX: /opt/llvm/bin/clang++ steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run tests' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: steps.should_run.outputs.run_ci_job == 'true' run: | cd mobile && ./bazelw test --test_output=all \ --test_env=ENVOY_IP_TEST_VERSIONS=v4only \ diff --git a/.github/workflows/mobile-cc_tests.yml b/.github/workflows/mobile-cc_tests.yml index 28f6c633ecd8..c824fc8f6ece 100644 --- a/.github/workflows/mobile-cc_tests.yml +++ b/.github/workflows/mobile-cc_tests.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + cctests: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_cc_tests == 'true' }} + needs: env name: cc_tests runs-on: ubuntu-20.04 timeout-minutes: 120 diff --git a/.github/workflows/mobile-compile_time_options.yml b/.github/workflows/mobile-compile_time_options.yml index b9ee5e056dda..fc8ff2073781 100644 --- a/.github/workflows/mobile-compile_time_options.yml +++ b/.github/workflows/mobile-compile_time_options.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + cc_test: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_compile_time_options == 'true' }} + needs: env name: cc_test runs-on: ubuntu-20.04 timeout-minutes: 120 @@ -20,15 +26,9 @@ jobs: image: envoyproxy/envoy-build-ubuntu:b0ff77ae3f25b0bf595f9b8bba46b489723ab446 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Build C++ library' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Envoy Mobile build verifies that the build configuration where HTTP/3 is enabled and @@ -45,22 +45,16 @@ jobs: --@com_envoyproxy_protoc_gen_validate//bazel:template-flavor= \ //test/cc/... swift_build: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_compile_time_options == 'true' }} + needs: env name: swift_build runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build Swift library' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -79,29 +73,22 @@ jobs: --@com_envoyproxy_protoc_gen_validate//bazel:template-flavor= \ //library/swift:ios_framework kotlin_build: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_compile_time_options == 'true' }} + needs: env name: kotlin_build runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh --android - name: 'Build Kotlin library' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.github/workflows/mobile-core.yml b/.github/workflows/mobile-core.yml index 26cd00b8089d..7c111e04a88b 100644 --- a/.github/workflows/mobile-core.yml +++ b/.github/workflows/mobile-core.yml @@ -7,12 +7,12 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: unittests: - if: github.repository == 'envoyproxy/envoy' + if: ${{ github.repository == 'envoyproxy/envoy' }} name: unit_tests runs-on: ubuntu-20.04 timeout-minutes: 120 diff --git a/.github/workflows/mobile-coverage.yml b/.github/workflows/mobile-coverage.yml index cdb1cf2a9853..8ff027449a9e 100644 --- a/.github/workflows/mobile-coverage.yml +++ b/.github/workflows/mobile-coverage.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + coverage: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_coverage == 'true' }} + needs: env name: coverage runs-on: ubuntu-20.04 timeout-minutes: 120 @@ -23,15 +29,9 @@ jobs: image: envoyproxy/envoy-build-ubuntu:41c5a05d708972d703661b702a63ef5060125c33 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run coverage' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -40,11 +40,9 @@ jobs: COVERAGE_THRESHOLD=76 \ ../test/run_envoy_bazel_coverage.sh //test/common/... //test/cc/... - name: 'Package coverage' - if: steps.should_run.outputs.run_ci_job == 'true' run: | cd mobile && tar -czf coverage.tar.gz generated/coverage - name: 'Upload report' - if: steps.should_run.outputs.run_ci_job == 'true' uses: actions/upload-artifact@v3 with: name: coverage.tar.gz diff --git a/.github/workflows/mobile-docs.yml b/.github/workflows/mobile-docs.yml index 403529803e14..093b5f29740c 100644 --- a/.github/workflows/mobile-docs.yml +++ b/.github/workflows/mobile-docs.yml @@ -7,12 +7,12 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: docs: - if: github.repository == 'envoyproxy/envoy' + if: ${{ github.repository == 'envoyproxy/envoy' }} runs-on: ubuntu-20.04 timeout-minutes: 20 container: diff --git a/.github/workflows/mobile-format.yml b/.github/workflows/mobile-format.yml index 97457d9f2015..ac48d4308063 100644 --- a/.github/workflows/mobile-format.yml +++ b/.github/workflows/mobile-format.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + formatall: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_formatting == 'true' }} + needs: env name: format_all runs-on: ubuntu-20.04 timeout-minutes: 45 @@ -25,36 +31,25 @@ jobs: ENVOY_BAZEL_PREFIX: "@envoy" steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run formatters' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./tools/check_format.sh precommit: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_formatting == 'true' }} + needs: env name: precommit runs-on: macos-12 timeout-minutes: 45 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Install precommit' - if: steps.should_run.outputs.run_ci_job == 'true' run: brew install pre-commit - name: 'Run precommit' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && find mobile/* | pre-commit run --files swiftlint: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_formatting == 'true' }} + needs: env name: swift_lint runs-on: ubuntu-latest timeout-minutes: 5 @@ -66,46 +61,34 @@ jobs: run: swiftlint lint --strict working-directory: mobile drstring: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_formatting == 'true' }} + needs: env name: drstring runs-on: macos-12 timeout-minutes: 10 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run DrString' - if: steps.should_run.outputs.run_ci_job == 'true' env: DEVELOPER_DIR: /Applications/Xcode_14.1.app run: cd mobile && ./bazelw run @DrString//:drstring check kotlinlint: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_formatting == 'true' }} + needs: env name: kotlin_lint runs-on: macos-12 timeout-minutes: 45 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 - if: steps.should_run.outputs.run_ci_job == 'true' with: java-version: '8' java-package: jdk architecture: x64 distribution: zulu - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Run Kotlin Lint (Detekt)' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -114,5 +97,4 @@ jobs: //library/kotlin/io/envoyproxy/envoymobile:envoy_lib_lint \ //examples/kotlin/hello_world:hello_envoy_kt_lint - name: 'Run Kotlin Formatter (ktlint)' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./bazelw build kotlin_format diff --git a/.github/workflows/mobile-ios_build.yml b/.github/workflows/mobile-ios_build.yml index fd3601c1cc9b..a1d117ff13cd 100644 --- a/.github/workflows/mobile-ios_build.yml +++ b/.github/workflows/mobile-ios_build.yml @@ -7,27 +7,26 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + iosbuild: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build == 'true' }} + needs: env name: ios_build runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build Envoy.framework distributable' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -37,23 +36,16 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //library/swift:ios_framework swifthelloworld: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build == 'true' }} name: swift_helloworld needs: iosbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -62,7 +54,6 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //examples/swift/hello_world:app - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start simulator' with: timeout_minutes: 5 @@ -70,7 +61,6 @@ jobs: command: ./mobile/ci/start_ios_simulator.sh # Run the app in the background and redirect logs. - name: 'Run app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -79,29 +69,23 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //examples/swift/hello_world:app &> /tmp/envoy.log & - run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log) - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Check connectivity' - run: cat /tmp/envoy.log if: ${{ failure() || cancelled() }} name: 'Log app run' swiftbaselineapp: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build_all == 'true' }} + needs: + - env + - iosbuild name: swift_baseline_app - needs: iosbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -110,7 +94,6 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //test/swift/apps/baseline:app - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start simulator' with: timeout_minutes: 5 @@ -118,7 +101,6 @@ jobs: command: ./mobile/ci/start_ios_simulator.sh # Run the app in the background and redirect logs. - name: 'Run app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -127,29 +109,22 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //test/swift/apps/baseline:app &> /tmp/envoy.log & - run: sed '/received headers with status 301/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log) - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Check connectivity' - run: cat /tmp/envoy.log if: ${{ failure() || cancelled() }} name: 'Log app run' swiftexperimentalapp: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build_all == 'true' }} + needs: env name: swift_experimental_app needs: iosbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -160,7 +135,6 @@ jobs: --define envoy_mobile_listener=enabled \ //test/swift/apps/experimental:app - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start simulator' with: timeout_minutes: 5 @@ -168,7 +142,6 @@ jobs: command: ./mobile/ci/start_ios_simulator.sh # Run the app in the background and redirect logs. - name: 'Run app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -179,29 +152,22 @@ jobs: --define envoy_mobile_listener=enabled \ //test/swift/apps/experimental:app &> /tmp/envoy.log & - run: sed '/received headers with status 200/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log) - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Check connectivity' - run: cat /tmp/envoy.log if: ${{ failure() || cancelled() }} name: 'Log app run' swiftasyncawait: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build_all == 'true' }} + needs: env name: swift_async_await needs: iosbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -210,7 +176,6 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //examples/swift/async_await:app - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start simulator' with: timeout_minutes: 5 @@ -218,7 +183,6 @@ jobs: command: ./mobile/ci/start_ios_simulator.sh # Run the app in the background and redirect logs. - name: 'Run app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -249,23 +213,17 @@ jobs: if: ${{ failure() || cancelled() }} name: 'Log app run' objchelloworld: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_build_all == 'true' }} + needs: env name: objc_helloworld needs: iosbuild runs-on: macos-12 timeout-minutes: 50 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -274,7 +232,6 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //examples/objective-c/hello_world:app - uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Start simulator' with: timeout_minutes: 5 @@ -282,7 +239,6 @@ jobs: command: ./mobile/ci/start_ios_simulator.sh # Run the app in the background and redirect logs. - name: 'Run app' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -291,7 +247,6 @@ jobs: $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ //examples/objective-c/hello_world:app &> /tmp/envoy.log & - run: sed '/received headers with status 301/q' <(touch /tmp/envoy.log && tail -F /tmp/envoy.log) - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Check connectivity' - run: cat /tmp/envoy.log if: ${{ failure() || cancelled() }} diff --git a/.github/workflows/mobile-ios_tests.yml b/.github/workflows/mobile-ios_tests.yml index c2b141027d9f..e6f25e960d7e 100644 --- a/.github/workflows/mobile-ios_tests.yml +++ b/.github/workflows/mobile-ios_tests.yml @@ -7,27 +7,26 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + swifttests: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_tests == 'true' }} + needs: env name: swift_tests runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh - name: 'Run swift library tests' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # runs with admin enabled due to regression testing admin interface @@ -43,22 +42,16 @@ jobs: --define=admin_functionality=enabled \ //test/swift/... objctests: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_ios_tests == 'true' }} + needs: env name: c_and_objc_tests runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Install dependencies' - if: steps.should_run.outputs.run_ci_job == 'true' run: cd mobile && ./ci/mac_ci_setup.sh - name: 'Run Objective-C library tests' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.github/workflows/mobile-perf.yml b/.github/workflows/mobile-perf.yml index 26084818d469..b1c142bf2c1b 100644 --- a/.github/workflows/mobile-perf.yml +++ b/.github/workflows/mobile-perf.yml @@ -7,12 +7,12 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: sizecurrent: - if: github.repository == 'envoyproxy/envoy' + if: ${{ github.repository == 'envoyproxy/envoy' }} name: size_current runs-on: ubuntu-20.04 timeout-minutes: 120 @@ -39,7 +39,7 @@ jobs: name: sizecurrent path: mobile/bazel-bin/test/performance/test_binary_size sizemain: - if: github.repository == 'envoyproxy/envoy' + if: ${{ github.repository == 'envoyproxy/envoy' }} name: size_main runs-on: ubuntu-20.04 timeout-minutes: 90 @@ -68,9 +68,11 @@ jobs: name: sizemain path: mobile/bazel-bin/test/performance/test_binary_size sizecompare: - if: github.repository == 'envoyproxy/envoy' + if: ${{ github.repository == 'envoyproxy/envoy' }} + needs: + - sizecurrent + - sizemain name: size_compare - needs: [sizecurrent, sizemain] runs-on: ubuntu-20.04 timeout-minutes: 30 container: diff --git a/.github/workflows/mobile-release_validation.yml b/.github/workflows/mobile-release_validation.yml index f5f03d84420a..34cf2878aeea 100644 --- a/.github/workflows/mobile-release_validation.yml +++ b/.github/workflows/mobile-release_validation.yml @@ -7,27 +7,26 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + validate_swiftpm_example: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_release_validation == 'true' }} + needs: env name: validate_swiftpm_example runs-on: macos-12 timeout-minutes: 120 steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - run: cd mobile && ./ci/mac_ci_setup.sh - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Install dependencies' - name: 'Build xcframework' - if: steps.should_run.outputs.run_ci_job == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -37,9 +36,7 @@ jobs: //:ios_xcframework # Ignore errors: Bad CRC when unzipping large files: https://bbs.archlinux.org/viewtopic.php?id=153011 - run: unzip mobile/bazel-bin/library/swift/Envoy.xcframework.zip -d mobile/examples/swift/swiftpm/Packages || true - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Unzip xcframework' - run: xcodebuild -project mobile/examples/swift/swiftpm/EnvoySwiftPMExample.xcodeproj -scheme EnvoySwiftPMExample -destination platform="iOS Simulator,name=iPhone 14 Pro Max,OS=16.1" - if: steps.should_run.outputs.run_ci_job == 'true' name: 'Build app' # TODO(jpsim): Run app and inspect logs to validate diff --git a/.github/workflows/mobile-tsan.yml b/.github/workflows/mobile-tsan.yml index 8a5898f2b813..918613f15146 100644 --- a/.github/workflows/mobile-tsan.yml +++ b/.github/workflows/mobile-tsan.yml @@ -7,12 +7,18 @@ on: pull_request: concurrency: - group: ${{ github.head_ref-github.workflow || github.run_id }} + group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} cancel-in-progress: true jobs: + env: + if: ${{ github.repository == 'envoyproxy/envoy' }} + uses: ./.github/workflows/env.yml + secrets: inherit + tsan: - if: github.repository == 'envoyproxy/envoy' + if: ${{ needs.env.outputs.mobile_tsan == 'true' }} + needs: env name: tsan runs-on: ubuntu-20.04 timeout-minutes: 90 @@ -23,17 +29,11 @@ jobs: CXX: /opt/llvm/bin/clang++ steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Add safe directory run: git config --global --add safe.directory /__w/envoy/envoy - - id: should_run - name: 'Check whether to run' - run: ./mobile/tools/should_run_ci.sh - name: 'Run tests' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: steps.should_run.outputs.run_ci_job == 'true' run: | cd mobile && ./bazelw test \ --test_output=all \ diff --git a/mobile/tools/should_run_ci.sh b/mobile/tools/should_run_ci.sh deleted file mode 100755 index 1ee2622db98f..000000000000 --- a/mobile/tools/should_run_ci.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -######################################################################## -# should_run_ci.sh -# -# Checks current branch and changed PR paths to determine if mobile CI -# jobs should be run. -######################################################################## - -job="$GITHUB_JOB" -branch_name="$GITHUB_REF_NAME" - -function success() { - echo "Running $job because there are $1 changes on $branch_name" - echo "run_ci_job=true" >> "$GITHUB_OUTPUT" -} - -function failure() { - echo "Skipping $job because there are no mobile changes on $branch_name" - echo "run_ci_job=false" >> "$GITHUB_OUTPUT" -} - -if [[ $branch_name == "main" ]]; then - # Skip some example apps on `main` to reduce CI load - case "$job" in - swiftbaselineapp|swiftexperimentalapp|swiftasyncawait|objchelloworld|javahelloworld|kotlinbaselineapp|kotlinexperimentalapp) - echo "Skipping $job because current branch is main" - echo "run_ci_job=false" >> "$GITHUB_OUTPUT" - exit 0 - ;; - esac - - # Run all other mobile CI jobs on `main` - echo "Running $job because current branch is main" - echo "run_ci_job=true" >> "$GITHUB_OUTPUT" - exit 0 -fi - -if [[ $GITHUB_BASE_REF == release/* ]]; then - # Skip mobile CI jobs on PRs targeting release branches - echo "Skipping $job because the PR is targeting a release branch" - echo "run_ci_job=false" >> "$GITHUB_OUTPUT" - exit 0 -fi - -base_commit="$(git merge-base origin/main HEAD)" -changed_files="$(git diff "$base_commit" --name-only)" - -if grep -q "^mobile/" <<< "$changed_files"; then - success "mobile" -elif grep -q "^bazel/repository_locations\.bzl" <<< "$changed_files"; then - success "bazel/repository_locations.bzl" -elif grep -q "^\.bazelrc" <<< "$changed_files"; then - success ".bazelrc" -elif grep -q "^\.github/workflows/mobile-*" <<< "$changed_files"; then - success "GitHub Workflows" -else - failure -fi diff --git a/mobile/tools/what_to_run.sh b/mobile/tools/what_to_run.sh new file mode 100755 index 000000000000..d67ca8e9c9b4 --- /dev/null +++ b/mobile/tools/what_to_run.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -euo pipefail + +BRANCH_NAME="$GITHUB_REF_NAME" +BASE_COMMIT="$(git merge-base origin/main HEAD)" +CHANGED_FILES="$(git diff "${BASE_COMMIT}" --name-only)" +CHANGE_MATCH='^mobile/|^bazel/repository_locations\.bzl|^\.bazelrc|^\.github/workflows/mobile-*|^\.github/workflows/env.yml' + +# The logic in this file is roughly: +# +# pull_request + changed files = run all mobile CI +# +# main = run some mobile CI +# +# all other commits = run minimal mobile CI (these jobs have no conditions) +# +# Branches are not currently tested, altho that should be restricted by the workflow + + +run_default_ci () { + { + echo "mobile_android_build=true" + echo "mobile_android_tests=true" + echo "mobile_asan=true" + echo "mobile_cc_tests=true" + echo "mobile_compile_time_options=true" + echo "mobile_coverage=true" + echo "mobile_formatting=true" + echo "mobile_ios_build=true" + echo "mobile_ios_tests=true" + echo "mobile_release_validation=true" + echo "mobile_tsan=true" + } >> "$GITHUB_OUTPUT" +} + +run_ci_for_changed_files () { + run_default_ci + { + echo "mobile_android_build_all=true" + echo "mobile_ios_build_all=true" + } >> "$GITHUB_OUTPUT" +} + +if [[ "$BRANCH_NAME" == "main" ]]; then + run_default_ci + exit 0 +fi + +if grep -qE "$CHANGE_MATCH" <<< "$CHANGED_FILES"; then + run_ci_for_changed_files +fi