Skip to content

Commit 7f7332a

Browse files
committed
[GR-67309] Introduce API for opting out of "common" gate tasks for mx gate.
PullRequest: mx/1956
2 parents 2569418 + 827acf6 commit 7f7332a

File tree

4 files changed

+62
-26
lines changed

4 files changed

+62
-26
lines changed

ci/common.jsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ local common_json = import "../common.json";
316316

317317
wasm:: {
318318
downloads+: {
319-
WABT_DIR: {name: 'wabt', version: '1.0.36', platformspecific: true},
319+
WABT_DIR: {name: 'wabt', version: '1.0.37', platformspecific: true},
320320
},
321321
environment+: {
322322
WABT_DIR: '$WABT_DIR/bin',
@@ -325,7 +325,7 @@ local common_json = import "../common.json";
325325

326326
wasm_ol8:: {
327327
downloads+: {
328-
WABT_DIR: {name: 'wabt', version: '1.0.36-ol8', platformspecific: true},
328+
WABT_DIR: {name: 'wabt', version: '1.0.37-ol8', platformspecific: true},
329329
},
330330
environment+: {
331331
WABT_DIR: '$WABT_DIR/bin',

common.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "7.62.1",
7+
"mx_version": "7.62.2",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
@@ -55,12 +55,12 @@
5555
"graalvm-ee-25-ea": {"name": "graalvm-jdk", "version": "25.0.0", "ea": "36", "platformspecific": true },
5656

5757
"oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+37", "platformspecific": true, "extrabundles": ["static-libs"]},
58-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02", "platformspecific": true },
59-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02-debug", "platformspecific": true },
60-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+37-jvmci-b02-sulong", "platformspecific": true },
61-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02", "platformspecific": true },
62-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02-debug", "platformspecific": true },
63-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+37-jvmci-b02-sulong", "platformspecific": true }
58+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+37-jvmci-b05", "platformspecific": true },
59+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+37-jvmci-b05-debug", "platformspecific": true },
60+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+37-jvmci-b05-sulong", "platformspecific": true },
61+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+37-jvmci-b05", "platformspecific": true },
62+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+37-jvmci-b05-debug", "platformspecific": true },
63+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+37-jvmci-b05-sulong", "platformspecific": true }
6464
},
6565

6666
"eclipse": {

src/mx/_impl/mx_gate.py

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"Task",
3030
"add_gate_argument",
3131
"add_gate_runner",
32+
"opt_out_common_gate_tasks",
3233
"prepend_gate_runner",
3334
"add_omit_clean_args",
3435
"gate_clean",
@@ -111,6 +112,10 @@ class Task:
111112
verbose = False
112113
startTime = None
113114

115+
explicit_common = False
116+
explicit_common_tasks = []
117+
explicit_common_tags = []
118+
114119
def tag_matches(self, _tags):
115120
for t in _tags:
116121
assert isinstance(t, str), f'{t} is not a string and thus not a valid tag'
@@ -145,7 +150,8 @@ def __init__(self, title,
145150
tags=None,
146151
legacyTitles=None,
147152
description=None,
148-
report=None):
153+
report=None,
154+
_common=False):
149155
"""
150156
:param report: if not None, then `make_test_report` is called when this task ends.
151157
The component used for the report will be the name of the primary suite
@@ -190,6 +196,14 @@ def __init__(self, title,
190196
else:
191197
_tags = self.tags if self.tags else []
192198
self.skipped = not self.tag_matches(_tags)
199+
if not self.skipped and _common and Task.explicit_common:
200+
# if this is a common task, and we're not already skipping it for another reason (e.g. commandline arguments)
201+
# decide whether to skip based on the opt_out_common_gate_tasks setting of the primary suite
202+
self.skipped = True
203+
if title in Task.explicit_common_tasks:
204+
self.skipped = False
205+
if any(t in Task.explicit_common_tags for t in self.tags):
206+
self.skipped = False
193207
if not self.skipped:
194208
self.start = time.time()
195209
self.end = None
@@ -258,6 +272,7 @@ def __repr__(self):
258272
_gate_runners = []
259273
_pre_gate_runners = []
260274
_extra_gate_arguments = []
275+
_explicit_common_tasks = []
261276

262277
def add_gate_argument(*args, **kwargs):
263278
"""
@@ -285,6 +300,18 @@ def prepend_gate_runner(suite, runner):
285300
suiteRunner = (suite, runner)
286301
_pre_gate_runners.append(suiteRunner)
287302

303+
def opt_out_common_gate_tasks(suite, include=None, include_tags=None):
304+
"""
305+
Opt out of common gate tasks if this suite is the primary suite.
306+
307+
include: A list of common task names that should be kept.
308+
include_tags: A list of common task tags that should be kept.
309+
310+
This only affects the common tasks defined by mx itself. The suite itself can redefine tags removed
311+
with this function.
312+
"""
313+
_explicit_common_tasks.append((suite, include, include_tags))
314+
288315
def add_omit_clean_args(parser):
289316
parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
290317
parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
@@ -294,7 +321,7 @@ def add_omit_clean_args(parser):
294321
parser.add_argument('-o', '--omit-clean', action='store_true', dest='noClean', help='equivalent to -j -n -e')
295322

296323
def gate_clean(cleanArgs, tasks, name='Clean', tags=None):
297-
with Task(name, tasks, tags=tags) as t:
324+
with Task(name, tasks, tags=tags, _common=True) as t:
298325
if t:
299326
mx.command_function('clean')(cleanArgs)
300327

@@ -401,6 +428,15 @@ def gate(args):
401428
elif args.x:
402429
mx.abort('-x option cannot be used without --task-filter, --strict-task-filter, or the --tags option')
403430

431+
if not args.all_suites:
432+
for (s, include, include_tags) in _explicit_common_tasks:
433+
if s is mx.primary_suite():
434+
Task.explicit_common = True
435+
if include is not None:
436+
Task.explicit_common_tasks += include
437+
if include_tags is not None:
438+
Task.explicit_common_tags += include_tags
439+
404440
if args.jacoco_zip:
405441
args.jacocout = 'html'
406442

@@ -681,13 +717,13 @@ def _test(value, expect, open_fp):
681717

682718
def _run_gate(cleanArgs, args, tasks):
683719
global _jacoco
684-
with Task('Versions', tasks, tags=[Tags.always]) as t:
720+
with Task('Versions', tasks, tags=[Tags.always], _common=True) as t:
685721
if t:
686722
mx.command_function('version')(['--oneline'])
687723
mx.command_function('sversions')([])
688724
mx.log(f"Python version: {sys.version_info}")
689725

690-
with Task('JDKReleaseInfo', tasks, tags=[Tags.always]) as t:
726+
with Task('JDKReleaseInfo', tasks, tags=[Tags.always], _common=True) as t:
691727
if t:
692728
jdkDirs = os.pathsep.join([mx.get_env('JAVA_HOME', ''), mx.get_env('EXTRA_JAVA_HOMES', '')])
693729
for jdkDir in jdkDirs.split(os.pathsep):
@@ -702,7 +738,7 @@ def _run_gate(cleanArgs, args, tasks):
702738
if t:
703739
_run_mx_suite_tests()
704740

705-
with Task('VerifyMultiReleaseProjects', tasks, tags=[Tags.always]) as t:
741+
with Task('VerifyMultiReleaseProjects', tasks, tags=[Tags.always], _common=True) as t:
706742
if t:
707743
mx.command_function('verifymultireleaseprojects')([])
708744

@@ -712,37 +748,37 @@ def _run_gate(cleanArgs, args, tasks):
712748
runner(args, tasks)
713749

714750
if mx.primary_suite().getMxCompatibility().gate_run_pyformat():
715-
with Task("Format python code", tasks, tags=[Tags.style]) as t:
751+
with Task("Format python code", tasks, tags=[Tags.style], _common=True) as t:
716752
if t:
717753
if mx.command_function("pyformat")(["--dry-run"]) != 0:
718754
mx.abort_or_warn("Python formatting tools not configured correctly", args.strict_mode)
719755

720-
with Task('Pylint', tasks, tags=[Tags.style]) as t:
756+
with Task('Pylint', tasks, tags=[Tags.style], _common=True) as t:
721757
if t:
722758
if mx.command_function('pylint')(['--primary']) != 0:
723759
mx.abort_or_warn('Pylint not configured correctly. Cannot execute Pylint task.', args.strict_mode)
724760

725761
if not args.noClean:
726762
gate_clean(cleanArgs, tasks, tags=[Tags.build, Tags.fullbuild, Tags.ecjbuild])
727763

728-
with Task('Distribution Overlap Check', tasks, tags=[Tags.style]) as t:
764+
with Task('Distribution Overlap Check', tasks, tags=[Tags.style], _common=True) as t:
729765
if t:
730766
if mx.command_function('checkoverlap')([]) != 0:
731767
t.abort('Found overlapping distributions.')
732768

733-
with Task('Canonicalization Check', tasks, tags=[Tags.style]) as t:
769+
with Task('Canonicalization Check', tasks, tags=[Tags.style], _common=True) as t:
734770
if t:
735771
mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...'))
736772
if mx.command_function('canonicalizeprojects')([]) != 0:
737773
t.abort('Rerun "mx canonicalizeprojects" and modify the suite.py files as suggested.')
738774

739-
with Task('Verify Java Sources in Project', tasks, tags=[Tags.style]) as t:
775+
with Task('Verify Java Sources in Project', tasks, tags=[Tags.style], _common=True) as t:
740776
if t:
741777
mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring all Java sources are in a Java project directory...'))
742778
if mx.command_function('verifysourceinproject')([]) != 0:
743779
t.abort('Move or delete the Java sources that are not in a Java project directory.')
744780

745-
with Task('BuildWithEcj', tasks, tags=[Tags.fullbuild, Tags.ecjbuild], legacyTitles=['BuildJavaWithEcj']) as t:
781+
with Task('BuildWithEcj', tasks, tags=[Tags.fullbuild, Tags.ecjbuild], legacyTitles=['BuildJavaWithEcj'], _common=True) as t:
746782
if t:
747783
defaultBuildArgs = ['-p']
748784
if not args.no_warning_as_error:
@@ -754,20 +790,20 @@ def _run_gate(cleanArgs, args, tasks):
754790
if fullbuild:
755791
gate_clean(cleanArgs + ['--keep-logs'], tasks, name='CleanAfterEcjBuild', tags=[Tags.fullbuild])
756792

757-
with Task('BuildWithJavac', tasks, tags=[Tags.build, Tags.fullbuild], legacyTitles=['BuildJavaWithJavac']) as t:
793+
with Task('BuildWithJavac', tasks, tags=[Tags.build, Tags.fullbuild], legacyTitles=['BuildJavaWithJavac'], _common=True) as t:
758794
if t:
759795
defaultBuildArgs = ['-p']
760796
if not args.no_warning_as_error:
761797
defaultBuildArgs += ['--warning-as-error']
762798
mx.command_function('build')(defaultBuildArgs + ['--force-javac'] + args.extra_build_args)
763799

764-
with Task('IDEConfigCheck', tasks, tags=[Tags.fullbuild]) as t:
800+
with Task('IDEConfigCheck', tasks, tags=[Tags.fullbuild], _common=True) as t:
765801
if t:
766802
if args.cleanIDE:
767803
mx.command_function('ideclean')([])
768804
mx.command_function('ideinit')([])
769805

770-
with Task('CodeFormatCheck', tasks, tags=[Tags.style]) as t:
806+
with Task('CodeFormatCheck', tasks, tags=[Tags.style], _common=True) as t:
771807
if t:
772808
eclipse_exe = mx.get_env('ECLIPSE_EXE')
773809
if eclipse_exe is not None:
@@ -776,11 +812,11 @@ def _run_gate(cleanArgs, args, tasks):
776812
else:
777813
mx.abort_or_warn('ECLIPSE_EXE environment variable not set. Cannot execute CodeFormatCheck task.', args.strict_mode)
778814

779-
with Task('Checkstyle', tasks, tags=[Tags.style]) as t:
815+
with Task('Checkstyle', tasks, tags=[Tags.style], _common=True) as t:
780816
if t and mx.command_function('checkstyle')(['--primary']) != 0:
781817
t.abort('Checkstyle warnings were found')
782818

783-
with Task('SpotBugs', tasks, tags=[Tags.fullbuild]) as t:
819+
with Task('SpotBugs', tasks, tags=[Tags.fullbuild], _common=True) as t:
784820
_spotbugs_strict_mode_args = ['--strict-mode'] if args.strict_mode and mx.primary_suite().getMxCompatibility().gate_spotbugs_strict_mode() else []
785821
_spotbugs_primary_args = ["--primary"] if mx.primary_suite().getMxCompatibility().spotbugs_primary_support() else []
786822
if t and mx.command_function('spotbugs')(_spotbugs_strict_mode_args + _spotbugs_primary_args) != 0:

src/mx/mx_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
2-
version = "7.62.2" # GR-67014 Add ECJ ver 3.43
2+
version = "7.63.0" # GR-67309 opt out of common `mx gate` tasks

0 commit comments

Comments
 (0)