Skip to content

Commit

Permalink
Revert "Fix oppia#5370, part of oppia#59: Migrate to Bazel 6.5.0 (opp…
Browse files Browse the repository at this point in the history
…ia#4886)"

This reverts commit add9f74.
  • Loading branch information
Vishwajith-Shettigar authored Jun 15, 2024
1 parent add9f74 commit 40bce79
Show file tree
Hide file tree
Showing 29 changed files with 417 additions and 176 deletions.
9 changes: 4 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Configurations to ensure that Android-specific classes build correctly.
# Configurations for arguments that should automatically be added to Bazel commands.
build --android_databinding_use_v3_4_args \
--experimental_android_databinding_v2 \
--java_header_compilation=false \
--noincremental_dexing \
--define=android_standalone_dexing_tool=d8_compat_dx \
--android_databinding_use_androidx

# Ensure that all builds use the same JDK for building & running (for better hermeticity and fewer
# inconsistencies across environment configurations).
build --java_runtime_version=remotejdk_11 --tool_java_runtime_version=remotejdk_11

# Ensure all built Java files treat warnings as errors (similar to the Kotlin configuration) to help
# reduce code smell & potential bugs during development.
build --javacopt="-Werror"
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
4.0.0
29 changes: 21 additions & 8 deletions .github/actions/set-up-android-bazel-build-environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contains common operations to set up a hermetic Android + Bazel build environment for Oppia
# Android CI workflows. Action prerequisites:
# - JDK 11 must be installed & set as the default version via JAVA_HOME
# - Bazel must be installed, in the path, and be version 6.5.0
# - JDK 9 must be installed & set as the default version via JAVA_HOME
# - Bazel must be installed, in the path, and be version 4.0.0

# TODO(#1861): Revert SDK pinning for improved CI performance once Bazel is sufficiently stable that
# we can rely on the automatic SDK provided by GitHub's CI environment.
Expand All @@ -19,20 +19,20 @@ runs:
$JAVA_HOME/bin/java -version
# Verify that the correct version of Java is installed.
java -version 2>&1 | grep -q -E "11.0"
java -version 2>&1 | grep -q -E "1.9|9.0"
HAS_CORRECT_JAVA_VERSION=$(echo $?)
if [[ "$HAS_CORRECT_JAVA_VERSION" == 1 ]] ; then
echo "Expected Java 11 to be installed"
echo "Expected Java 9 to be installed"
exit 1
fi
shell: bash

- name: Verify Bazel version
run: |
bazel --version | grep -q 6.5.0
bazel --version | grep -q 4.0.0
HAS_CORRECT_BAZEL_VERSION=$(echo $?)
if [[ "$HAS_CORRECT_JAVA_VERSION" == 1 ]] ; then
echo "Expected Bazel 6.5.0 to be installed"
echo "Expected Bazel 4.0.0 to be installed"
exit 1
fi
shell: bash
Expand Down Expand Up @@ -77,13 +77,26 @@ runs:
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-33"
shell: bash

- name: Install build tools 32.0.0
- name: Install build tools 29.0.2
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "build-tools;32.0.0"
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "build-tools;29.0.2"
shell: bash

- name: Configure Bazel to use JDK 9 for building
run: |
echo "build --java_language_version=9" >> $HOME/.bazelrc
shell: bash

- 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
shell: bash

- name: Set up Oppia Bazel Android Tools
run: |
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
shell: bash
30 changes: 15 additions & 15 deletions .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment
Expand Down Expand Up @@ -168,15 +168,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment
Expand Down Expand Up @@ -302,15 +302,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment
Expand Down Expand Up @@ -449,15 +449,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment
Expand Down Expand Up @@ -570,15 +570,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Set up build environment
uses: ./.github/actions/set-up-android-bazel-build-environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: TODO Issue Resolved Check
id: todoIssueResolvedCheck
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ jobs:
- name: Create oppia android tools directory
run: mkdir -p $HOME/oppia-android-tools

- name: Set up JDK 11
# Java 11 is specifically needed for Checkstyle.
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 1.11

- name: Download Checkstyle
run: |
Expand Down Expand Up @@ -103,7 +104,7 @@ jobs:
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- uses: actions/cache@v2
id: scripts_cache
Expand Down Expand Up @@ -195,7 +196,7 @@ jobs:
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- name: Maven Repin Check
if: always()
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ jobs:
run: |
echo "PR $PR_NUMBER is merging into $PR_BASE_REF_NAME from https://github.com/$PR_HEAD branch $PR_HEAD_REF_NAME."
- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

