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

Fix part of #5343: Introduce new CI workflow for Code Coverage #5465

Merged
merged 344 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
344 commits
Select commit Hold shift + click to select a range
4d5c21f
Fix Lint checks, resolved todos
Rd4dev Jul 10, 2024
4c87573
Specifying jdk version for TestBazelWorkspace build to see if this is…
Rd4dev Jul 10, 2024
3d810b2
Update TestBazelWorkspace tests to include jdk version in the bazelrc…
Rd4dev Jul 10, 2024
595e9df
Fix Lint checks on indentation
Rd4dev Jul 10, 2024
4bc533f
Refactored execute's return value to unit
Rd4dev Jul 11, 2024
ba16aaf
Refactor to take in a list of file paths as args for both cli and ci
Rd4dev Jul 11, 2024
138a141
Reverting --test_timeout flag to see other possible fixes
Rd4dev Jul 11, 2024
75e28e2
Add size large to RunCoverageTest to set timeout to 900 seconds
Rd4dev Jul 11, 2024
9da53d9
Updated tests to changes in taking in as a list of files as args
Rd4dev Jul 12, 2024
aaf3caf
Resolve merge conflict after test timeout and fetch error fixes in ed…
Rd4dev Jul 12, 2024
53d3d79
Resolve merge conflict after test timeout and fetch error fixes in ed…
Rd4dev Jul 12, 2024
d3eb372
Updated processTimeout to set as standard 5 minutes and moved outCont…
Rd4dev Jul 12, 2024
9b5995e
Merge branch 'code_coverage_fix_edge_cases' of https://github.com/opp…
Rd4dev Jul 12, 2024
fcf365e
Fix Lint checks, kdoc checks and updated tests for CoverageRunner, Co…
Rd4dev Jul 12, 2024
7f1bda0
Update tests for list of files as args implementation
Rd4dev Jul 12, 2024
6710f66
Retriggering since localTestHtmlFormat pass locally and to confirm if…
Rd4dev Jul 12, 2024
756bed8
Adding shard_count to see if that is making any difference
Rd4dev Jul 12, 2024
ab60123
Addition of dividing tests with shards did help with ci checks, now r…
Rd4dev Jul 12, 2024
d25ea9c
Adding back shards since that significantly lessens the test run time…
Rd4dev Jul 12, 2024
8802b27
Merge branch 'code_coverage_fix_edge_cases' of https://github.com/opp…
Rd4dev Jul 12, 2024
7a2f66b
Merge branch 'code_coverage_many_to_one_targets' of https://github.co…
Rd4dev Jul 12, 2024
66a387e
Merge branch 'develop' of https://github.com/Rd4dev/oppia-android int…
Rd4dev Jul 13, 2024
50574ae
Merge branch 'code_coverage_fix_edge_cases' of https://github.com/opp…
Rd4dev Jul 13, 2024
f170487
Changed base branch to develop in the repo and added reference comment
Rd4dev Jul 13, 2024
a720fe7
Updated Tests and the code now fails with Coverage Check Status
Rd4dev Jul 15, 2024
5c527a9
Resolve conflict with upstream many to one target branch
Rd4dev Jul 15, 2024
4350f5e
Fix failing test cases with changes to list of files and lint fixes
Rd4dev Jul 15, 2024
6fed0c0
Refactored runCoverageForFile generation separate function and added …
Rd4dev Jul 15, 2024
5e17837
Incrementing the shard count to 12 since the tests timeout in ci
Rd4dev Jul 15, 2024
bae304a
Decrementing the shard count to 8 to not cause overhead of resources,…
Rd4dev Jul 15, 2024
b0432f1
Reverting shards count to 4 but doubt if the cases are cached
Rd4dev Jul 15, 2024
f6fa8af
Incrementing the shard count to 6 since the tests timeout in ci with …
Rd4dev Jul 15, 2024
57f0875
Introduced ComputeChangedFiles utility to get the list of changed fil…
Rd4dev Jul 18, 2024
2d8166a
Replicated the Grouping and Sharding Strategy of test buckets for cha…
Rd4dev Jul 19, 2024
660c6bd
CI workflow to display and output the list of computed changed files
Rd4dev Jul 19, 2024
ede33c4
Ignoring the compute all files implementation need to confirm the git…
Rd4dev Jul 19, 2024
0635875
Retrieving Changed Files from the encoded bucket
Rd4dev Jul 19, 2024
919afdd
Replicating the unit test yaml implementation for code coverages
Rd4dev Jul 19, 2024
e242b9f
Add build targets for the retrieve changed files
Rd4dev Jul 19, 2024
0985145
Added missing changed files proto dependency
Rd4dev Jul 19, 2024
81257bc
Increasing the min threshold to 90 to see if the Coverage Check fails
Rd4dev Jul 19, 2024
61de269
Not a fix, just making sure if increasing the processTimeout helps, p…
Rd4dev Jul 19, 2024
7c32b5e
Exempting the file compute affected tests to cause a intentional cove…
Rd4dev Jul 19, 2024
b3df84b
Running the coverage script only once remvoing attempts
Rd4dev Jul 19, 2024
357cc5d
The coverage check job was ignored in the last ci run so re-commentin…
Rd4dev Jul 19, 2024
707a749
Introduced a new utility just to retrieve the test targets for the se…
Rd4dev Jul 19, 2024
81bab77
Added missing import for ScriptBackgroundCoroutineDispatcher in retri…
Rd4dev Jul 19, 2024
446a916
Using the instance of ScriptBackgroundCoroutineDispatcher
Rd4dev Jul 19, 2024
b46708d
Moving the file test target list implementation into script bg corout…
Rd4dev Jul 19, 2024
2c01848
Reverting the file exemption coverage case since we have other issues…
Rd4dev Jul 19, 2024
fe42482
Replacing the bazel coverage command with bazel test --collect covera…
Rd4dev Jul 19, 2024
67c0036
Removing the print statement for Raw Coverage Data since that seems t…
Rd4dev Jul 19, 2024
2a12472
Incrementing the shard to 24 to align with compute affected tests tes…
Rd4dev Jul 19, 2024
46b779a
Finding Test file paths to retrieve test targets for building the tes…
Rd4dev Jul 20, 2024
e8341cc
Visibility and Type fixes in retrieve changed files changes
Rd4dev Jul 20, 2024
1d5eeb4
Added test file exemption asset data to the build
Rd4dev Jul 20, 2024
113a828
Moving down the target declaration since test file exemption asset is…
Rd4dev Jul 20, 2024
a198c56
Re running to confirm if the coverage percentages are same throughout…
Rd4dev Jul 20, 2024
8c9800b
Re running to confirm since last ci did show difference in coverage p…
Rd4dev Jul 20, 2024
d4f8015
Printing out coverage report data utilizing collect coverage flag
Rd4dev Jul 21, 2024
7e139fe
Replacing the parseCoverage functionality with combined coverage repo…
Rd4dev Jul 21, 2024
ef3318b
Printing the final report Text and specific dat lines
Rd4dev Jul 21, 2024
606225f
Re running coverage analysis to check the coverage percentages
Rd4dev Jul 21, 2024
968474b
Re running coverage analysis attempt: 3 to check the coverage percent…
Rd4dev Jul 21, 2024
22f201d
Re running, also un commenting the oppia build tests caching - probab…
Rd4dev Jul 21, 2024
0808192
Re running while uncommenting the build oppia tests without caching s…
Rd4dev Jul 21, 2024
e0735a9
Re running attempt 6: with removing the kt suffix for test target que…
Rd4dev Jul 21, 2024
ede2c0b
Re run attempt 7 with bunch of random new line and print statments ju…
Rd4dev Jul 21, 2024
8946b06
Re run attempt 8: removing all print statements
Rd4dev Jul 21, 2024
3d78a86
Executing bazel command in 2 different ways for tests with shard conf…
Rd4dev Jul 21, 2024
5ea0739
Re run attempt 10; Printing the coverage command run with bazel test …
Rd4dev Jul 21, 2024
b266e48
Temporary reference point for handling multiple shard coverage data
Rd4dev Jul 22, 2024
15061ba
Adding workflow_run to trigger coverage workflow only when unit tests…
Rd4dev Jul 22, 2024
4e8198c
Re running the ci with workflow run removing quotes in the declaration
Rd4dev Jul 22, 2024
90db4f7
Recommenting the triggers that I uncommented unintentionally
Rd4dev Jul 22, 2024
8955775
Merge branch 'develop' of https://github.com/Rd4dev/oppia-android int…
Rd4dev Jul 24, 2024
10d9acd
Updated the sharedAndLocalTest case to sync in with updated multi tar…
Rd4dev Jul 24, 2024
77e0149
Resolved conflicts on sync with code_coverage_many_to_one_targets branch
Rd4dev Jul 24, 2024
e0d1afe
Clean up - Removed the Raw data path print statement
Rd4dev Jul 24, 2024
d0d72d1
Merge branch 'code_coverage_list_of_files' of https://github.com/oppi…
Rd4dev Jul 24, 2024
7443270
Adding external action wait for workflow action to trigger Coverage C…
Rd4dev Jul 24, 2024
77b060b
Halting the conditional triggering of coverage checks since external …
Rd4dev Jul 24, 2024
b800826
Removing the need for check unit tests completed job; left in previou…
Rd4dev Jul 24, 2024
9ad842f
Refactoring RetrieveChangedFiles and RetrieveChangedFilesTestTargets …
Rd4dev Jul 25, 2024
8eb748d
Updated the coverage workflow to utilize the combined retrieve change…
Rd4dev Jul 25, 2024
f73037c
Added missing import TimeUnit
Rd4dev Jul 25, 2024
fd1946e
Clean up of the coverage workflows and left over unused parts from re…
Rd4dev Jul 25, 2024
9a25964
Added a part of RetrieveChangedFilesTest test cases
Rd4dev Jul 25, 2024
9147df2
Clean up and Lint check fixes for KDoc missing functions
Rd4dev Jul 25, 2024
be8ff1c
Removing the mock data for multi target aggregation implementation
Rd4dev Jul 26, 2024
7d76b89
Added test cases for coverage data missing and retrieval failure cases
Rd4dev Jul 26, 2024
c2eddfb
Trigger Build since ExplorationActiveTimeControllerTest seems to fail
Rd4dev Jul 26, 2024
07e6fad
Syncing in with upstream many to one targets
Rd4dev Jul 27, 2024
5479330
Removing all the asynchronous calls to make it sequential
Rd4dev Jul 28, 2024
24390f5
Updated CoverageRunnerTest after sequential flow
Rd4dev Jul 28, 2024
ffe7768
Removed asynchronous flow in both source and test files for CoverageR…
Rd4dev Jul 28, 2024
8e88c35
Renaming the runWithCoverageAsync to runCoverageForTestTarget, update…
Rd4dev Jul 28, 2024
c1f012c
Trying to find the coverage path with regex pattern as they mismatch
Rd4dev Jul 29, 2024
aa0de7f
Save lobby before switching to a side branch to test permission error…
Rd4dev Jul 29, 2024
800ccda
Trying to hit a certain line n number of times in different ways yet …
Rd4dev Jul 29, 2024
ad611b8
Reverted changes with sample test data that were added for testing pu…
Rd4dev Jul 29, 2024
84c5336
Reverting the shard count to 4 which was introducing while testing
Rd4dev Jul 29, 2024
5561b4e
Merge branch 'develop' of https://github.com/Rd4dev/oppia-android int…
Rd4dev Jul 29, 2024
07184ee
Lint fixes for exceeding max line length
Rd4dev Jul 29, 2024
3974ce0
Fixes Missing Coverage Data Test Case
Rd4dev Jul 29, 2024
360dc4b
Fixed the retrieve coverage failure test case :) by reproducing the s…
Rd4dev Jul 30, 2024
565f2f5
Clean up and refactored the test cases
Rd4dev Jul 30, 2024
bd96fa3
Resolved conflict with upstream many to one targets merge
Rd4dev Jul 30, 2024
2e04f8a
Added functionality to also include source files of the test files to…
Rd4dev Jul 30, 2024
e6c506e
Isolated the sharedTest source File detection with test source File d…
Rd4dev Jul 30, 2024
0353897
Tiny clean up for finding the source file list
Rd4dev Jul 30, 2024
b749916
Added a new proto Coverage Report Container to hold all the coverage …
Rd4dev Jul 30, 2024
a35d7a0
Save lobby - Collecting protos into one coverage report container pro…
Rd4dev Jul 31, 2024
05a007b
Updating the coverage missing test case while removing the job and re…
Rd4dev Jul 31, 2024
a3a661e
Clean up and changed the test case names to be more specific on what …
Rd4dev Jul 31, 2024
8a12cf4
Added validation to ensure exactly one unique value of filePath and f…
Rd4dev Jul 31, 2024
e72179a
Clean up of aggreagation code and replaced conditional error statment…
Rd4dev Jul 31, 2024
f00ebc6
Removed the mock data used for coverage report with n:1 file target a…
Rd4dev Jul 31, 2024
2fa9737
Resolve merge conflicts with changes to upstream one to may targets b…
Rd4dev Jul 31, 2024
8b2415e
Hardcoded implementation of saving the protos to their own path
Rd4dev Jul 31, 2024
b0839ca
New proto structure for coverage to having distinct case for success …
Rd4dev Aug 1, 2024
d9ef7d8
Roughly organized layout / implementation of the flow of the protos a…
Rd4dev Aug 1, 2024
333607e
Re-writing the CoverageReporter script to handle the container proto …
Rd4dev Aug 1, 2024
b17e0d1
First set of cleanup with coverage reporter implemented
Rd4dev Aug 1, 2024
824c406
Reference point for mock data with new repeated bazel test target pro…
Rd4dev Aug 1, 2024
5ee99c0
Clean up and simplification of usage of single usage entry
Rd4dev Aug 1, 2024
372ae95
Fix lint checks and failing test case with update to the proto strucu…
Rd4dev Aug 1, 2024
6499311
Added missing import for BazelTestTarget
Rd4dev Aug 1, 2024
aa68b95
Final md report generation with failure, details - 1. failure below t…
Rd4dev Aug 2, 2024
5e0da59
Refactored CoverageReporter into unit functionalities and avoid repet…
Rd4dev Aug 2, 2024
bcb0bf2
Added parameter to save the proto to the path specified
Rd4dev Aug 2, 2024
8ff593f
Added Coverage Check Status that check through every fail and details…
Rd4dev Aug 2, 2024
9b2f0d8
Added a helper method to calculate coverage percentages
Rd4dev Aug 2, 2024
40b5f14
Updated tests for Coverage Runner Test
Rd4dev Aug 2, 2024
257e434
Added test case for CoverageReporter to test success detail, falure a…
Rd4dev Aug 2, 2024
a63a4d0
Added test case for CoverageReporter to test success detail, falure a…
Rd4dev Aug 2, 2024
edfd42d
Added combined success failure and exempted test file cases
Rd4dev Aug 2, 2024
91cd498
Updated RunCoverageTest test cases with new rewritten report implemen…
Rd4dev Aug 4, 2024
a4d5e58
Resolve merge conflicts with changes to upstream proto BazelTestTarge…
Rd4dev Aug 4, 2024
b41ad71
Fix lint checks indents and max line lengths
Rd4dev Aug 4, 2024
db74fee
Fix test with unresolved bazel test target list, added kdoc
Rd4dev Aug 4, 2024
d7ab04d
Fix failing test cases, lint checks indents, missing new lines and ma…
Rd4dev Aug 4, 2024
e5da141
Fix failing test with absence of trimEnd
Rd4dev Aug 4, 2024
c847231
Conditional new line additions; with next commits replace them with a…
Rd4dev Aug 4, 2024
2172905
Replaced appendLine with append to use \n in line
Rd4dev Aug 4, 2024
2ff0bda
Fix Tests with Failure cases and used the public const MIN_THRESHOLD …
Rd4dev Aug 4, 2024
61accfb
Kdoc checks and fix test with list of files
Rd4dev Aug 4, 2024
eef9618
Added Coverage Check Status to entire check and md report
Rd4dev Aug 4, 2024
aed8081
Refactored new lines in tests and added Coverage status to test templ…
Rd4dev Aug 4, 2024
4293d43
Fix failing tests with color codes and new line missing
Rd4dev Aug 5, 2024
d93762e
Updated test failure with appropriate failure type in test cases
Rd4dev Aug 5, 2024
75048d2
Fix failing test cases with missing new line
Rd4dev Aug 5, 2024
a294810
Bumping shard_count to 24 that got overriden with merge
Rd4dev Aug 5, 2024
d1ceedd
Added new tests with failing cases and new types of reports
Rd4dev Aug 5, 2024
464840c
Fix Lint check removed unused imports
Rd4dev Aug 5, 2024
7d875a9
Readding the shard count, removing while local testing
Rd4dev Aug 5, 2024
8c35412
Refactored log report to log only the failed coverage report to avoid…
Rd4dev Aug 5, 2024
d9358fd
Fixed Kdoc issues and redundant quotes
Rd4dev Aug 5, 2024
d4dc9fe
Resolve merge conflict with upstream list of files and modified alway…
Rd4dev Aug 5, 2024
e024b8f
Added remaining test target collection test cases for retrieveChangeF…
Rd4dev Aug 5, 2024
5ea6054
Introducing ComputeChangedFilesTest test file
Rd4dev Aug 5, 2024
267b1b3
Base test case setup to add a file as a changed file for computeChang…
Rd4dev Aug 6, 2024
12df19d
Added test cases for ComputeChangedFiles replicated exactly from the …
Rd4dev Aug 6, 2024
e20782c
Enable Functionality to compute on all available .kt source files
Rd4dev Aug 6, 2024
5e528fe
Merge branch 'develop' of https://github.com/Rd4dev/oppia-android int…
Rd4dev Aug 6, 2024
e72eec3
Added the copy of local and shared test to ensure the multiple test f…
Rd4dev Aug 6, 2024
49d2029
Resolve merge conflict with upstream RunCoverageTest
Rd4dev Aug 6, 2024
226f8b6
Added test to verify that the final container is saved to output prot…
Rd4dev Aug 6, 2024
223c266
Save lobby for proto extraction and storage
Rd4dev Aug 6, 2024
8aa42bb
Added test case to verify one single line hit my multiple targets of …
Rd4dev Aug 6, 2024
871a48e
Updated the Final coverage report template as suggested. This introdu…
Rd4dev Aug 7, 2024
2221bad
Updated tests with updated md template and fixed few review comments
Rd4dev Aug 7, 2024
c670ec3
Reverting the shard count change for ci run
Rd4dev Aug 7, 2024
45ee041
Resolve merge conflicts with upstream one to many targets :(
Rd4dev Aug 7, 2024
9b01b54
Save lobby while fixing tests as they take too long
Rd4dev Aug 7, 2024
2535777
Enabled and refactored compute changed files to have all files settin…
Rd4dev Aug 7, 2024
c6b45db
Remove unintended shard count
Rd4dev Aug 7, 2024
4e4c687
Cleaned up the BazelClient could be refactored more, will do after 1s…
Rd4dev Aug 7, 2024
87b45a9
Little clean with left debugging lines
Rd4dev Aug 7, 2024
30f3e97
Added test case with compute all file settings
Rd4dev Aug 8, 2024
e527dd9
Refactoring with test file exemption removal
Rd4dev Aug 8, 2024
2f11be3
Fixed test cases with Coverage Reporter and also added test cases cor…
Rd4dev Aug 8, 2024
667ed45
Fix failing test with CoverageRunnerTest due to incorrect target spec…
Rd4dev Aug 8, 2024
09277b6
Fixing test cases part 1 - md report template changes
Rd4dev Aug 8, 2024
0738388
Fix Lint checks majorly formattings
Rd4dev Aug 8, 2024
bdddfd5
Fix tests part 2 - exceptions and templates
Rd4dev Aug 8, 2024
9400e9e
Fix Tests part 3 - remove unnecessary lines
Rd4dev Aug 8, 2024
5d6b16b
Fix test after bumping min threshold to 70
Rd4dev Aug 8, 2024
0f3309c
Fix tests part 4 - with template and min threshold changes :|
Rd4dev Aug 8, 2024
ad5aa58
Fix Lint check Remove needless blank line
Rd4dev Aug 8, 2024
4ee8269
Updating with the upstream list of files
Rd4dev Aug 8, 2024
6aeda6b
Removing the logic to run test with args
Rd4dev Aug 8, 2024
71a9ce2
Bumping the processTimeout to 15 since the code coverage run failed w…
Rd4dev Aug 8, 2024
395a3b1
Fix Lint checks and re running ci to verify coverage pass
Rd4dev Aug 8, 2024
d8b9e6a
Removed the supress cases and comments
Rd4dev Aug 8, 2024
bec21b7
Bumping the process timeout straight in the RunCoverage to 35 and rem…
Rd4dev Aug 8, 2024
89dcd05
Trying to bump processTimeout in test
Rd4dev Aug 8, 2024
fed6a79
Brought in changes from the exempt-test-targets-incompatible-with-cod…
Rd4dev Aug 8, 2024
cec0f34
Changing the report format to proto for the ci runs and also bumping …
Rd4dev Aug 8, 2024
15b6d63
Resolved conflicts with upstream list of files
Rd4dev Aug 8, 2024
2274c0d
Fix Lint check missing space after =
Rd4dev Aug 8, 2024
d8d121e
Fix Lint check missing space after =
Rd4dev Aug 8, 2024
cba7a13
Triggering ci since many checks seem to fail after update
Rd4dev Aug 8, 2024
dad1370
Remove old implementation for collecting data
Rd4dev Aug 8, 2024
4462e12
Merge from upstream remove old implementation
Rd4dev Aug 8, 2024
83836bc
Fix failing test cases with changes from pull from exemptions pr
Rd4dev Aug 8, 2024
d1307c9
Added tests for BazelClient and Missing Build declarations inclusions
Rd4dev Aug 9, 2024
2639294
Fix Lint checks max line legth
Rd4dev Aug 9, 2024
013c951
Merge with develop branch
Rd4dev Aug 9, 2024
b8b70ed
Reordering the coverage output
Rd4dev Aug 9, 2024
743024d
Readjusted the bazel client test output
Rd4dev Aug 9, 2024
fa9cde0
Merge with latest upstream list of files
Rd4dev Aug 9, 2024
65419db
Removed unused instrumentation / path finder variables
Rd4dev Aug 9, 2024
0801ea5
Updated md template with replacing the file name links with the detai…
Rd4dev Aug 9, 2024
ac2f97e
Moved exempted list too to a details summary as they too might grow big
Rd4dev Aug 9, 2024
f951993
Updated tests to reflect changes in md report with replacement of lin…
Rd4dev Aug 9, 2024
fdf274a
Updated with suggested edits in the review
Rd4dev Aug 9, 2024
dc47fc6
Removed parsing of the pb file in the Coverage Reporter Test
Rd4dev Aug 9, 2024
bc7054b
Fix failing tests and lint checks
Rd4dev Aug 9, 2024
2d4b338
Fixed a flaky test, expected it to be since the order depends on the …
Rd4dev Aug 9, 2024
12e9f3e
Fix Lint check indentation
Rd4dev Aug 9, 2024
91f031f
Merge from upstream list of files branch
Rd4dev Aug 9, 2024
aed0c18
Mapping tests to targets right in the compute changed files
Rd4dev Aug 9, 2024
7c8dac9
Code cleanup the changes need verification in ci
Rd4dev Aug 9, 2024
f6460e3
Removed steps: git-secret, decrypt secrets and all with caching steps…
Rd4dev Aug 9, 2024
69256ea
Split instrumentation test cases and added test for non kt files checks
Rd4dev Aug 9, 2024
618a9ee
Updated test cases and added tests for non kotlin files
Rd4dev Aug 9, 2024
9b0c209
Updating tests to work on files that are committed and not just added…
Rd4dev Aug 9, 2024
48bc7f7
Fixed/Updated all the test cases with changes to the computing only t…
Rd4dev Aug 9, 2024
3eac085
Reverting the commented check unit test completed job to verify ci runs
Rd4dev Aug 9, 2024
28593b5
Merge and resolving with upstream after incompatible files are exempted
Rd4dev Aug 10, 2024
7949695
Resolve conflict with coverage BUILD
Rd4dev Aug 10, 2024
8839a01
Updated tests with source incompatible exemption changes
Rd4dev Aug 10, 2024
a970df2
Fix Tests after merging with upstream exemptions
Rd4dev Aug 10, 2024
ea1be84
Storing the protos to their respective file name paths and updated it…
Rd4dev Aug 10, 2024
fa85aa6
Fix tests with saving proto - yet to confirm test case with changes t…
Rd4dev Aug 10, 2024
3377795
Added log statement for md report path
Rd4dev Aug 10, 2024
aeaa8fc
Resolved merge conflict with upstream list of files
Rd4dev Aug 10, 2024
fe67c3a
Commented the dependency to unit test to test coverage runs after cac…
Rd4dev Aug 10, 2024
2709e46
Removing the need dependency for coverage workflow
Rd4dev Aug 10, 2024
7836bdc
Added test cases to cover the mapping of test to source file
Rd4dev Aug 10, 2024
9ee65c2
Fix upstream override of findTestFile args
Rd4dev Aug 10, 2024
73231c5
Fix failing test with additional message missing errors
Rd4dev Aug 10, 2024
f834919
Merge with upstream list of files after test fixes
Rd4dev Aug 10, 2024
7a8f32f
Fix failing tests with high Coverage Exemption
Rd4dev Aug 10, 2024
b89dfb9
Merge with upstream list of files
Rd4dev Aug 10, 2024
b655df7
Reverting the commented out check unit job
Rd4dev Aug 10, 2024
1d35054
Changing the proto to MD as keeping the proto would skip the coverage…
Rd4dev Aug 10, 2024
76da534
Removed unused Enable_caching variable
Rd4dev Aug 10, 2024
21773d0
Resolving conflict after list of files branch merge with develop
Rd4dev Aug 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 255 additions & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
# Contains jobs corresponding to code coverage.

name: Code Coverage

# Controls when the action will run. Triggers the workflow on pull request
# events or push events in the develop branch.
on:
pull_request:
push:
branches:
# Push events on develop branch
- develop

jobs:
check_unit_tests_completed:
name: Check unit test completed
runs-on: ubuntu-latest
steps:
- name: Wait for unit tests to checks
uses: ArcticLampyrid/action-wait-for-workflow@v1.2.0
with:
workflow: unit_tests.yml
sha: auto

compute_changed_files:
name: Compute changed files
needs: check_unit_tests_completed
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.compute-file-matrix.outputs.matrix }}
can_skip_files: ${{ steps.compute-file-matrix.outputs.can_skip_files }}
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 file matrix
id: compute-file-matrix
env:
compute_all_files: ${{ 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_changed_files -- $(pwd) $(pwd)/changed_files.log $base_commit_hash compute_all_files=$compute_all_files
FILE_BUCKET_LIST=$(cat ./changed_files.log | sed 's/^\|$/"/g' | paste -sd, -)
echo "Changed files (note that this might be all files if configured to run all or on the develop branch): $FILE_BUCKET_LIST"
echo "::set-output name=matrix::{\"changed-files-bucket-base64-encoded-shard\":[$FILE_BUCKET_LIST]}"
if [[ ! -z "$FILE_BUCKET_LIST" ]]; then
echo "::set-output name=can_skip_files::false"
else
echo "::set-output name=can_skip_files::true"
echo "No files are affected by this change. If this is wrong, you can add '[RunAllTests]' to the PR title to force a run."
fi

code_coverage_run:
Rd4dev marked this conversation as resolved.
Show resolved Hide resolved
name: Run Code Coverage
needs: compute_changed_files
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
max-parallel: 10
matrix: ${{ fromJson(needs.compute_changed_files.outputs.matrix) }}
env:
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 caching bucket
env:
CHANGED_FILESS_BUCKET_BASE64_ENCODED_SHARD: ${{ matrix.changed-files-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.
CHANGED_FILES_BUCKET_BASE64=$(echo "$CHANGED_FILESS_BUCKET_BASE64_ENCODED_SHARD" | cut -d ";" -f 2)
bazel run //scripts:retrieve_changed_files -- $(pwd) $CHANGED_FILES_BUCKET_BASE64 $(pwd)/file_bucket_name $(pwd)/changed_files $(pwd)/bazel_test_targets
FILE_CATEGORY=$(cat ./file_bucket_name)
CHANGED_FILES=$(cat ./changed_files)
BAZEL_TEST_TARGETS=$(cat ./bazel_test_targets)
echo "File category: $FILE_CATEGORY"
echo "Changed Files: $CHANGED_FILES"
echo "Bazel test targets: $BAZEL_TEST_TARGETS"
echo "FILE_CACHING_BUCKET=$FILE_CATEGORY" >> $GITHUB_ENV
echo "CHANGED_FILES=$CHANGED_FILES" >> $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.FILE_CACHING_BUCKET }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-tests-${{ env.FILE_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
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: Build Oppia Tests
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 Coverage
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
run: |
bazel run //scripts:run_coverage -- $(pwd) $CHANGED_FILES --format=MARKDOWN --processTimeout=15
BenHenning marked this conversation as resolved.
Show resolved Hide resolved

# Reference: https://github.community/t/127354/7.
check_coverage_results:
name: Check Code Coverage Results
needs: [ compute_changed_files, code_coverage_run ]
# 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:
- name: Check coverages passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.code_coverage_run.result != 'success' }}
run: exit 1
15 changes: 15 additions & 0 deletions scripts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@ kt_jvm_binary(
],
)

kt_jvm_binary(
Rd4dev marked this conversation as resolved.
Show resolved Hide resolved
name = "retrieve_changed_files",
testonly = True,
data = TEST_FILE_EXEMPTION_ASSETS,
main_class = "org.oppia.android.scripts.ci.RetrieveChangedFilesKt",
runtime_deps = ["//scripts/src/java/org/oppia/android/scripts/ci:retrieve_changed_files_lib"],
)

kt_jvm_binary(
name = "compute_changed_files",
testonly = True,
main_class = "org.oppia.android.scripts.ci.ComputeChangedFilesKt",
runtime_deps = ["//scripts/src/java/org/oppia/android/scripts/ci:compute_changed_files_lib"],
)

# Note that this is intentionally not test-only since it's used by the app build pipeline. Also,
# this apparently needs to be a java_binary to set up runfiles correctly when executed within a
# Starlark rule as a tool.
Expand Down
30 changes: 30 additions & 0 deletions scripts/src/java/org/oppia/android/scripts/ci/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ kt_jvm_library(
"//scripts/src/java/org/oppia/android/scripts/proto:affected_tests_java_proto",
],
)

kt_jvm_library(
name = "compute_changed_files_lib",
testonly = True,
srcs = [
"ComputeChangedFiles.kt",
],
visibility = ["//scripts:oppia_script_binary_visibility"],
deps = [
"//scripts/src/java/org/oppia/android/scripts/common:git_client",
"//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder",
"//scripts/src/java/org/oppia/android/scripts/common:repository_file",
"//scripts/src/java/org/oppia/android/scripts/proto:changed_files_java_proto",
],
)

kt_jvm_library(
name = "retrieve_changed_files_lib",
testonly = True,
srcs = [
"RetrieveChangedFiles.kt",
],
visibility = ["//scripts:oppia_script_binary_visibility"],
deps = [
"//scripts/src/java/org/oppia/android/scripts/common:bazel_client",
"//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder",
"//scripts/src/java/org/oppia/android/scripts/proto:changed_files_java_proto",
"//scripts/src/java/org/oppia/android/scripts/proto:script_exemptions_java_proto",
],
)
Loading
Loading