-
Notifications
You must be signed in to change notification settings - Fork 1
UID2-3858 verify no of tests run #141
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a1ca4d2
Add check for the number of tests run
cYKatherine dc4cc72
Add tests for number of tests run
cYKatherine 6bac3f5
Extract scripts
cYKatherine 9165378
Add checkout uid2-shared-actions step
cYKatherine 709d546
Exit when tests_run doesn't have value
cYKatherine 837cba8
Use parameter to pass in values
cYKatherine 3a44684
Change kcc-UID2-3858-verify-no-of-tests-run to v3
cYKatherine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -59,6 +59,13 @@ jobs: | |
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Checkout uid2-shared-actions repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: kcc-UID2-3858-verify-no-of-tests-run | ||
|
||
| repository: IABTechLab/uid2-shared-actions | ||
| path: uid2-shared-actions | ||
|
|
||
| - name: Set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
|
|
@@ -113,9 +120,11 @@ jobs: | |
|
|
||
| - name: Compile | ||
| if: ${{ inputs.publish_to_maven != true }} | ||
| env: | ||
| EXTRA_FLAGS: "-s settings.xml -Dgpg.passphrase=\"${{ secrets.GPG_PASSPHRASE }}\"" | ||
| run: | | ||
| cd ./${{ inputs.working_dir }} | ||
| mvn -B -s settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" clean compile test | ||
| bash uid2-shared-actions/scripts/compile_java_test_and_verify.sh -s settings.xml -D gpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" | ||
|
|
||
| - name: Commit pom.xml and version.json | ||
| if: ${{ steps.checkRelease.outputs.is_release != 'true' }} | ||
|
|
||
This file contains hidden or 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,70 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Function to display usage instructions | ||
| usage() { | ||
| echo "Usage: $0 [-s SETTINGS_FILE] [-D NAME=VALUE]" | ||
| echo " -s SETTINGS_FILE Specify Maven settings file" | ||
| echo " -D NAME=VALUE Set a system property (can be used multiple times)" | ||
| echo "Any remaining arguments will be passed directly to Maven." | ||
| exit 1 | ||
| } | ||
|
|
||
| # Initialize variables | ||
| settings_file="" | ||
| system_properties=() # Use an array for multiple -D options | ||
|
|
||
| # Parse command-line options | ||
| while getopts "s:D:" opt; do | ||
| case $opt in | ||
| s) | ||
| settings_file="-s $OPTARG" | ||
| ;; | ||
| D) | ||
| system_properties+=("-D$OPTARG") | ||
| ;; | ||
| \?) | ||
| echo "Invalid option: -$OPTARG" >&2 | ||
| usage | ||
| ;; | ||
| :) | ||
| echo "Option -$OPTARG requires an argument." >&2 | ||
| usage | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Shift off the processed options, leaving only the remaining arguments | ||
| shift "$((OPTIND-1))" | ||
|
|
||
| # Construct Maven command | ||
| mvn_command="mvn -B ${settings_file}" | ||
|
|
||
| # Add system properties to the command | ||
| for prop in "${system_properties[@]}"; do | ||
| mvn_command+=" ${prop}" | ||
| done | ||
|
|
||
| # Append any remaining arguments to the Maven command | ||
| mvn_command+=" $@" | ||
|
|
||
| # Add the fixed part of the Maven command | ||
| mvn_command+=" clean compile test" | ||
|
|
||
| echo "DEBUG: Executing Maven command: ${mvn_command}" | ||
| ${mvn_command} | tee build.log | ||
|
|
||
| tests_run=$(cat build.log | grep "Tests run:" | tail -n 1 | sed 's/.*Tests run: \([0-9]*\).*/\1/') | ||
|
|
||
| echo "DEBUG: tests_run = $tests_run" | ||
|
|
||
| if [ -z "$tests_run" ]; then | ||
| echo "WARNING: Could not determine the number of tests run." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$tests_run" -eq 0 ]; then | ||
| echo "ERROR: No tests were run!" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "INFO: $tests_run tests were run!" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to v3 before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the checkout of the repo necessary? Is it possible to use a reusable workflow instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was required for testing. Keep it here as Abu is doing some refactoring laster on so that we don't need to specify the branch name every where when we are testing in the future.