From b8e6766b905aa700951ca7f8a93f4207ebe8a608 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Fri, 13 Oct 2023 17:45:27 +0100 Subject: [PATCH 1/5] mobile/ci: Add reusable workflow Signed-off-by: Ryan Northey --- .github/workflows/_mobile_ci.yml | 93 ++++++++++++++++++ .github/workflows/mobile-android_tests.yml | 106 +++++++++------------ 2 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/_mobile_ci.yml diff --git a/.github/workflows/_mobile_ci.yml b/.github/workflows/_mobile_ci.yml new file mode 100644 index 000000000000..96cb283527f6 --- /dev/null +++ b/.github/workflows/_mobile_ci.yml @@ -0,0 +1,93 @@ +name: Envoy CI + +on: + workflow_call: + inputs: + target: + required: true + type: string + name: + required: true + type: string + command: + required: true + type: string + build_image: + type: string + runs-on: + required: true + type: string + timeout-minutes: + type: number + default: 20 + + diskspace_hack: + type: boolean + default: false + skip: + type: boolean + default: false + env: + type: string + + +concurrency: + group: ${{ github.workflow }}-${{ inputs.target }} + cancel-in-progress: true + +jobs: + mobile_ci: + if: ${{ ! inputs.skip }} + runs-on: ${{ inputs.runs-on }} + name: ${{ inputs.target }} + permissions: + contents: read + packages: read + timeout-minutes: ${{ inputs.timeout-minutes }} + steps: + - name: Pre-cleanup + # Using the defaults in + # https://github.com/envoyproxy/toolshed/blob/main/gh-actions/diskspace/action.yml. + uses: envoyproxy/toolshed/gh-actions/diskspace@actions-v0.0.18 + if: ${{ inputs.diskpace_hack }} + - uses: actions/checkout@v4 + - name: Add safe directory + run: git config --global --add safe.directory /__w/envoy/envoy + + - name: 'Java setup' + if: contains(inputs.runs-on, 'macos') + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 + with: + java-version: '8' + java-package: jdk + architecture: x64 + distribution: zulu + - name: 'Install mac dependencies' + if: contains(inputs.runs-on, 'macos') + run: | + cd mobile + ./ci/mac_ci_setup.sh + + - name: Set Environment Variables + run: | + read -ra vars <<< {{ inputs.env }} + for [[ var in "${vars[@]}" ]]; do + IFS=': ' read -ra parts <<< "$var" + export "${parts[0]}=${parts[1]}" + done + - name: ${{ inputs.name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ -z "${{ inputs.build_image }}" ]]; then + ${{ inputs.command }} + exit 0 + fi + docker run \ + --volume="${PWD}:/source" \ + --workdir="/source/mobile" \ + -e GITHUB_TOKEN \ + -e CC \ + -e CXX \ + ${{ inputs.build_image }} \ + ${{ inputs.command }} diff --git a/.github/workflows/mobile-android_tests.yml b/.github/workflows/mobile-android_tests.yml index f9b381021241..fc1918b11b5f 100644 --- a/.github/workflows/mobile-android_tests.yml +++ b/.github/workflows/mobile-android_tests.yml @@ -21,68 +21,52 @@ jobs: permissions: contents: read - javatestslinux: - if: ${{ needs.env.outputs.mobile_android_tests == 'true' }} + android_test: + name: ${{ matrix.target }} needs: env permissions: contents: read packages: read - name: java_tests_linux - runs-on: ${{ needs.env.outputs.agent_ubuntu }} - timeout-minutes: 90 - steps: - - name: Pre-cleanup - # Using the defaults in - # https://github.com/envoyproxy/toolshed/blob/main/gh-actions/diskspace/action.yml. - uses: envoyproxy/toolshed/gh-actions/diskspace@actions-v0.0.18 - - uses: actions/checkout@v4 - - name: Add safe directory - run: git config --global --add safe.directory /__w/envoy/envoy - - name: 'Run Kotlin library integration tests' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CC: /opt/llvm/bin/clang - CXX: /opt/llvm/bin/clang++ - run: | - docker run --volume="${PWD}:/source" --workdir="/source/mobile" \ - -e GITHUB_TOKEN -e CC -e CXX ${{ needs.env.outputs.build_image_ubuntu_mobile }} \ - ./bazelw test \ - --build_tests_only \ - --config=test-android \ - --config=mobile-remote-ci \ - --define=signal_trace=disabled \ - //test/java/... - - kotlintestslinux: - if: ${{ needs.env.outputs.mobile_android_tests == 'true' }} - needs: env - permissions: - contents: read - packages: read - # Only kotlin tests are executed since with linux: - # https://github.com/envoyproxy/envoy-mobile/issues/1418. - name: kotlin_tests_linux - runs-on: ${{ needs.env.outputs.agent_ubuntu }} - timeout-minutes: 90 - steps: - - name: Pre-cleanup - # Using the defaults in - # https://github.com/envoyproxy/toolshed/blob/main/gh-actions/diskspace/action.yml. - uses: envoyproxy/toolshed/gh-actions/diskspace@actions-v0.0.18 - - uses: actions/checkout@v4 - - name: Add safe directory - run: git config --global --add safe.directory /__w/envoy/envoy - - name: 'Run Kotlin library integration tests' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CC: /opt/llvm/bin/clang - CXX: /opt/llvm/bin/clang++ - run: | - docker run --volume="${PWD}:/source" --workdir="/source/mobile" \ - -e GITHUB_TOKEN -e CC -e CXX ${{ needs.env.outputs.build_image_ubuntu_mobile }} \ - ./bazelw test \ - --build_tests_only \ - --config=test-android \ - --config=mobile-remote-ci \ - --define=signal_trace=disabled \ - //test/kotlin/... + strategy: + fail-fast: false + matrix: + include: + # Only kotlin tests are executed since with linux: + # https://github.com/envoyproxy/envoy-mobile/issues/1418. + - target: kotlin_tests_linux + name: Run Kotlin library integration tests + diskspace_hack: true + timeout-minutes: 90 + runs-on: ${{ needs.env.outputs.agent_ubuntu }} + env: | + CC: /opt/llvm/bin/clang + CXX: /opt/llvm/bin/clang++ + command: | + ./bazelw test \ + --build_tests_only \ + --config=test-android \ + --config=mobile-remote-ci \ + --define=signal_trace=disabled \ + //test/kotlin/... + - target: java_tests_linux + name: Run Java library tests + timeout-minutes: 120 + runs-on: ${{ needs.env.outputs.agent_ubuntu }} + run: | + ./bazelw test \ + --build_tests_only \ + --config=test-android \ + --config=mobile-remote-ci \ + --define=signal_trace=disabled \ + //test/java/... + uses: ./.github/workflows/_mobile_ci.yml + with: + target: ${{ matrix.target }} + name: ${{ matrix.name }} + env: ${{ matrix.env }} + command: ${{ matrix.command }} + build_image: ${{ needs.env.outputs.build_image_ubuntu_mobile }} + diskspace_hack: ${{ matrix.diskspace_hack == 'true' }} + runs-on: ${{ matrix.runs-on }} + timeout-minutes: ${{ fromJSON(matrix.timeout-minutes) }} + skip: ${{ needs.env.outputs.mobile_android_tests != 'true' }} From 519f522f6483fd88b4073f9cb81d3267253082fb Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Fri, 13 Oct 2023 18:29:47 +0100 Subject: [PATCH 2/5] .github/ Signed-off-by: Ryan Northey --- .github/workflows/_mobile_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_mobile_ci.yml b/.github/workflows/_mobile_ci.yml index 96cb283527f6..4e64bcd54c3e 100644 --- a/.github/workflows/_mobile_ci.yml +++ b/.github/workflows/_mobile_ci.yml @@ -70,7 +70,7 @@ jobs: - name: Set Environment Variables run: | - read -ra vars <<< {{ inputs.env }} + read -ra vars <<< ${{ inputs.env }} for [[ var in "${vars[@]}" ]]; do IFS=': ' read -ra parts <<< "$var" export "${parts[0]}=${parts[1]}" From 3017db86165faab22d6f1d80d6a00f83019dce11 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Fri, 13 Oct 2023 18:31:45 +0100 Subject: [PATCH 3/5] .github/ Signed-off-by: Ryan Northey --- .github/workflows/_mobile_ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/_mobile_ci.yml b/.github/workflows/_mobile_ci.yml index 4e64bcd54c3e..63a06c1567fc 100644 --- a/.github/workflows/_mobile_ci.yml +++ b/.github/workflows/_mobile_ci.yml @@ -70,6 +70,9 @@ jobs: - name: Set Environment Variables run: | + if [[ -z "${{ inputs.env }}" ]]; do + exit 0 + done read -ra vars <<< ${{ inputs.env }} for [[ var in "${vars[@]}" ]]; do IFS=': ' read -ra parts <<< "$var" From 034dc7af0d6cf6972ff66f8e056943a21c9127cd Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Fri, 13 Oct 2023 18:34:02 +0100 Subject: [PATCH 4/5] .github/ Signed-off-by: Ryan Northey --- .github/workflows/_mobile_ci.yml | 9 +++++++-- .github/workflows/mobile-android_tests.yml | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/_mobile_ci.yml b/.github/workflows/_mobile_ci.yml index 63a06c1567fc..791242160b3d 100644 --- a/.github/workflows/_mobile_ci.yml +++ b/.github/workflows/_mobile_ci.yml @@ -1,4 +1,7 @@ -name: Envoy CI +name: Envoy mobile CI + +permissions: + contents: read on: workflow_call: @@ -29,7 +32,9 @@ on: default: false env: type: string - + default: | + CC: /opt/llvm/bin/clang + CXX: /opt/llvm/bin/clang++ concurrency: group: ${{ github.workflow }}-${{ inputs.target }} diff --git a/.github/workflows/mobile-android_tests.yml b/.github/workflows/mobile-android_tests.yml index fc1918b11b5f..df8c7a7995a8 100644 --- a/.github/workflows/mobile-android_tests.yml +++ b/.github/workflows/mobile-android_tests.yml @@ -38,9 +38,6 @@ jobs: diskspace_hack: true timeout-minutes: 90 runs-on: ${{ needs.env.outputs.agent_ubuntu }} - env: | - CC: /opt/llvm/bin/clang - CXX: /opt/llvm/bin/clang++ command: | ./bazelw test \ --build_tests_only \ From a107d5ddb48eb89c13f65c0a90c487a515b34b19 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Fri, 13 Oct 2023 18:35:52 +0100 Subject: [PATCH 5/5] .github/ Signed-off-by: Ryan Northey --- .github/workflows/_mobile_ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_mobile_ci.yml b/.github/workflows/_mobile_ci.yml index 791242160b3d..43bdd93073a1 100644 --- a/.github/workflows/_mobile_ci.yml +++ b/.github/workflows/_mobile_ci.yml @@ -75,9 +75,9 @@ jobs: - name: Set Environment Variables run: | - if [[ -z "${{ inputs.env }}" ]]; do + if [[ -z "${{ inputs.env }}" ]]; then exit 0 - done + fi read -ra vars <<< ${{ inputs.env }} for [[ var in "${vars[@]}" ]]; do IFS=': ' read -ra parts <<< "$var"