Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Bazel tests won't run on develop CI #5407

Closed
BenHenning opened this issue May 22, 2024 · 1 comment · Fixed by #5408
Closed

[BUG]: Bazel tests won't run on develop CI #5407

BenHenning opened this issue May 22, 2024 · 1 comment · Fixed by #5408
Assignees
Labels
bug End user-perceivable behaviors which are not desirable. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Priority: Essential This work item must be completed for its milestone. Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.

Comments

@BenHenning
Copy link
Member

Describe the bug

#4929 introduced functional fixes for the ComputeAffectedTests script, and these seem to work fine in CI except for the develop branch which is now failing: see failure for 24b1721:

Run bazel run //scripts:compute_affected_tests -- $(pwd) $(pwd)/affected_targets.log $base_commit_hash compute_all_tests=$compute_all_targets
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 1ad3ad08-be18-43cf-a2d7-f1f0fd4f[17](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:18)04
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/robolectric/robolectric-bazel/archive/4.5.tar.gz) = af0177d32ecd2cd68ee6e9f5d38288e1c4de0dd2a756bb7133c243f2d5fe06f7
DEBUG: Rule 'robolectric' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "af0177d32ecd2cd68ee6e9f5d38288e1c4de0dd2a756bb7133c243f2d5fe06f7"
DEBUG: Repository robolectric instantiated at:
  /home/runner/work/oppia-android/oppia-android/WORKSPACE:97:13: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
DEBUG: Rule 'tools_android' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1594238320 -0400"
DEBUG: Repository tools_android instantiated at:
  /home/runner/work/oppia-android/oppia-android/WORKSPACE:108:15: in <toplevel>
Repository rule git_repository defined at:
  /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/external/bazel_tools/tools/build_defs/repo/git.bzl:[19](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:20)9:33: in <toplevel>
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Analyzing: target //scripts:compute_affected_tests (1 packages loaded, 0 targets configured)
Analyzing: target //scripts:compute_affected_tests (9 packages loaded, 8 targets configured)
Analyzing: target //scripts:compute_affected_tests (9 packages loaded, 8 targets configured)
WARNING: Download from https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/kotlin-stdlib-common-1.5.0-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/com/google/protobuf/protobuf-javalite/3.19.2/protobuf-javalite-3.19.2-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/kotlin-stdlib-common-1.5.0.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/com/google/protobuf/protobuf-javalite/3.19.2/protobuf-javalite-3.19.2.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/annotations/13.0/annotations-13.0.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/kotlin-stdlib-1.5.0-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/kotlin-stdlib-1.5.0.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
Analyzing: target //scripts:compute_affected_tests (58 packages loaded, 1194 targets configured)
INFO: Analyzed target //scripts:compute_affected_tests (60 packages loaded, 1411 targets configured).
INFO: Found 1 target...
[0 / 5] [Prepa] Expanding template external/io_bazel_rules_kotlin/src/main/kotlin/builder [for host]
INFO: From KotlinCompile //scripts/src/java/org/oppia/android/scripts/common:script_background_coroutine_dispatcher { kt: 1, java: 0, srcjars: 0 } for k8:
warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk7.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk8.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-script-runtime.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-reflect.jar (version 1.4)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
[402 / 415] KotlinCompile //scripts/src/java/org/oppia/android/scripts/common:command_executor { kt: 3, java: 0, srcjars: 0 } for k8; 5s remote-cache, worker ... (3 actions, 2 running)
INFO: From KotlinCompile //scripts/src/java/org/oppia/android/scripts/common:command_executor { kt: 3, java: 0, srcjars: 0 } for k8:
warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk7.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk8.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-script-runtime.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-reflect.jar (version 1.4)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
INFO: From Building external/com_google_protobuf/libprotobuf_java.jar (1[23](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:24) source files, 1 source jar):
warning: -parameters is not supported for target value 1.7. Use 1.8 or later.
INFO: From KotlinCompile //scripts/src/java/org/oppia/android/scripts/common:bazel_client { kt: 1, java: 0, srcjars: 0 } for k8:
warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk7.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk8.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b[31](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:32)fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a88[32](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:33)bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8[34](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:35)1d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-script-runtime.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-reflect.jar (version 1.4)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
INFO: From KotlinCompile //scripts/src/java/org/oppia/android/scripts/common:git_client { kt: 1, java: 0, srcjars: 0 } for k8:
warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk7.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk8.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-script-runtime.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-reflect.jar (version 1.4)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
INFO: From KotlinCompile //scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib { kt: 1, java: 0, srcjars: 0 } for k8:
warning: runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk7.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-stdlib-jdk8.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.0/header_kotlin-stdlib-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/external/maven/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.0/header_kotlin-stdlib-common-1.5.0.jar (version 1.5)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-script-runtime.jar (version 1.4)
    /home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/external/com_github_jetbrains_kotlin/lib/kotlin-reflect.jar (version 1.4)
