From 08532d12082dab84efaa3b60a51dba774d3f4f23 Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Thu, 4 Aug 2022 11:51:44 -0700 Subject: [PATCH 1/6] Add workflow definition for fireperf end-to-end tests --- .github/workflows/fireperf-e2e.yml | 96 +++++++++++++++++++++++++++++ ci/fireci/fireciplugins/fireperf.py | 3 +- 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/fireperf-e2e.yml diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml new file mode 100644 index 00000000000..e3b0a26d250 --- /dev/null +++ b/.github/workflows/fireperf-e2e.yml @@ -0,0 +1,96 @@ +name: FirePerf E2E Tests + +on: + pull_request: + schedule: + - cron: 4 */4 * * * # every 4 hours at 04 minutes past the hour + +concurrency: + group: ${{ github.workflow }} + +env: + PERF_E2E_GOOGLE_SERVICES: ${{ secrets.PERF_E2E_GOOGLE_SERVICES }} + FTL_RESULTS_BUCKET: fireescape + +jobs: + prod: + runs-on: ubuntu-latest + steps: + - name: Checkout firebase-android-sdk + uses: actions/checkout@v3 + - name: Checkout firebase-android-buildtools + uses: actions/checkout@v3 + with: + repository: FirebasePrivate/firebase-android-buildtools + token: ${{ secrets.GOOGLE_OSS_BOT_TOKEN }} + path: firebase-android-buildtools + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: temurin + cache: gradle + - name: Set up NDK 21.4.7075529 + run: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager + echo "y" | $SDKMANAGER "ndk;21.4.7075529" + ln -sfn ${ANDROID_SDK_ROOT}/ndk/21.4.7075529 ${ANDROID_NDK_ROOT} + echo "ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}" >> $GITHUB_ENV + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Set up fireci + run: pip3 install -e ci/fireci + - uses: google-github-actions/auth@v0 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} + - uses: google-github-actions/setup-gcloud@v0 + - name: Add google-services.json + run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json + - name: Run fireperf end-to-end tests + run: fireci fireperf_e2e_test --plugin_repo_dir=firebase-android-buildtools --target_environment=prod + + autopush: + runs-on: ubuntu-latest + steps: + - name: Checkout firebase-android-sdk + uses: actions/checkout@v3 + - name: Checkout firebase-android-buildtools + uses: actions/checkout@v3 + with: + repository: FirebasePrivate/firebase-android-buildtools + token: ${{ secrets.GOOGLE_OSS_BOT_TOKEN }} + path: firebase-android-buildtools + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: temurin + cache: gradle + - name: Set up NDK 21.4.7075529 + run: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager + echo "y" | $SDKMANAGER "ndk;21.4.7075529" + ln -sfn ${ANDROID_SDK_ROOT}/ndk/21.4.7075529 ${ANDROID_NDK_ROOT} + echo "ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}" >> $GITHUB_ENV + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Set up fireci + run: pip3 install -e ci/fireci + - uses: google-github-actions/auth@v0 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} + - uses: google-github-actions/setup-gcloud@v0 + - name: Add google-services.json + run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json + - name: Run fireperf end-to-end tests + run: fireci fireperf_e2e_test --plugin_repo_dir=firebase-android-buildtools --target_environment=autopush diff --git a/ci/fireci/fireciplugins/fireperf.py b/ci/fireci/fireciplugins/fireperf.py index a073c922efa..8e336e5390f 100644 --- a/ci/fireci/fireciplugins/fireperf.py +++ b/ci/fireci/fireciplugins/fireperf.py @@ -13,7 +13,6 @@ # limitations under the License. import click -import contextlib import logging import os import pathlib @@ -38,7 +37,7 @@ ) @ci_command() def fireperf_e2e_test(target_environment, plugin_repo_dir): - """Run Firebase Performance end to end test.""" + """Run Firebase Performance end-to-end test.""" _logger.info('Building fireperf plugin ...') with chdir(plugin_repo_dir): From 9614d2d9195d0c33ca80ac793facc5f6fbef56ed Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Thu, 4 Aug 2022 16:29:56 -0700 Subject: [PATCH 2/6] Remove pull_request trigger --- .github/workflows/fireperf-e2e.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml index e3b0a26d250..22c4edefc25 100644 --- a/.github/workflows/fireperf-e2e.yml +++ b/.github/workflows/fireperf-e2e.yml @@ -1,7 +1,6 @@ name: FirePerf E2E Tests on: - pull_request: schedule: - cron: 4 */4 * * * # every 4 hours at 04 minutes past the hour From 8befeaebdbd92cf4418eccbc382bdf7b637b30b1 Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Tue, 9 Aug 2022 16:21:21 -0700 Subject: [PATCH 3/6] Notify developers upon failures --- .github/workflows/fireperf-e2e.yml | 95 +++++++++++++++++------------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml index 22c4edefc25..663a1863d24 100644 --- a/.github/workflows/fireperf-e2e.yml +++ b/.github/workflows/fireperf-e2e.yml @@ -1,8 +1,10 @@ name: FirePerf E2E Tests on: + pull_request: schedule: - cron: 4 */4 * * * # every 4 hours at 04 minutes past the hour + workflow_dispatch: # allow triggering the workflow manually concurrency: group: ${{ github.workflow }} @@ -12,8 +14,11 @@ env: FTL_RESULTS_BUCKET: fireescape jobs: - prod: + test: runs-on: ubuntu-latest + strategy: + matrix: + environment: [ prod, autopush ] steps: - name: Checkout firebase-android-sdk uses: actions/checkout@v3 @@ -51,45 +56,53 @@ jobs: - name: Add google-services.json run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json - name: Run fireperf end-to-end tests - run: fireci fireperf_e2e_test --plugin_repo_dir=firebase-android-buildtools --target_environment=prod - - autopush: - runs-on: ubuntu-latest - steps: - - name: Checkout firebase-android-sdk - uses: actions/checkout@v3 - - name: Checkout firebase-android-buildtools - uses: actions/checkout@v3 - with: - repository: FirebasePrivate/firebase-android-buildtools - token: ${{ secrets.GOOGLE_OSS_BOT_TOKEN }} - path: firebase-android-buildtools - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: 11 - distribution: temurin - cache: gradle - - name: Set up NDK 21.4.7075529 run: | - ANDROID_ROOT=/usr/local/lib/android - ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk - ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle - SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager - echo "y" | $SDKMANAGER "ndk;21.4.7075529" - ln -sfn ${ANDROID_SDK_ROOT}/ndk/21.4.7075529 ${ANDROID_NDK_ROOT} - echo "ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}" >> $GITHUB_ENV - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Set up fireci - run: pip3 install -e ci/fireci - - uses: google-github-actions/auth@v0 + fireci fireperf_e2e_test \ + --plugin_repo_dir=firebase-android-buildtools \ + --target_environment=${{ matrix.environment }} + - name: Notify developers upon failures + if: ${{ failure() }} + uses: actions/github-script@v6 with: - credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} - - uses: google-github-actions/setup-gcloud@v0 - - name: Add google-services.json - run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json - - name: Run fireperf end-to-end tests - run: fireci fireperf_e2e_test --plugin_repo_dir=firebase-android-buildtools --target_environment=autopush + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const commit = context.sha; + const run = context.runId; + const url = `https://github.com/${owner}/${repo}/actions/runs/${run}`; + + const datetime = (new Date()).toLocaleString('en-US', { + timeZone: 'America/Los_Angeles', + dateStyle: 'medium', + timeStyle: 'long', + }); + + const text = + `Failed on commit ${commit} at ${datetime}. + + ${url}`; + + const { data: issues } = await github.rest.issues.listForRepo({ + owner: owner, + repo: repo, + state: 'open', + labels: 'fireperf-e2e-tests' + }); + + if (issues.length) { + github.rest.issues.createComment({ + owner: owner, + repo: repo, + issue_number: issues[0].number, + body: text, + }); + } else { + github.rest.issues.create({ + owner: owner, + repo: repo, + title: 'FirePerf E2E Test Failures', + body: text, + labels: ['fireperf-e2e-tests'], + assignees: ['jeremyjiang-dev', 'leotianlizhan', 'visumickey'] + }); + } From 006d3bbcfff497c8b830fec1f0f1d9f0fa039cca Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Thu, 11 Aug 2022 09:42:21 -0700 Subject: [PATCH 4/6] test notification --- .github/workflows/fireperf-e2e.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml index 663a1863d24..c88c7eb7968 100644 --- a/.github/workflows/fireperf-e2e.yml +++ b/.github/workflows/fireperf-e2e.yml @@ -57,9 +57,10 @@ jobs: run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json - name: Run fireperf end-to-end tests run: | - fireci fireperf_e2e_test \ - --plugin_repo_dir=firebase-android-buildtools \ - --target_environment=${{ matrix.environment }} + # fireci fireperf_e2e_test \ + # --plugin_repo_dir=firebase-android-buildtools \ + # --target_environment=${{ matrix.environment }} + exit 1 - name: Notify developers upon failures if: ${{ failure() }} uses: actions/github-script@v6 @@ -78,7 +79,9 @@ jobs: }); const text = - `Failed on commit ${commit} at ${datetime}. + `Notification testing. Please ignore. + + Failed on commit ${commit} at ${datetime}. ${url}`; @@ -100,7 +103,7 @@ jobs: github.rest.issues.create({ owner: owner, repo: repo, - title: 'FirePerf E2E Test Failures', + title: 'Notification Testing: FirePerf E2E Test Failures', body: text, labels: ['fireperf-e2e-tests'], assignees: ['jeremyjiang-dev', 'leotianlizhan', 'visumickey'] From fb1a73f2e8a25b8cb13f5453f942987c41da5892 Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Thu, 11 Aug 2022 09:54:45 -0700 Subject: [PATCH 5/6] remove pull_request trigger --- .github/workflows/fireperf-e2e.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml index c88c7eb7968..3199eaf73ab 100644 --- a/.github/workflows/fireperf-e2e.yml +++ b/.github/workflows/fireperf-e2e.yml @@ -1,7 +1,6 @@ name: FirePerf E2E Tests on: - pull_request: schedule: - cron: 4 */4 * * * # every 4 hours at 04 minutes past the hour workflow_dispatch: # allow triggering the workflow manually @@ -57,10 +56,9 @@ jobs: run: echo $PERF_E2E_GOOGLE_SERVICES | base64 -d > google-services.json - name: Run fireperf end-to-end tests run: | - # fireci fireperf_e2e_test \ - # --plugin_repo_dir=firebase-android-buildtools \ - # --target_environment=${{ matrix.environment }} - exit 1 + fireci fireperf_e2e_test \ + --plugin_repo_dir=firebase-android-buildtools \ + --target_environment=${{ matrix.environment }} - name: Notify developers upon failures if: ${{ failure() }} uses: actions/github-script@v6 @@ -79,9 +77,7 @@ jobs: }); const text = - `Notification testing. Please ignore. - - Failed on commit ${commit} at ${datetime}. + `Failed on commit ${commit} at ${datetime}. ${url}`; @@ -103,7 +99,7 @@ jobs: github.rest.issues.create({ owner: owner, repo: repo, - title: 'Notification Testing: FirePerf E2E Test Failures', + title: 'FirePerf E2E Test Failures', body: text, labels: ['fireperf-e2e-tests'], assignees: ['jeremyjiang-dev', 'leotianlizhan', 'visumickey'] From 0dece9d6454ba421cccd40a45a3c4827a396f201 Mon Sep 17 00:00:00 2001 From: Yifan Yang Date: Thu, 11 Aug 2022 14:17:55 -0700 Subject: [PATCH 6/6] add @raymondlam to assignee list --- .github/workflows/fireperf-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fireperf-e2e.yml b/.github/workflows/fireperf-e2e.yml index 3199eaf73ab..c754b7c718d 100644 --- a/.github/workflows/fireperf-e2e.yml +++ b/.github/workflows/fireperf-e2e.yml @@ -102,6 +102,6 @@ jobs: title: 'FirePerf E2E Test Failures', body: text, labels: ['fireperf-e2e-tests'], - assignees: ['jeremyjiang-dev', 'leotianlizhan', 'visumickey'] + assignees: ['jeremyjiang-dev', 'leotianlizhan', 'raymondlam', 'visumickey'] }); }