From 38a9b6939a19eddd04cc366f26f3cef4e077a9c2 Mon Sep 17 00:00:00 2001 From: Rd Date: Thu, 15 Aug 2024 14:38:49 +0530 Subject: [PATCH] Test as upload worked --- .github/workflows/build_tests.yml | 1364 ++++++++++---------- .github/workflows/code_coverage.yml | 11 +- .github/workflows/issue_checks.yml | 102 +- .github/workflows/main.yml | 332 ++--- .github/workflows/repository_messaging.yml | 48 +- .github/workflows/unit_tests.yml | 670 +++++----- 6 files changed, 1263 insertions(+), 1264 deletions(-) diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 1f293b1282b..7034b6907cc 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -1,682 +1,682 @@ -# Contains jobs corresponding to build tests (such as verifying that certain targets build, including the app itself). - -name: Build Tests - -on: - workflow_dispatch: - pull_request: - push: - branches: - # Push events on develop branch - - develop - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - bazel_build_app: - name: Build Binary with Bazel - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Check Bazel environment - run: bazel info - - # See https://git-secret.io/installation for details on installing git-secret. Note that the - # apt-get method isn't used since it's much slower to update & upgrade apt before installation - # versus just directly cloning & installing the project. Further, the specific version - # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. - # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # Note that caching only works on non-forks. - - name: Build Oppia binary (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia - - - name: Build Oppia binary (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build -- //:oppia - - # Note that caching only works on non-forks. - - name: Build Oppia KitKat binary (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_kitkat - - - name: Build Oppia binary KitKat (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build -- //:oppia_kitkat - - - name: Copy Oppia dev APKs for uploading - run: | - cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - - - uses: actions/upload-artifact@v2 - with: - name: oppia-bazel.apk - path: /home/runner/work/oppia-android/oppia-android/oppia.apk - - build_oppia_dev_aab: - name: Build Oppia AAB (developer flavors) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Check Bazel environment - run: bazel info - - # See https://git-secret.io/installation for details on installing git-secret. Note that the - # apt-get method isn't used since it's much slower to update & upgrade apt before installation - # versus just directly cloning & installing the project. Further, the specific version - # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. - # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # Note that caching only works on non-forks. - - name: Build Oppia developer AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_dev - - - name: Build Oppia developer AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build -- //:oppia_dev - - # Note that caching only works on non-forks. - - name: Build Oppia developer KitKat AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_dev_kitkat - - - name: Build Oppia developer KitKat AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build -- //:oppia_dev_kitkat - - build_oppia_alpha_aab: - name: Build Oppia AAB (alpha flavors) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Check Bazel environment - run: bazel info - - # See https://git-secret.io/installation for details on installing git-secret. Note that the - # apt-get method isn't used since it's much slower to update & upgrade apt before installation - # versus just directly cloning & installing the project. Further, the specific version - # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. - # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # Note that caching only works on non-forks. - - name: Build Oppia alpha AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha - - - name: Build Oppia alpha AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build --compilation_mode=opt -- //:oppia_alpha - - # Note that caching only works on non-forks. - - name: Build Oppia alpha KitKat AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha_kitkat - - - name: Build Oppia alpha KitKat AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build --compilation_mode=opt -- //:oppia_alpha_kitkat - - # Note that caching only works on non-forks. - - name: Build Oppia alpha Kenya-specific AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha_kenya - - - name: Build Oppia alpha Kenya-specific AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build --compilation_mode=opt -- //:oppia_alpha_kenya - - build_oppia_beta_aab: - name: Build Oppia AAB (beta flavor) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Check Bazel environment - run: bazel info - - # See https://git-secret.io/installation for details on installing git-secret. Note that the - # apt-get method isn't used since it's much slower to update & upgrade apt before installation - # versus just directly cloning & installing the project. Further, the specific version - # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. - # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # Note that caching only works on non-forks. - - name: Build Oppia beta AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_beta - - - name: Build Oppia beta AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build --compilation_mode=opt -- //:oppia_beta - - build_oppia_ga_aab: - name: Build Oppia AAB (GA flavor) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Check Bazel environment - run: bazel info - - # See https://git-secret.io/installation for details on installing git-secret. Note that the - # apt-get method isn't used since it's much slower to update & upgrade apt before installation - # versus just directly cloning & installing the project. Further, the specific version - # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. - # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # Note that caching only works on non-forks. - - name: Build Oppia GA AAB (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: | - bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_ga - - - name: Build Oppia GA AAB (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} - run: | - bazel build --compilation_mode=opt -- //:oppia_ga +## Contains jobs corresponding to build tests (such as verifying that certain targets build, including the app itself). +# +#name: Build Tests +# +#on: +# workflow_dispatch: +# pull_request: +# push: +# branches: +# # Push events on develop branch +# - develop +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +#jobs: +# bazel_build_app: +# name: Build Binary with Bazel +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Check Bazel environment +# run: bazel info +# +# # See https://git-secret.io/installation for details on installing git-secret. Note that the +# # apt-get method isn't used since it's much slower to update & upgrade apt before installation +# # versus just directly cloning & installing the project. Further, the specific version +# # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. +# # This also uses a different directory to install git-secret to avoid requiring root access +# # when running the git secret command. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # Note that caching only works on non-forks. +# - name: Build Oppia binary (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia +# +# - name: Build Oppia binary (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build -- //:oppia +# +# # Note that caching only works on non-forks. +# - name: Build Oppia KitKat binary (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_kitkat +# +# - name: Build Oppia binary KitKat (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build -- //:oppia_kitkat +# +# - name: Copy Oppia dev APKs for uploading +# run: | +# cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ +# +# - uses: actions/upload-artifact@v2 +# with: +# name: oppia-bazel.apk +# path: /home/runner/work/oppia-android/oppia-android/oppia.apk +# +# build_oppia_dev_aab: +# name: Build Oppia AAB (developer flavors) +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Check Bazel environment +# run: bazel info +# +# # See https://git-secret.io/installation for details on installing git-secret. Note that the +# # apt-get method isn't used since it's much slower to update & upgrade apt before installation +# # versus just directly cloning & installing the project. Further, the specific version +# # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. +# # This also uses a different directory to install git-secret to avoid requiring root access +# # when running the git secret command. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # Note that caching only works on non-forks. +# - name: Build Oppia developer AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_dev +# +# - name: Build Oppia developer AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build -- //:oppia_dev +# +# # Note that caching only works on non-forks. +# - name: Build Oppia developer KitKat AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_dev_kitkat +# +# - name: Build Oppia developer KitKat AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build -- //:oppia_dev_kitkat +# +# build_oppia_alpha_aab: +# name: Build Oppia AAB (alpha flavors) +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Check Bazel environment +# run: bazel info +# +# # See https://git-secret.io/installation for details on installing git-secret. Note that the +# # apt-get method isn't used since it's much slower to update & upgrade apt before installation +# # versus just directly cloning & installing the project. Further, the specific version +# # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. +# # This also uses a different directory to install git-secret to avoid requiring root access +# # when running the git secret command. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # Note that caching only works on non-forks. +# - name: Build Oppia alpha AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha +# +# - name: Build Oppia alpha AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build --compilation_mode=opt -- //:oppia_alpha +# +# # Note that caching only works on non-forks. +# - name: Build Oppia alpha KitKat AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha_kitkat +# +# - name: Build Oppia alpha KitKat AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build --compilation_mode=opt -- //:oppia_alpha_kitkat +# +# # Note that caching only works on non-forks. +# - name: Build Oppia alpha Kenya-specific AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_alpha_kenya +# +# - name: Build Oppia alpha Kenya-specific AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build --compilation_mode=opt -- //:oppia_alpha_kenya +# +# build_oppia_beta_aab: +# name: Build Oppia AAB (beta flavor) +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Check Bazel environment +# run: bazel info +# +# # See https://git-secret.io/installation for details on installing git-secret. Note that the +# # apt-get method isn't used since it's much slower to update & upgrade apt before installation +# # versus just directly cloning & installing the project. Further, the specific version +# # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. +# # This also uses a different directory to install git-secret to avoid requiring root access +# # when running the git secret command. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # Note that caching only works on non-forks. +# - name: Build Oppia beta AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_beta +# +# - name: Build Oppia beta AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build --compilation_mode=opt -- //:oppia_beta +# +# build_oppia_ga_aab: +# name: Build Oppia AAB (GA flavor) +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Check Bazel environment +# run: bazel info +# +# # See https://git-secret.io/installation for details on installing git-secret. Note that the +# # apt-get method isn't used since it's much slower to update & upgrade apt before installation +# # versus just directly cloning & installing the project. Further, the specific version +# # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. +# # This also uses a different directory to install git-secret to avoid requiring root access +# # when running the git secret command. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # Note that caching only works on non-forks. +# - name: Build Oppia GA AAB (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# run: | +# bazel build --compilation_mode=opt --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia_ga +# +# - name: Build Oppia GA AAB (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || github.event.pull_request.head.repo.full_name != 'oppia/oppia-android' }} +# run: | +# bazel build --compilation_mode=opt -- //:oppia_ga diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 083eadd31fe..e18bb57d44e 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -3,10 +3,9 @@ name: Code Coverage # Controls when the action will run. Triggers the workflow on pull request -# events or push events in the develop branch +# events or push events in the develop branch. on: - pull_request_target: - types: [opened, synchronize, reopened] + pull_request: push: branches: # Push events on develop branch @@ -115,7 +114,7 @@ jobs: strategy: fail-fast: false max-parallel: 10 -# matrix: ${{ fromJson(needs.compute_changed_files.outputs.matrix) }} + matrix: ${{ fromJson(needs.compute_changed_files.outputs.matrix) }} env: CACHE_DIRECTORY: ~/.bazel_cache steps: @@ -248,7 +247,7 @@ jobs: CHANGED_FILES: ${{ env.CHANGED_FILES }} run: | echo "CHANGED FILES: $CHANGED_FILES" - bazel run //scripts:run_coverage -- $(pwd) utility/src/main/java/org/oppia/android/util/parser/math/MathModel.kt --format=PROTO --processTimeout=15 + bazel run //scripts:run_coverage -- $(pwd) $CHANGED_FILES --format=PROTO --processTimeout=15 - name: Upload Coverage Report Artifact uses: actions/upload-artifact@v4 @@ -269,7 +268,7 @@ jobs: uses: actions/download-artifact@v4 with: path: coverage-report-artifact - pattern: coverage-report-* + pattern: coverage-report merge-multiple: true - name: Filter Coverage Reports diff --git a/.github/workflows/issue_checks.yml b/.github/workflows/issue_checks.yml index a810002a8e2..8f4093c8818 100644 --- a/.github/workflows/issue_checks.yml +++ b/.github/workflows/issue_checks.yml @@ -1,51 +1,51 @@ -# Contains jobs corresponding to issue related checks. - -name: Issue Checks - -on: - issues: - types: [closed, reopened] - -permissions: - issues: write - -jobs: - script_check: - name: Closed TODO Issue Check - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - name: TODO Issue Resolved Check - id: todoIssueResolvedCheck - if: ${{ github.event.action == 'closed' }} - run: | - bazel run //scripts:todo_issue_resolved_check -- $(pwd) ${{ github.event.issue.number }} ${{ github.sha }} - - - name: Reopen Issue - if: failure() && steps.todoIssueResolvedCheck.outcome == 'failure' - env: - GITHUB_TOKEN: ${{ github.token }} - run: | - gh issue reopen ${{ github.event.issue.number }} - - - name: Check for duplicate comment - id: duplicateCommentCheck - if: failure() && steps.todoIssueResolvedCheck.outcome == 'failure' - env: - GITHUB_TOKEN: ${{ github.token }} - run: | - gh issue view ${{ github.event.issue.number }} --json comments --jq '.comments[-1].body' > $(pwd)/latest_comment.txt - bazel run //scripts:todo_issue_comment_check -- $(pwd) latest_comment.txt script_failures.txt - - - name: Add Comment - if: failure() && steps.duplicateCommentCheck.outcome == 'failure' - env: - GITHUB_TOKEN: ${{ github.token }} - run: | - gh issue comment ${{ github.event.issue.number }} -F $(pwd)/script_failures.txt +## Contains jobs corresponding to issue related checks. +# +#name: Issue Checks +# +#on: +# issues: +# types: [closed, reopened] +# +#permissions: +# issues: write +# +#jobs: +# script_check: +# name: Closed TODO Issue Check +# runs-on: ubuntu-20.04 +# steps: +# - uses: actions/checkout@v2 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - name: TODO Issue Resolved Check +# id: todoIssueResolvedCheck +# if: ${{ github.event.action == 'closed' }} +# run: | +# bazel run //scripts:todo_issue_resolved_check -- $(pwd) ${{ github.event.issue.number }} ${{ github.sha }} +# +# - name: Reopen Issue +# if: failure() && steps.todoIssueResolvedCheck.outcome == 'failure' +# env: +# GITHUB_TOKEN: ${{ github.token }} +# run: | +# gh issue reopen ${{ github.event.issue.number }} +# +# - name: Check for duplicate comment +# id: duplicateCommentCheck +# if: failure() && steps.todoIssueResolvedCheck.outcome == 'failure' +# env: +# GITHUB_TOKEN: ${{ github.token }} +# run: | +# gh issue view ${{ github.event.issue.number }} --json comments --jq '.comments[-1].body' > $(pwd)/latest_comment.txt +# bazel run //scripts:todo_issue_comment_check -- $(pwd) latest_comment.txt script_failures.txt +# +# - name: Add Comment +# if: failure() && steps.duplicateCommentCheck.outcome == 'failure' +# env: +# GITHUB_TOKEN: ${{ github.token }} +# run: | +# gh issue comment ${{ github.event.issue.number }} -F $(pwd)/script_failures.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed6cd752264..14dbc98914d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,166 +1,166 @@ -# Contains jobs corresponding to Gradle tests (particularly Robolectric unit tests). - -name: Unit Tests (Robolectric -- Gradle) - -# Controls when the action will run. Triggers the workflow on pull request -# events or push events in the develop branch. -on: - workflow_dispatch: - pull_request: - push: - branches: - # Push events on develop branch - - develop - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -# This workflow has the following jobs: -# robolectric_tests: Robolectric tests for all modules except the app module -# app_tests: Non-flaky Robolectric tests for the app module -jobs: - robolectric_tests: - name: Non-app Module Robolectric Tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - id: cache - with: - path: ~/.gradle - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }} - - - name: Set up JDK 1.9 - uses: actions/setup-java@v1 - with: - java-version: 1.9 - - - name: Check Java version & path - run: | - which java - java -version - echo "Java home: $JAVA_HOME" - $JAVA_HOME/bin/java -version - - - name: Install Dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: ./gradlew --full-stacktrace androidDependencies -Dorg.gradle.java.home=$JAVA_HOME - - - name: Check Gradle environment - run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v - - - name: Build App - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: sudo ./gradlew --full-stacktrace assembleDebug -Dorg.gradle.java.home=$JAVA_HOME - - - name: Utility tests - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - - name: Upload Utility Test Reports - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status - with: - name: utility reports - path: utility/build/reports - - - name: Data tests - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: sudo ./gradlew --full-stacktrace :data:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - - name: Upload Data Test Reports - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status - with: - name: data reports - path: data/build/reports - - - name: Domain tests - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - - name: Upload Domain Test Reports - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status - with: - name: domain reports - path: domain/build/reports - - - name: Testing tests - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME - - name: Upload Testing Test Reports - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status - with: - name: testing reports - path: testing/build/reports - - run_app_module_test: - name: Run app module Robolectric test shard - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - shard: [shard0, shard1, shard2, shard3, shard4, shard5, shard6, shard7] - steps: - - uses: actions/checkout@v2 - - - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }} - - - name: Set up JDK 1.9 - uses: actions/setup-java@v1 - with: - java-version: 1.9 - - - name: Check Java version & path - run: | - which java - java -version - echo "Java home: $JAVA_HOME" - $JAVA_HOME/bin/java -version - - - name: Check Gradle environment - run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v - - - name: Robolectric tests - App Module - # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 - run: | - sudo ./gradlew --full-stacktrace :app:testDebugUnitTest --${{ matrix.shard }} -Dorg.gradle.java.home=$JAVA_HOME - - name: Upload App Test Reports - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status - with: - name: app reports ${{ matrix.shard }} - path: app/build/reports - - app_tests: - name: App Module Robolectric Tests - needs: run_app_module_test - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - steps: - - name: Check tests passed (for tests that ran) - if: ${{ needs.run_app_module_test.result != 'success' }} - run: exit 1 +## Contains jobs corresponding to Gradle tests (particularly Robolectric unit tests). +# +#name: Unit Tests (Robolectric -- Gradle) +# +## Controls when the action will run. Triggers the workflow on pull request +## events or push events in the develop branch. +#on: +# workflow_dispatch: +# pull_request: +# push: +# branches: +# # Push events on develop branch +# - develop +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +## This workflow has the following jobs: +## robolectric_tests: Robolectric tests for all modules except the app module +## app_tests: Non-flaky Robolectric tests for the app module +#jobs: +# robolectric_tests: +# name: Non-app Module Robolectric Tests +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/cache@v2 +# id: cache +# with: +# path: ~/.gradle +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }} +# +# - name: Set up JDK 1.9 +# uses: actions/setup-java@v1 +# with: +# java-version: 1.9 +# +# - name: Check Java version & path +# run: | +# which java +# java -version +# echo "Java home: $JAVA_HOME" +# $JAVA_HOME/bin/java -version +# +# - name: Install Dependencies +# if: steps.cache.outputs.cache-hit != 'true' +# run: ./gradlew --full-stacktrace androidDependencies -Dorg.gradle.java.home=$JAVA_HOME +# +# - name: Check Gradle environment +# run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v +# +# - name: Build App +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: sudo ./gradlew --full-stacktrace assembleDebug -Dorg.gradle.java.home=$JAVA_HOME +# +# - name: Utility tests +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME +# - name: Upload Utility Test Reports +# uses: actions/upload-artifact@v2 +# if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status +# with: +# name: utility reports +# path: utility/build/reports +# +# - name: Data tests +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: sudo ./gradlew --full-stacktrace :data:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME +# - name: Upload Data Test Reports +# uses: actions/upload-artifact@v2 +# if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status +# with: +# name: data reports +# path: data/build/reports +# +# - name: Domain tests +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME +# - name: Upload Domain Test Reports +# uses: actions/upload-artifact@v2 +# if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status +# with: +# name: domain reports +# path: domain/build/reports +# +# - name: Testing tests +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: sudo ./gradlew --full-stacktrace :testing:testDebugUnitTest -Dorg.gradle.java.home=$JAVA_HOME +# - name: Upload Testing Test Reports +# uses: actions/upload-artifact@v2 +# if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status +# with: +# name: testing reports +# path: testing/build/reports +# +# run_app_module_test: +# name: Run app module Robolectric test shard +# runs-on: ubuntu-20.04 +# strategy: +# fail-fast: false +# matrix: +# shard: [shard0, shard1, shard2, shard3, shard4, shard5, shard6, shard7] +# steps: +# - uses: actions/checkout@v2 +# +# - uses: actions/cache@v2 +# with: +# path: ~/.gradle/caches +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }} +# +# - name: Set up JDK 1.9 +# uses: actions/setup-java@v1 +# with: +# java-version: 1.9 +# +# - name: Check Java version & path +# run: | +# which java +# java -version +# echo "Java home: $JAVA_HOME" +# $JAVA_HOME/bin/java -version +# +# - name: Check Gradle environment +# run: ./gradlew -Dorg.gradle.java.home=$JAVA_HOME -v +# +# - name: Robolectric tests - App Module +# # We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58 +# run: | +# sudo ./gradlew --full-stacktrace :app:testDebugUnitTest --${{ matrix.shard }} -Dorg.gradle.java.home=$JAVA_HOME +# - name: Upload App Test Reports +# uses: actions/upload-artifact@v2 +# if: ${{ !cancelled() }} # IMPORTANT: Upload reports regardless of success or failure status +# with: +# name: app reports ${{ matrix.shard }} +# path: app/build/reports +# +# app_tests: +# name: App Module Robolectric Tests +# needs: run_app_module_test +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# runs-on: ${{ matrix.os }} +# strategy: +# matrix: +# os: [ubuntu-20.04] +# steps: +# - name: Check tests passed (for tests that ran) +# if: ${{ needs.run_app_module_test.result != 'success' }} +# run: exit 1 diff --git a/.github/workflows/repository_messaging.yml b/.github/workflows/repository_messaging.yml index c6d9e0f0a0a..ef6660dfb26 100644 --- a/.github/workflows/repository_messaging.yml +++ b/.github/workflows/repository_messaging.yml @@ -1,24 +1,24 @@ -# Contains jobs corresponding to repository-wide messaging. - -name: Repository Messaging - -on: - pull_request_target: - types: [ opened ] - -jobs: - holiday_message: - runs-on: ubuntu-latest - # NOTE TO DEVELOPERS: Update the body text and set this to 'true' to enable automatic messaging on all new PRs. - if: false - steps: - - name: Add holiday comment - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - Thanks for submitting this pull request! Some main reviewers - have taken time off for the next few weeks, so it may take a - little while before we can look at this PR. We appreciate your - patience while some of our team members recharge. We'll be fully - returning on 10 January 2022. +## Contains jobs corresponding to repository-wide messaging. +# +#name: Repository Messaging +# +#on: +# pull_request_target: +# types: [ opened ] +# +#jobs: +# holiday_message: +# runs-on: ubuntu-latest +# # NOTE TO DEVELOPERS: Update the body text and set this to 'true' to enable automatic messaging on all new PRs. +# if: false +# steps: +# - name: Add holiday comment +# uses: peter-evans/create-or-update-comment@v1 +# with: +# issue-number: ${{ github.event.pull_request.number }} +# body: | +# Thanks for submitting this pull request! Some main reviewers +# have taken time off for the next few weeks, so it may take a +# little while before we can look at this PR. We appreciate your +# patience while some of our team members recharge. We'll be fully +# returning on 10 January 2022. diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f59a5b9bee7..80b47599053 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -1,335 +1,335 @@ -# Contains jobs corresponding to unit tests. Integration (e.g. emulator or screenshot testing) or End-to-End tests should not be triggered here. - -name: Unit Tests (Robolectric - Bazel) - -# Controls when the action will run. Triggers the workflow on pull request -# events or push events in the develop branch. -on: - workflow_dispatch: - pull_request: - push: - branches: - # Push events on develop branch - - develop - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - bazel_compute_affected_targets: - name: Compute affected tests - runs-on: ubuntu-20.04 - outputs: - matrix: ${{ steps.compute-test-matrix.outputs.matrix }} - can_skip_tests: ${{ steps.compute-test-matrix.outputs.can_skip_tests }} - env: - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - uses: actions/cache@v2 - id: scripts_cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Compute test matrix - id: compute-test-matrix - env: - compute_all_targets: ${{ contains(github.event.pull_request.title, '[RunAllTests]') }} - # See: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request. Defer to origin/develop outside a PR (such as develop's main CI runs). - base_commit_hash: ${{ github.event.pull_request.base.sha || 'origin/develop' }} - # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly - # comma-separated list of test targets for the matrix. - run: | - bazel run //scripts:compute_affected_tests -- $(pwd) $(pwd)/affected_targets.log $base_commit_hash compute_all_tests=$compute_all_targets - TEST_BUCKET_LIST=$(cat ./affected_targets.log | sed 's/^\|$/"/g' | paste -sd, -) - echo "Affected tests (note that this might be all tests if configured to run all or on the develop branch): $TEST_BUCKET_LIST" - echo "::set-output name=matrix::{\"affected-tests-bucket-base64-encoded-shard\":[$TEST_BUCKET_LIST]}" - if [[ ! -z "$TEST_BUCKET_LIST" ]]; then - echo "::set-output name=can_skip_tests::false" - else - echo "::set-output name=can_skip_tests::true" - echo "No tests are detected as affected by this change. If this is wrong, you can add '[RunAllTests]' to the PR title to force a run." - fi - - bazel_run_test: - name: Run Bazel Test - needs: bazel_compute_affected_targets - if: ${{ needs.bazel_compute_affected_targets.outputs.can_skip_tests != 'true' }} - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - max-parallel: 10 - matrix: ${{ fromJson(needs.bazel_compute_affected_targets.outputs.matrix) }} - env: - ENABLE_CACHING: false - CACHE_DIRECTORY: ~/.bazel_cache - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Set up Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 6.5.0 - - - uses: actions/cache@v2 - id: scripts_cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - - name: Set up build environment - uses: ./.github/actions/set-up-android-bazel-build-environment - - - name: Configure Bazel to use a local cache (for scripts) - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - - name: Extract test caching bucket & targets - env: - AFFECTED_TESTS_BUCKET_BASE64_ENCODED_SHARD: ${{ matrix.affected-tests-bucket-base64-encoded-shard }} - run: | - # See https://stackoverflow.com/a/29903172 for cut logic. This is needed to remove the - # user-friendly shard prefix from the matrix value. - AFFECTED_TESTS_BUCKET_BASE64=$(echo "$AFFECTED_TESTS_BUCKET_BASE64_ENCODED_SHARD" | cut -d ";" -f 2) - bazel run //scripts:retrieve_affected_tests -- $AFFECTED_TESTS_BUCKET_BASE64 $(pwd)/test_bucket_name $(pwd)/bazel_test_targets - TEST_CATEGORY=$(cat ./test_bucket_name) - BAZEL_TEST_TARGETS=$(cat ./bazel_test_targets) - echo "Test category: $TEST_CATEGORY" - echo "Bazel test targets: $BAZEL_TEST_TARGETS" - echo "TEST_CACHING_BUCKET=$TEST_CATEGORY" >> $GITHUB_ENV - echo "BAZEL_TEST_TARGETS=$BAZEL_TEST_TARGETS" >> $GITHUB_ENV - - # For reference on this & the later cache actions, see: - # https://github.com/actions/cache/issues/239#issuecomment-606950711 & - # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work - # with Bazel since Bazel can share the most recent cache from an unrelated build and still - # benefit from incremental build performance (assuming that actions/cache aggressively removes - # older caches due to the 5GB cache limit size & Bazel's large cache size). - - uses: actions/cache@v2 - id: test_cache - with: - path: ${{ env.CACHE_DIRECTORY }} - key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests-${{ env.TEST_CACHING_BUCKET }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests-${{ env.TEST_CACHING_BUCKET }}- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- - ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- - - # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a - # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) - # thereby only ever using the last successful cache version. This solution will result in a - # few slower CI actions around the time cache is detected to be too large, but it should - # incrementally improve thereafter. - - name: Ensure cache size - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - # See https://stackoverflow.com/a/27485157 for reference. - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) - echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" - # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem - # to only increase by a few hundred megabytes across changes for unrelated branches. This - # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build - # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB - # compressed cache). - if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then - echo "Cache exceeds cut-off; resetting it (will result in a slow build)" - rm -rf $EXPANDED_BAZEL_CACHE_PATH - fi - - - name: Configure Bazel to use a local cache (for tests) - env: - BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} - run: | - EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" - echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" - echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc - shell: bash - - # See explanation in bazel_build_app for how this is installed. - - name: Install git-secret (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - - name: Decrypt secrets (non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - # See https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/ for for-loop reference. - - name: Build Oppia Tests (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} - run: | - # Attempt to build 5 times in case there are flaky builds. - # TODO(#3759): Remove this once there are no longer app test build failures. - i=0 - # Disable exit-on-first-failure. - set +e - while [ $i -ne 5 ]; do - i=$(( $i+1 )) - echo "Attempt $i/5 to build test targets" - bazel build --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS - done - # Capture the error code of the final command run (which should be a success if there isn't a real build failure). - last_error_code=$? - # Reenable exit-on-first-failure. - set -e - # Exit only if the most recent exit was a failure (by using a subshell). - (exit $last_error_code) - - - name: Build Oppia Tests (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }} - env: - BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} - run: | - # Attempt to build 5 times in case there are flaky builds. - # TODO(#3759): Remove this once there are no longer app test build failures. - i=0 - # Disable exit-on-first-failure. - set +e - while [ $i -ne 5 ]; do - i=$(( $i+1 )) - echo "Attempt $i/5 to build test targets" - bazel build --keep_going -- $BAZEL_TEST_TARGETS - done - # Capture the error code of the final command run (which should be a success if there isn't a real build failure). - last_error_code=$? - # Reenable exit-on-first-failure. - set -e - # Exit only if the most recent exit was a failure (by using a subshell). - (exit $last_error_code) - - name: Run Oppia Tests (with caching, non-fork only) - if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} - run: | - # Attempt to build 5 times in case there are flaky builds. - # TODO(#3970): Remove this once there are no longer app test build failures. - i=0 - # Disable exit-on-first-failure. - set +e - while [ $i -ne 5 ]; do - i=$(( $i+1 )) - echo "Attempt $i/5 to run test targets" - bazel test --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS - done - # Capture the error code of the final command run (which should be a success if there isn't a real build failure). - last_error_code=$? - # Reenable exit-on-first-failure. - set -e - # Exit only if the most recent exit was a failure (by using a subshell). - (exit $last_error_code) - - name: Run Oppia Tests (without caching, or on a fork) - if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }} - env: - BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} - run: | - # Attempt to build 5 times in case there are flaky builds. - # TODO(#3970): Remove this once there are no longer app test build failures. - i=0 - # Disable exit-on-first-failure. - set +e - while [ $i -ne 5 ]; do - i=$(( $i+1 )) - echo "Attempt $i/5 to run test targets" - bazel test --keep_going -- $BAZEL_TEST_TARGETS - done - # Capture the error code of the final command run (which should be a success if there isn't a real build failure). - last_error_code=$? - # Reenable exit-on-first-failure. - set -e - # Exit only if the most recent exit was a failure (by using a subshell). - (exit $last_error_code) - - # Reference: https://github.community/t/127354/7. - check_test_results: - name: Check Bazel Test Results - needs: [bazel_compute_affected_targets, bazel_run_test] - # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, - # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. - if: ${{ !cancelled() }} - runs-on: ubuntu-20.04 - steps: - # This step will be skipped if there are no tests to run, so the overall job should pass. - - name: Check tests passed (for tests that ran) - if: ${{ needs.bazel_compute_affected_targets.outputs.can_skip_tests != 'true' && needs.bazel_run_test.result != 'success' }} - run: exit 1 +## Contains jobs corresponding to unit tests. Integration (e.g. emulator or screenshot testing) or End-to-End tests should not be triggered here. +# +#name: Unit Tests (Robolectric - Bazel) +# +## Controls when the action will run. Triggers the workflow on pull request +## events or push events in the develop branch. +#on: +# workflow_dispatch: +# pull_request: +# push: +# branches: +# # Push events on develop branch +# - develop +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: true +# +#jobs: +# bazel_compute_affected_targets: +# name: Compute affected tests +# runs-on: ubuntu-20.04 +# outputs: +# matrix: ${{ steps.compute-test-matrix.outputs.matrix }} +# can_skip_tests: ${{ steps.compute-test-matrix.outputs.can_skip_tests }} +# env: +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - uses: actions/cache@v2 +# id: scripts_cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Compute test matrix +# id: compute-test-matrix +# env: +# compute_all_targets: ${{ contains(github.event.pull_request.title, '[RunAllTests]') }} +# # See: https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request. Defer to origin/develop outside a PR (such as develop's main CI runs). +# base_commit_hash: ${{ github.event.pull_request.base.sha || 'origin/develop' }} +# # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly +# # comma-separated list of test targets for the matrix. +# run: | +# bazel run //scripts:compute_affected_tests -- $(pwd) $(pwd)/affected_targets.log $base_commit_hash compute_all_tests=$compute_all_targets +# TEST_BUCKET_LIST=$(cat ./affected_targets.log | sed 's/^\|$/"/g' | paste -sd, -) +# echo "Affected tests (note that this might be all tests if configured to run all or on the develop branch): $TEST_BUCKET_LIST" +# echo "::set-output name=matrix::{\"affected-tests-bucket-base64-encoded-shard\":[$TEST_BUCKET_LIST]}" +# if [[ ! -z "$TEST_BUCKET_LIST" ]]; then +# echo "::set-output name=can_skip_tests::false" +# else +# echo "::set-output name=can_skip_tests::true" +# echo "No tests are detected as affected by this change. If this is wrong, you can add '[RunAllTests]' to the PR title to force a run." +# fi +# +# bazel_run_test: +# name: Run Bazel Test +# needs: bazel_compute_affected_targets +# if: ${{ needs.bazel_compute_affected_targets.outputs.can_skip_tests != 'true' }} +# runs-on: ubuntu-20.04 +# strategy: +# fail-fast: false +# max-parallel: 10 +# matrix: ${{ fromJson(needs.bazel_compute_affected_targets.outputs.matrix) }} +# env: +# ENABLE_CACHING: false +# CACHE_DIRECTORY: ~/.bazel_cache +# steps: +# - uses: actions/checkout@v2 +# +# - name: Set up JDK 11 +# uses: actions/setup-java@v1 +# with: +# java-version: 11 +# +# - name: Set up Bazel +# uses: abhinavsingh/setup-bazel@v3 +# with: +# version: 6.5.0 +# +# - uses: actions/cache@v2 +# id: scripts_cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# - name: Set up build environment +# uses: ./.github/actions/set-up-android-bazel-build-environment +# +# - name: Configure Bazel to use a local cache (for scripts) +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# - name: Extract test caching bucket & targets +# env: +# AFFECTED_TESTS_BUCKET_BASE64_ENCODED_SHARD: ${{ matrix.affected-tests-bucket-base64-encoded-shard }} +# run: | +# # See https://stackoverflow.com/a/29903172 for cut logic. This is needed to remove the +# # user-friendly shard prefix from the matrix value. +# AFFECTED_TESTS_BUCKET_BASE64=$(echo "$AFFECTED_TESTS_BUCKET_BASE64_ENCODED_SHARD" | cut -d ";" -f 2) +# bazel run //scripts:retrieve_affected_tests -- $AFFECTED_TESTS_BUCKET_BASE64 $(pwd)/test_bucket_name $(pwd)/bazel_test_targets +# TEST_CATEGORY=$(cat ./test_bucket_name) +# BAZEL_TEST_TARGETS=$(cat ./bazel_test_targets) +# echo "Test category: $TEST_CATEGORY" +# echo "Bazel test targets: $BAZEL_TEST_TARGETS" +# echo "TEST_CACHING_BUCKET=$TEST_CATEGORY" >> $GITHUB_ENV +# echo "BAZEL_TEST_TARGETS=$BAZEL_TEST_TARGETS" >> $GITHUB_ENV +# +# # For reference on this & the later cache actions, see: +# # https://github.com/actions/cache/issues/239#issuecomment-606950711 & +# # https://github.com/actions/cache/issues/109#issuecomment-558771281. Note that these work +# # with Bazel since Bazel can share the most recent cache from an unrelated build and still +# # benefit from incremental build performance (assuming that actions/cache aggressively removes +# # older caches due to the 5GB cache limit size & Bazel's large cache size). +# - uses: actions/cache@v2 +# id: test_cache +# with: +# path: ${{ env.CACHE_DIRECTORY }} +# key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests-${{ env.TEST_CACHING_BUCKET }}-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests-${{ env.TEST_CACHING_BUCKET }}- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-binary- +# ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel- +# +# # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a +# # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit) +# # thereby only ever using the last successful cache version. This solution will result in a +# # few slower CI actions around the time cache is detected to be too large, but it should +# # incrementally improve thereafter. +# - name: Ensure cache size +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# # See https://stackoverflow.com/a/27485157 for reference. +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1) +# echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB" +# # Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem +# # to only increase by a few hundred megabytes across changes for unrelated branches. This +# # is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build +# # of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB +# # compressed cache). +# if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then +# echo "Cache exceeds cut-off; resetting it (will result in a slow build)" +# rm -rf $EXPANDED_BAZEL_CACHE_PATH +# fi +# +# - name: Configure Bazel to use a local cache (for tests) +# env: +# BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }} +# run: | +# EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}" +# echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path" +# echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc +# shell: bash +# +# # See explanation in bazel_build_app for how this is installed. +# - name: Install git-secret (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} +# shell: bash +# run: | +# cd $HOME +# mkdir -p $HOME/gitsecret +# git clone https://github.com/sobolevn/git-secret.git git-secret +# cd git-secret && make build +# PREFIX="$HOME/gitsecret" make install +# echo "$HOME/gitsecret" >> $GITHUB_PATH +# echo "$HOME/gitsecret/bin" >> $GITHUB_PATH +# +# - name: Decrypt secrets (non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} +# env: +# GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} +# run: | +# cd $HOME +# # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! +# echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg +# gpg --import ./git_secret_private_key.gpg +# cd $GITHUB_WORKSPACE +# git secret reveal +# +# # See https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/ for for-loop reference. +# - name: Build Oppia Tests (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} +# run: | +# # Attempt to build 5 times in case there are flaky builds. +# # TODO(#3759): Remove this once there are no longer app test build failures. +# i=0 +# # Disable exit-on-first-failure. +# set +e +# while [ $i -ne 5 ]; do +# i=$(( $i+1 )) +# echo "Attempt $i/5 to build test targets" +# bazel build --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS +# done +# # Capture the error code of the final command run (which should be a success if there isn't a real build failure). +# last_error_code=$? +# # Reenable exit-on-first-failure. +# set -e +# # Exit only if the most recent exit was a failure (by using a subshell). +# (exit $last_error_code) +# +# - name: Build Oppia Tests (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }} +# env: +# BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} +# run: | +# # Attempt to build 5 times in case there are flaky builds. +# # TODO(#3759): Remove this once there are no longer app test build failures. +# i=0 +# # Disable exit-on-first-failure. +# set +e +# while [ $i -ne 5 ]; do +# i=$(( $i+1 )) +# echo "Attempt $i/5 to build test targets" +# bazel build --keep_going -- $BAZEL_TEST_TARGETS +# done +# # Capture the error code of the final command run (which should be a success if there isn't a real build failure). +# last_error_code=$? +# # Reenable exit-on-first-failure. +# set -e +# # Exit only if the most recent exit was a failure (by using a subshell). +# (exit $last_error_code) +# - name: Run Oppia Tests (with caching, non-fork only) +# if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }} +# env: +# BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} +# BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} +# run: | +# # Attempt to build 5 times in case there are flaky builds. +# # TODO(#3970): Remove this once there are no longer app test build failures. +# i=0 +# # Disable exit-on-first-failure. +# set +e +# while [ $i -ne 5 ]; do +# i=$(( $i+1 )) +# echo "Attempt $i/5 to run test targets" +# bazel test --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS +# done +# # Capture the error code of the final command run (which should be a success if there isn't a real build failure). +# last_error_code=$? +# # Reenable exit-on-first-failure. +# set -e +# # Exit only if the most recent exit was a failure (by using a subshell). +# (exit $last_error_code) +# - name: Run Oppia Tests (without caching, or on a fork) +# if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }} +# env: +# BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }} +# run: | +# # Attempt to build 5 times in case there are flaky builds. +# # TODO(#3970): Remove this once there are no longer app test build failures. +# i=0 +# # Disable exit-on-first-failure. +# set +e +# while [ $i -ne 5 ]; do +# i=$(( $i+1 )) +# echo "Attempt $i/5 to run test targets" +# bazel test --keep_going -- $BAZEL_TEST_TARGETS +# done +# # Capture the error code of the final command run (which should be a success if there isn't a real build failure). +# last_error_code=$? +# # Reenable exit-on-first-failure. +# set -e +# # Exit only if the most recent exit was a failure (by using a subshell). +# (exit $last_error_code) +# +# # Reference: https://github.community/t/127354/7. +# check_test_results: +# name: Check Bazel Test Results +# needs: [bazel_compute_affected_targets, bazel_run_test] +# # The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations, +# # serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows. +# if: ${{ !cancelled() }} +# runs-on: ubuntu-20.04 +# steps: +# # This step will be skipped if there are no tests to run, so the overall job should pass. +# - name: Check tests passed (for tests that ran) +# if: ${{ needs.bazel_compute_affected_targets.outputs.can_skip_tests != 'true' && needs.bazel_run_test.result != 'success' }} +# run: exit 1