diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml
index 992a7e86cb1..276f2841312 100644
--- a/.github/workflows/code_coverage.yml
+++ b/.github/workflows/code_coverage.yml
@@ -258,10 +258,10 @@ jobs:
evaluate_code_coverage_reports:
name: Evaluate Code Coverage Reports
runs-on: ubuntu-20.04
- needs: code_coverage_run
+ needs: [ check_unit_tests_completed, 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() }}
+ if: ${{ !cancelled() && needs.check_unit_tests_completed.result == 'success'}}
env:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
@@ -311,12 +311,16 @@ jobs:
# Reference: https://github.community/t/127354/7.
check_coverage_results:
name: Check Code Coverage Results
- needs: [ compute_changed_files, code_coverage_run, evaluate_code_coverage_reports ]
+ needs: [ check_unit_tests_completed, compute_changed_files, code_coverage_run, evaluate_code_coverage_reports ]
# 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 unit tests passed
+ if: ${{ needs.check_unit_tests_completed.result != 'success' }}
+ run: exit 1
+
- name: Check coverages passed
if: ${{ needs.compute_changed_files.outputs.can_skip_files != 'true' && needs.code_coverage_run.result != 'success' }}
run: exit 1
diff --git a/.github/workflows/comment_coverage_report.yml b/.github/workflows/comment_coverage_report.yml
index 9ecb4e2e95c..16c1ae0da63 100644
--- a/.github/workflows/comment_coverage_report.yml
+++ b/.github/workflows/comment_coverage_report.yml
@@ -3,11 +3,11 @@
name: Comment Coverage Report
# Controls when the action will run. Triggers the workflow on pull request events
-# (assigned, opened, synchronize, reopened)
+# (opened, synchronize, reopened)
on:
pull_request_target:
- types: [assigned, opened, synchronize, reopened]
+ types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
diff --git a/scripts/src/java/org/oppia/android/scripts/coverage/reporter/BUILD.bazel b/scripts/src/java/org/oppia/android/scripts/coverage/reporter/BUILD.bazel
index 85b59087cc2..217bc961aa1 100644
--- a/scripts/src/java/org/oppia/android/scripts/coverage/reporter/BUILD.bazel
+++ b/scripts/src/java/org/oppia/android/scripts/coverage/reporter/BUILD.bazel
@@ -15,5 +15,6 @@ kt_jvm_library(
"//scripts/src/java/org/oppia/android/scripts/common:bazel_client",
"//scripts/src/java/org/oppia/android/scripts/proto:coverage_java_proto",
"//scripts/src/java/org/oppia/android/scripts/proto:script_exemptions_java_proto",
+ "//third_party:com_google_guava_guava",
],
)
diff --git a/scripts/src/java/org/oppia/android/scripts/coverage/reporter/CoverageReporter.kt b/scripts/src/java/org/oppia/android/scripts/coverage/reporter/CoverageReporter.kt
index 31763392945..f447a58c256 100644
--- a/scripts/src/java/org/oppia/android/scripts/coverage/reporter/CoverageReporter.kt
+++ b/scripts/src/java/org/oppia/android/scripts/coverage/reporter/CoverageReporter.kt
@@ -1,5 +1,6 @@
package org.oppia.android.scripts.coverage.reporter
+import com.google.common.html.HtmlEscapers
import org.oppia.android.scripts.proto.Coverage
import org.oppia.android.scripts.proto.CoverageReport
import org.oppia.android.scripts.proto.CoverageReportContainer
@@ -277,7 +278,7 @@ class CoverageReporter(
"""
${lineNumber.toString().padStart(4, ' ')} |
- $line |
+ ${HtmlEscapers.htmlEscaper().escape(line)} |
""".trimIndent()
)
diff --git a/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt b/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt
index 7ef0183f00d..3d28a816c7d 100644
--- a/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt
+++ b/scripts/src/javatests/org/oppia/android/scripts/coverage/RunCoverageTest.kt
@@ -317,7 +317,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(kotlinFilePath)
- assertThat(readHtmlReport(kotlinFilePath)).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(kotlinFilePath)
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -342,7 +348,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(sourceFilePath)
- assertThat(readHtmlReport(sourceFilePath)).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(sourceFilePath)
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -541,7 +553,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePath)
- assertThat(readHtmlReport(filePath)).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePath)
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -1880,10 +1898,20 @@ class RunCoverageTest {
).execute()
val expectedResult1 = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult1)
+ val unescapedHtmlReport1 = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+ assertThat(unescapedHtmlReport1).isEqualTo(expectedResult1)
val expectedResult2 = getExpectedHtmlText(filePathList.get(1))
- assertThat(readHtmlReport(filePathList.get(1))).isEqualTo(expectedResult2)
+ val unescapedHtmlReport2 = readHtmlReport(filePathList.get(1))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+ assertThat(unescapedHtmlReport2).isEqualTo(expectedResult2)
}
@Test
@@ -1910,7 +1938,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -1937,7 +1971,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -1964,7 +2004,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -2009,7 +2055,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -2036,7 +2088,13 @@ class RunCoverageTest {
val expectedResult = getExpectedHtmlText(filePathList.get(0))
- assertThat(readHtmlReport(filePathList.get(0))).isEqualTo(expectedResult)
+ val unescapedHtmlReport = readHtmlReport(filePathList.get(0))
+ .replace(""", "\"")
+ .replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+
+ assertThat(unescapedHtmlReport).isEqualTo(expectedResult)
}
@Test
@@ -2262,7 +2320,13 @@ class RunCoverageTest {