Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
16 changes: 14 additions & 2 deletions .github/scripts/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ def pretty_time_duration(seconds: float) -> str:
required=False,
default="build/junit-xml/**/*.xml",
help="Path to XML files. Glob patterns are supported.")

parser.add_argument("--done-file",
required=False,
default="",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, why not set default value like build/junit-xml/done?

@mumrah mumrah Sep 7, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted this to be an optional argument so its easier to test locally. I don't feel too strongly about this, either way seems fine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "--path" has default value, so that is why I raise this comment 😃

For another trivial reason, we can simplify the command passed to junit parser if it has default value.

help="A file that signals the test suite was completed")
if not os.getenv("GITHUB_WORKSPACE"):
print("This script is intended to by run by GitHub Actions.")
exit(1)
Expand All @@ -153,7 +156,7 @@ def pretty_time_duration(seconds: float) -> str:

reports = glob(pathname=args.path, recursive=True)
logger.debug(f"Found {len(reports)} JUnit results")
workspace_path = get_env("GITHUB_WORKSPACE") # e.g., /home/runner/work/apache/kafka
workspace_path = get_env("GITHUB_WORKSPACE") # e.g., /home/runner/work/apache/kafka

total_file_count = 0
total_run = 0 # All test runs according to <testsuite tests="N"/>
Expand Down Expand Up @@ -248,6 +251,15 @@ def pretty_time_duration(seconds: float) -> str:
print(f"| {row_joined} |")
print("\n</details>")


# Print special message if these are partial results
if args.done_file:
if not os.path.exists(args.done_file):
logger.debug(f"Did not find done file '{args.done_file}'. These are partial results!")
logger.debug(summary)
logger.debug("Failing this step because done file was missing.")
exit(1)

logger.debug(summary)
if total_failures > 0:
logger.debug(f"Failing this step due to {total_failures} test failures")
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ jobs:
-PcommitId=xxxxxxxxxxxxxxxx \
test
- name: Archive JUnit reports
if: always()
uses: actions/upload-artifact@v4
id: junit-upload-artifact
with:
Expand All @@ -126,8 +125,7 @@ jobs:
**/build/reports/tests/test/*
if-no-files-found: ignore
- name: Parse JUnit tests
if: always()
run: python .github/scripts/junit.py >> $GITHUB_STEP_SUMMARY
run: python .github/scripts/junit.py --done-file build/junit-xml/done >> $GITHUB_STEP_SUMMARY
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,19 @@ gradle.taskGraph.whenReady { taskGraph ->
}
}

task createDoneFile() {
doLast {
def doneFile = rootProject.layout.buildDirectory.dir("junit-xml/done").get().asFile
doneFile.createNewFile()
}
}

tasks.named("test") {
if (System.getenv('GITHUB_ACTIONS') != null) {
finalizedBy "createDoneFile"
}
}

def fineTuneEclipseClasspathFile(eclipse, project) {
eclipse.classpath.file {
beforeMerged { cp ->
Expand Down