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

Add validation for platform strings to exclude_parser.py #5651

Merged
merged 4 commits into from
Dec 2, 2024

Conversation

jiekang
Copy link
Contributor

@jiekang jiekang commented Sep 26, 2024

Fixes: #5650

@jiekang jiekang marked this pull request as draft September 26, 2024 01:27
@jiekang
Copy link
Contributor Author

jiekang commented Sep 26, 2024

@smlambert Would appreciate your thoughts here on the approach before I exit Draft.

And maybe I need to update the GH actions somewhere to fail when this exits with code 1?
And are there other things I can validate while I'm here?

@sophia-guo
Copy link
Contributor

Alternative of global ERROR_FOUND ( needed for all log.error) to fail the github check is adding custom handler.

class ErrorTrackingHandler(logging.Handler):
    def __init__(self):
        super().__init__()
        self.error_logged = False

    def emit(self, record):
        if record.levelno >= logging.ERROR:
            self.error_logged = True

LOG = logging.getLogger("my_custom_logger")
...

# Add the custom error-tracking handler
error_tracker = ErrorTrackingHandler()
LOG.addHandler(error_tracker)

...
# Check if any ERROR or higher-level messages were logged
if error_tracker.error_logged:
    print("Errors were logged, exiting with error.")
    sys.exit(1)

@jiekang jiekang marked this pull request as ready for review November 28, 2024 19:26
@jiekang
Copy link
Contributor Author

jiekang commented Nov 28, 2024

This change now:

  1. Updates the entire program to exit with error when an 'Error' is logged
  2. Logs an error when multiple spaces are detected in the platform string
  3. Only parses files in the directory specified by --exclude-dir

Due to how the code is structured, an error is logged whenever an exception is raised. This will now mean any of those cases will cause the process to exit with code 1. This is overall an improvement as it now covers validating the format of the entire exclude string:

<Testclass> <URL_to_open_issue> <os-arch_comma-separatedList>

@jiekang
Copy link
Contributor Author

jiekang commented Nov 28, 2024

This is a breaking change, the process will now exit with code 1 when:

  • A file exists in the exclude directory that does not match the ProblemList regex ProblemList_openjdk(?P<jdk_version>\\d+)-?(?P<jdk_impl>.*).txt
  • The exclude file to parse is not a file
  • The format of an exclude string does not fit <Testclass> <URL_to_open_issue> <os-arch_comma-separatedList>
  • The os-arch cannot be split via (?<!x86)(?<!alpine)-

Copy link
Contributor

@smlambert smlambert left a comment

Choose a reason for hiding this comment

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

This looks very good to me, thanks @jiekang! Have you use a personal repo to do some basic testing (as many of us end up doing with these workflow PRs)?

@sophia-guo sophia-guo merged commit de802c7 into adoptium:master Dec 2, 2024
2 checks passed
@sophia-guo
Copy link
Contributor

sophia-guo commented Dec 2, 2024

Based on this change, it detected following errors with openjdk problemlist (current supports jdk version, 8,11,17,21,23,24)

ERROR - ./openjdk/excludes/ProblemList_openjdk23.txt:151 : Not exactly 3 elements when splitting java/net/DatagramSocket/GetLocalAddress.java #3088 aix-ppc64, linux-ppc64le
ERROR - ./openjdk/excludes/ProblemList_openjdk23.txt:189 : Not exactly 3 elements when splitting java/io/File/GetXSpace.java https://bugs.openjdk.java.net/browse/JDK-8251466 windows-all, linux-arm, aix-all
ERROR - ./openjdk/excludes/ProblemList_openjdk21.txt:141 : Not exactly 3 elements when splitting java/net/DatagramSocket/GetLocalAddress.java #3088 aix-ppc64, linux-ppc64le
ERROR - ./openjdk/excludes/ProblemList_openjdk21.txt:179 : Not exactly 3 elements when splitting java/io/File/GetXSpace.java https://bugs.openjdk.java.net/browse/JDK-8251466 windows-all, linux-arm, aix-all

ERROR - ./openjdk/excludes/ProblemList_openjdk23.txt:151 : Not exactly 3 elements when splitting java/net/DatagramSocket/GetLocalAddress.java #3088 aix-ppc64, linux-ppc64le
ERROR - ./openjdk/excludes/ProblemList_openjdk23.txt:189 : Not exactly 3 elements when splitting java/io/File/GetXSpace.java https://bugs.openjdk.java.net/browse/JDK-8251466 windows-all, linux-arm, aix-all
ERROR - ./openjdk/excludes/ProblemList_openjdk24.txt:151 : Not exactly 3 elements when splitting java/net/DatagramSocket/GetLocalAddress.java #3088 aix-ppc64, linux-ppc64le
ERROR - ./openjdk/excludes/ProblemList_openjdk24.txt:189 : Not exactly 3 elements when splitting java/io/File/GetXSpace.java https://bugs.openjdk.java.net/browse/JDK-8251466 windows-all, linux-arm, aix-all

@jiekang would you be able to do a following PR to fix those? I believe with this PR in, any PR with changes in openjdk/exclude will also trigger those errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update exclude_parser.py to error when ProblemList format has issues
3 participants