warning: some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
[414 / 415] [Prepa] Merging Kotlin output jar //scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib (Runtime) from 1 inputs
Target //scripts:compute_affected_tests up-to-date:
  bazel-bin/scripts/compute_affected_tests.jar
  bazel-bin/scripts/compute_affected_tests.jdeps
INFO: Elapsed time: 56.612s, Critical Path: 14.95s
INFO: 415 processes: [39](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:40)0 remote cache hit, 17 internal, 4 linux-sandbox, 4 worker.
INFO: Build completed successfully, 415 total actions
INFO: Running command line: bazel-bin/scripts/compute_affected_tests /home/runner/work/oppia-android/oppia-android /home/runner/work/oppia-android/oppia-android/affected_targets.log 'compute_all_tests=false'
INFO: Build completed successfully, [41](https://github.com/oppia/oppia-android/actions/runs/9198899153/job/25302622694#step:7:42)5 total actions
/home/runner/.cache/bazel/_bazel_runner/ef69b31fa14ea8341d6589b0a8832bdd/execroot/__main__/bazel-out/k8-fastbuild/bin/scripts/compute_affected_tests: line 112: fg: no job control
Usage: bazel run //scripts:compute_affected_tests -- <path_to_directory_root> <path_to_output_file> <merge_base_commit> <compute_all_tests=true/false>

Steps To Reproduce

This isn't easy to repro because it seems that, from the error, the underlying problem has to do with how we now compute the base_commit_hash variable:

base_commit_hash: ${{ github.event.pull_request.base.sha }}

there is no pull_request when running CI outside of a PR's CI runs so it seems this SHA value is actually empty. This can be reproed approximately by running the command as though it were empty:

bazel run //scripts:compute_affected_tests -- $(pwd) $(pwd)/affected_targets.log  compute_all_tests=false

(Notice the two spaces between the arguments).

This can only be reasonably verified by submitting a fix and ensuring that the CI run now passes.

Expected Behavior

CI runs should always run & pass on develop.

Screenshots/Videos

No response

What device/emulator are you using?

No response

Which Android version is your device/emulator running?

No response

Which version of the Oppia Android app are you using?

No response

Additional Context

It's not worth reverting #4929 since it's introducing an issue that only affects fully submitted PRs (meaning a fix-forward has the same likelihood of fixing/breaking develop as a revert + fix, but it requires less reviewing & merging and thus can hopefully be fixed more quickly).

@BenHenning BenHenning added bug End user-perceivable behaviors which are not desirable. triage needed labels May 22, 2024
@BenHenning BenHenning self-assigned this May 22, 2024
@BenHenning BenHenning added Priority: Essential This work item must be completed for its milestone. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. and removed triage needed labels May 22, 2024
BenHenning added a commit that referenced this issue May 23, 2024
## Explanation
Fixes #5407

This introduces a proper fallback for the base branch used for computing
affected tests when off-develop: ``origin/develop`` (which was the same
base used prior to #4929 being merged).

This can't easily be verified without being merged, but I have high
confidence it'll work since we've used the JavaScript ``||`` fallback
syntax in GitHub workflow ``if`` conditionals in the past (and the
environment should be the same for ``env`` variables).

Note that this is being fixed forward rather than reverted because the
only verification is merging the PR, so it's actually faster and simpler
to fix forward than to revert the original PR and re-submit a fix (which
has the same likelihood of fixing CI as this fix forward).

## Essential Checklist
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
N/A -- This only affects CI infrastructure.
@BenHenning
Copy link
Member Author

Looks like everything is fixed now. Env in latest develop CI run:

  env:
    CACHE_DIRECTORY: ~/.bazel_cache
    compute_all_targets: false
    base_commit_hash: origin/develop

And everything passed: https://github.com/oppia/oppia-android/actions/runs/9212567763/job/25344491603.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Priority: Essential This work item must be completed for its milestone. Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.
Development

Successfully merging a pull request may close this issue.

1 participant