diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 0a68c899643..fd43aae0565 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -21,18 +21,44 @@ jobs: ENABLE_CACHING: false steps: - uses: actions/checkout@v2 - - name: Clone Oppia Bazel - run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Set up JDK 9 uses: actions/setup-java@v1 with: java-version: 9 - - name: Extract Android tools + + - name: Check Java version & path + run: | + which java + java -version + echo "Java home: $JAVA_HOME" + $JAVA_HOME/bin/java -version + + - name: Set up Bazel + uses: abhinavsingh/setup-bazel@v3 + with: + version: 4.0.0 + + - name: Configure Bazel to use JDK 9 for building + run: | + echo "build --java_language_version=9" >> $HOME/.bazelrc + + - name: Configure Bazel to use specific sandbox tmpfs + run: | + echo "build --enable_platform_specific_config" >> $HOME/.bazelrc + echo "build:linux --sandbox_tmpfs_path=/tmp" >> $HOME/.bazelrc + + - name: Check Bazel environment + run: bazel info + + - name: Set up Oppia Bazel Android Tools run: | - mkdir -p $GITHUB_WORKSPACE/tmp/android_tools - cd $HOME/oppia-bazel - unzip bazel-tools.zip - tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools + mkdir $HOME/opensource + cd $HOME/opensource + git clone https://github.com/oppia/oppia-bazel-tools + echo build --override_repository=android_tools="$(cd "$(dirname "$HOME/opensource/oppia-bazel-tools")"; pwd)/$(basename "$HOME/opensource/oppia-bazel-tools")" >> $HOME/.bazelrc + echo build --android_databinding_use_androidx >> $HOME/.bazelrc + # 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 @@ -50,6 +76,7 @@ jobs: 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: @@ -61,25 +88,23 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - - name: Unzip Bazel binary - run: | - cd $HOME/oppia-bazel - unzip bazel-build.zip - cd $GITHUB_WORKSPACE - chmod a+x $HOME/oppia-bazel/bazel + # 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: | - $HOME/oppia-bazel/bazel build --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia + 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: | - $HOME/oppia-bazel/bazel build --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- //:oppia + bazel build -- //:oppia + - name: Copy Oppia APK 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 diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 82295e047a8..84a48991ed2 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -65,14 +65,36 @@ jobs: ENABLE_CACHING: false steps: - uses: actions/checkout@v2 + - name: Set up JDK 9 uses: actions/setup-java@v1 with: java-version: 9 + + - name: Check Java version & path + run: | + which java + java -version + echo "Java home: $JAVA_HOME" + $JAVA_HOME/bin/java -version + - name: Set up Bazel uses: abhinavsingh/setup-bazel@v3 with: version: 4.0.0 + + - name: Configure Bazel to use JDK 9 for building + run: | + echo "build --java_language_version=9" >> $HOME/.bazelrc + + - name: Configure Bazel to use specific sandbox tmpfs + run: | + echo "build --enable_platform_specific_config" >> $HOME/.bazelrc + echo "build:linux --sandbox_tmpfs_path=/tmp" >> $HOME/.bazelrc + + - name: Check Bazel environment + run: bazel info + - name: Set up Oppia Bazel Android Tools run: | mkdir $HOME/opensource @@ -80,6 +102,7 @@ jobs: git clone https://github.com/oppia/oppia-bazel-tools echo build --override_repository=android_tools="$(cd "$(dirname "$HOME/opensource/oppia-bazel-tools")"; pwd)/$(basename "$HOME/opensource/oppia-bazel-tools")" >> $HOME/.bazelrc echo build --android_databinding_use_androidx >> $HOME/.bazelrc + # 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')) }} @@ -92,6 +115,7 @@ jobs: 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: @@ -103,11 +127,13 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal + - name: Run Oppia Test (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 }} run: bazel test --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} + - name: Run Oppia Test (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: