-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[ci] Add debian-12 to matrix in packaging and platform jobs #116172
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
Changes from all commits
7fbc1ac
a122f0a
bd853eb
9402eaf
1e09b40
d3b0365
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ steps: | |
setup: | ||
image: | ||
- debian-11 | ||
- debian-12 | ||
- opensuse-leap-15 | ||
- oraclelinux-7 | ||
- oraclelinux-8 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ steps: | |
setup: | ||
image: | ||
- debian-11 | ||
- debian-12 | ||
- opensuse-leap-15 | ||
- oraclelinux-7 | ||
- oraclelinux-8 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ steps: | |
setup: | ||
image: | ||
- debian-11 | ||
- debian-12 | ||
- opensuse-leap-15 | ||
- oraclelinux-7 | ||
- oraclelinux-8 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,31 @@ | |
import junit.framework.TestCase; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
import org.elasticsearch.packaging.util.FileUtils; | ||
import org.elasticsearch.packaging.util.LintianResultParser; | ||
import org.elasticsearch.packaging.util.LintianResultParser.Issue; | ||
import org.elasticsearch.packaging.util.LintianResultParser.Result; | ||
import org.elasticsearch.packaging.util.Shell; | ||
import org.junit.BeforeClass; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile; | ||
import static org.junit.Assume.assumeTrue; | ||
|
||
public class DebMetadataTests extends PackagingTestCase { | ||
|
||
private final LintianResultParser lintianParser = new LintianResultParser(); | ||
private static final List<String> IGNORED_TAGS = List.of( | ||
// Override syntax changes between lintian versions in a non-backwards compatible way, so we have to tolerate these. | ||
// Tag mismatched-override is a non-erasable tag which cannot be ignored with overrides, so we handle it here. | ||
"mismatched-override", | ||
// systemd-service-file-outside-lib has been incorrect and removed in the newer version on Lintian | ||
"systemd-service-file-outside-lib" | ||
); | ||
|
||
@BeforeClass | ||
public static void filterDistros() { | ||
assumeTrue("only deb", distribution.packaging == Distribution.Packaging.DEB); | ||
|
@@ -35,15 +48,26 @@ public void test05CheckLintian() { | |
if (helpText.contains("--fail-on-warnings")) { | ||
extraArgs = "--fail-on-warnings"; | ||
} else if (helpText.contains("--fail-on error")) { | ||
extraArgs = "--fail-on warning"; | ||
// Recent lintian versions are picky about malformed or mismatched overrides. | ||
// Unfortunately override syntax changes between lintian versions in a non-backwards compatible | ||
// way, so we have to tolerate these (or maintain separate override files per lintian version). | ||
if (helpText.contains("--suppress-tags")) { | ||
extraArgs += " --suppress-tags malformed-override,mismatched-override"; | ||
extraArgs = "--fail-on error,warning"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lintian
|
||
} | ||
Shell.Result result = sh.runIgnoreExitCode( | ||
String.format(Locale.ROOT, "lintian %s %s", extraArgs, getDistributionFile(distribution())) | ||
); | ||
Result lintianResult = lintianParser.parse(result.stdout()); | ||
// Unfortunately Lintian overrides syntax changes between Lintian versions in a non-backwards compatible | ||
// way, so we have to manage some exclusions outside the overrides file. | ||
if (lintianResult.isSuccess() == false) { | ||
List<Issue> importantIssues = lintianResult.issues() | ||
.stream() | ||
.filter(issue -> IGNORED_TAGS.contains(issue.tag()) == false) | ||
.toList(); | ||
if (importantIssues.isEmpty() == false) { | ||
fail( | ||
"Issues for DEB package found by Lintian:\n" | ||
+ importantIssues.stream().map(Record::toString).collect(Collectors.joining("\n")) | ||
); | ||
Comment on lines
+53
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using exit code, the Lintian output is now parsed and some tags are ignored. It is needed, because in the newer version of Lintian tag |
||
} | ||
} | ||
sh.run(String.format(Locale.ROOT, "lintian %s %s", extraArgs, FileUtils.getDistributionFile(distribution()))); | ||
} | ||
|
||
public void test06Dependencies() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.packaging.util; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class LintianResultParser { | ||
|
||
private static final Logger logger = LogManager.getLogger(LintianResultParser.class); | ||
private static final Pattern RESULT_PATTERN = Pattern.compile("(?<severity>[EW]): (?<package>\\S+): (?<tag>\\S+) (?<message>.+)"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I've ever used "named" regex capture groups but I think I will going forward 👍 |
||
|
||
public Result parse(String output) { | ||
String[] lines = output.split("\n"); | ||
List<Issue> issues = Arrays.stream(lines).map(line -> { | ||
Matcher matcher = RESULT_PATTERN.matcher(line); | ||
if (matcher.matches() == false) { | ||
logger.info("Lintian output not matching expected pattern: {}", line); | ||
return null; | ||
} | ||
Severity severity = switch (matcher.group("severity")) { | ||
case "E" -> Severity.ERROR; | ||
case "W" -> Severity.WARNING; | ||
default -> Severity.UNKNOWN; | ||
}; | ||
return new Issue(severity, matcher.group("tag"), matcher.group("message")); | ||
}).filter(Objects::nonNull).toList(); | ||
|
||
return new Result(issues.stream().noneMatch(it -> it.severity == Severity.ERROR || it.severity == Severity.WARNING), issues); | ||
} | ||
|
||
public record Result(boolean isSuccess, List<Issue> issues) {} | ||
|
||
public record Issue(Severity severity, String tag, String message) {} | ||
|
||
enum Severity { | ||
ERROR, | ||
WARNING, | ||
UNKNOWN | ||
} | ||
} |
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.
Library
lsb-base
is now abandoned and marked as obsolete by Lintian. This lib is not available in Debian 12.As far as I understand it can be used for some logging function, but I couldn't find any direct calls to it from ES code.
The tests has passed on all DEB-based distributions so I assume it is safe to delete it.
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.
Presumable it's just because it brings in
sysvinit-utils
. @rjernst do you recall why this might be needed?