-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced a new utility just to retrieve the test targets for the se…
…t of changed files provided Since the code coverages take a long time, it should be possible that the builds are taking the most times which cause process didn't finish within intended time errors. So may be having the build oppia tests beforehand should help with this, but since we use just the changed files for the input to our run coverage scripts we will need this extra utility (or if possible lets try to move it with something else if possible retrieve changed files.kt) to handle the mapping of changed files to their respective targets to feed to build them
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
scripts/src/java/org/oppia/android/scripts/ci/RetrieveChangedFilesTestTargets.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.oppia.android.scripts.ci | ||
|
||
import org.oppia.android.scripts.common.BazelClient | ||
import org.oppia.android.scripts.common.CommandExecutor | ||
import org.oppia.android.scripts.common.CommandExecutorImpl | ||
import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.mergeFromCompressedBase64 | ||
import org.oppia.android.scripts.proto.ChangedFilesBucket | ||
import java.io.File | ||
import java.util.Locale | ||
import java.util.concurrent.TimeUnit | ||
import kotlin.system.exitProcess | ||
|
||
/** | ||
* The main entrypoint for retrieving the list of changed files from a particular encoded Base64 | ||
* bucket. This is used to parse the output from compute_changed_files. | ||
* | ||
* Usage: | ||
* bazel run //scripts:retrieve_changed_files -- \\ | ||
* <encoded_proto_in_base64> <path_to_bucket_name_output_file> \\ | ||
* <path_to_file_list_output_file> | ||
* | ||
* Arguments: | ||
* - encoded_proto_in_base64: the compressed & Base64-encoded [ChangedFilesBucket] proto computed | ||
* by compute_changed_files. | ||
* - path_to_bucket_name_output_file: path to the file where the file bucket name corresponding to | ||
* this bucket should be printed. | ||
* - path_to_file_list_output_file: path to the file where the list of changed files | ||
* corresponding to this bucket should be printed. | ||
* | ||
* Example: | ||
* bazel run //scripts:retrieve_changed_files -- $(pwd) $CHANGED_FILES_BUCKETS_BASE64_ENCODED_PROTO \\ | ||
* $(pwd)/file_bucket_name $(pwd)/changed_files | ||
*/ | ||
fun main(args: Array<String>) { | ||
/*if (args.size < 3) { | ||
println( | ||
"Usage: bazel run //scripts:retrieve_changed_files --" + | ||
" <encoded_proto_in_base64> <path_to_bucket_name_output_file>" + | ||
" <path_to_file_list_output_file>" | ||
) | ||
exitProcess(1) | ||
}*/ | ||
|
||
val rootDirectory = File(args[0]).absoluteFile | ||
val protoBase64 = args[1] | ||
val bucketNameOutputFile = File(args[2]) | ||
val fileTestTargetsListOutputFile = File(args[3]) | ||
|
||
val commandExecutor: CommandExecutor = | ||
CommandExecutorImpl( | ||
scriptBgDispatcher, processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES | ||
) | ||
|
||
val bazelClient = BazelClient(rootDirectory, commandExecutor) | ||
|
||
val changedFilesBucket = | ||
ChangedFilesBucket.getDefaultInstance().mergeFromCompressedBase64(protoBase64) | ||
bucketNameOutputFile.printWriter().use { writer -> | ||
writer.println(changedFilesBucket.cacheBucketName) | ||
} | ||
|
||
val changedFilesTestTargets = bazelClient.retrieveBazelTargets(changedFilesBucket.changedFilesList) | ||
println("Changed Files Test Targets: $changedFilesTestTargets") | ||
|
||
fileTestTargetsListOutputFile.printWriter().use { writer -> | ||
writer.println(changedFilesTestTargets.joinToString(separator = " ")) | ||
} | ||
} |