# For reference on this & the later cache actions, see:
# https://github.com/actions/cache/issues/239#issuecomment-606950711 &
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.compute-test-matrix.outputs.matrix }}
can_skip_tests: ${{ steps.compute-test-matrix.outputs.can_skip_tests }}
have_tests_to_run: ${{ steps.compute-test-matrix.outputs.have_tests_to_run }}
env:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- uses: actions/cache@v2
id: scripts_cache
Expand Down Expand Up @@ -86,16 +86,16 @@ jobs:
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"
echo "::set-output name=have_tests_to_run::true"
else
echo "::set-output name=can_skip_tests::true"
echo "::set-output name=have_tests_to_run::false"
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' }}
if: ${{ needs.bazel_compute_affected_targets.outputs.have_tests_to_run == 'true' }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand All @@ -107,15 +107,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
- name: Set up JDK 9
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 9

- name: Set up Bazel
uses: abhinavsingh/setup-bazel@v3
with:
version: 6.5.0
version: 4.0.0

- uses: actions/cache@v2
id: scripts_cache
Expand Down Expand Up @@ -325,5 +325,5 @@ jobs:
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' }}
if: ${{ needs.bazel_compute_affected_targets.outputs.have_tests_to_run == 'true' && needs.bazel_run_test.result != 'success' }}
run: exit 1
17 changes: 15 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ http_archive(
# Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin.
http_archive(
name = "io_bazel_rules_kotlin",
patches = ["//tools/kotlin:remove_processor_duplicates.patch"],
patches = ["//tools/kotlin:add_kotlinc_optin_support.patch"],
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["sha"],
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["version"]],
)

load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version")

# Use the 1.6 compiler since Kotlin 1.6 is the current supported version in the repository.
# Use the 1.6 compiler since rules_kotlin 1.5 defaults to the 1.5 compiler.
kotlin_repositories(
compiler_release = kotlinc_version(
release = "1.6.10",
Expand Down Expand Up @@ -212,6 +212,7 @@ maven_install(
maven_install_json = "//third_party:maven_install.json",
override_targets = {
"com.google.guava:guava": "@//third_party:com_google_guava_guava",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm": "@//third_party:kotlinx-coroutines-core-jvm",
},
repositories = DAGGER_REPOSITORIES + MAVEN_REPOSITORIES,
strict_visibility = True,
Expand Down Expand Up @@ -239,3 +240,15 @@ pinned_maven_install()
"jre",
]
]

http_jar(
name = "kotlinx-coroutines-core-jvm",
sha256 = HTTP_DEPENDENCY_VERSIONS["kotlinx-coroutines-core-jvm"]["sha"],
urls = [
"{0}/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/{1}/kotlinx-coroutines-core-jvm-{1}.jar".format(
url_base,
HTTP_DEPENDENCY_VERSIONS["kotlinx-coroutines-core-jvm"]["version"],
)
for url_base in DAGGER_REPOSITORIES + MAVEN_REPOSITORIES
],
)
2 changes: 1 addition & 1 deletion build_vars.bzl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BUILD_SDK_VERSION = 33
BUILD_TOOLS_VERSION = "32.0.0"
BUILD_TOOLS_VERSION = "29.0.2"
1 change: 1 addition & 0 deletions config/kitkat_main_dex_class_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ androidx/multidex/ZipUtil.class
androidx/work/Configuration$Provider.class
androidx/work/Configuration.class
androidx/work/WorkManager.class
com/google/firebase/FirebaseApp.class
javax/inject/Provider.class
kotlin/Function.class
kotlin/jvm/functions/Function0.class
Expand Down
2 changes: 1 addition & 1 deletion scripts/assets/file_content_validation_checks.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ file_content_checks {
}
file_content_checks {
file_path_regex: ".+?\\.kt"
prohibited_content_regex: "(format|getString|getStringArray|getQuantityString|getQuantityText|toLowerCase|toUpperCase|capitalize|decapitalize|lowercase|uppercase|replaceFirstChar)\\("
prohibited_content_regex: "(format|getString|getStringArray|getQuantityString|getQuantityText|toLowerCase|toUpperCase|capitalize|decapitalize|lowercase|uppercase)\\("
failure_message: "String formatting and resource retrieval should go through AppLanguageResourceHandler, OppiaLocale.DisplayLocale, or OppiaLocale.MachineLocale depending on the context (see each class's documentation for details on when each should be used)."
exempted_file_name: "app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt"
exempted_file_name: "domain/src/main/java/org/oppia/android/domain/util/JsonExtensions.kt"
Expand Down
11 changes: 0 additions & 11 deletions scripts/assets/maven_dependencies.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -1680,17 +1680,6 @@ maven_dependency {
}
}
}
maven_dependency {
artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4"
artifact_version: "1.6.4"
license {
license_name: "The Apache Software License, Version 2.0"
original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt"
scrapable_link {
url: "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
}
maven_dependency {
artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4"
artifact_version: "1.6.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.junit.rules.TemporaryFolder
import java.io.File

/** The version of Bazel to use in tests that set up Bazel workspaces. */
const val BAZEL_VERSION = "6.5.0"
const val BAZEL_VERSION = "4.0.0"

/**
* Test utility for generating various test & library targets in the specified [TemporaryFolder].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class AndroidBuildSdkPropertiesTest {
fun testBuildToolsVersion_isTheCorrectVersion() {
val properties = AndroidBuildSdkProperties()

assertThat(properties.buildToolsVersion).isEqualTo("32.0.0")
assertThat(properties.buildToolsVersion).isEqualTo("29.0.2")
}
}
Loading

0 comments on commit 40bce79

Please sign in to comment.