Skip to content

Commit 4717770

Browse files
committed
Add support for Amazon Linux 2023 in CI
1 parent dfb0982 commit 4717770

6 files changed

Lines changed: 35 additions & 28 deletions

File tree

.github/scripts/prebuild.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ elif command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
7272
else
7373
echo "Skipping Android NDK installation on $dpkg_architecture" >&2
7474
fi
75-
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
75+
elif command -v dnf >/dev/null 2>&1 ; then # amazonlinux2023, rhel-ubi9
7676
$sudo dnf update -y
7777

7878
# Build dependencies
7979
$sudo dnf install -y sqlite-devel ncurses-devel python3
8080

8181
# Debug symbols
82+
$sudo dnf install -y 'dnf-command(debuginfo-install)'
8283
$sudo dnf debuginfo-install -y glibc
8384
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
8485
$sudo yum update -y

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
needs: [soundness, space-format-check]
1919
with:
2020
enable_cross_pr_testing: true
21-
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
21+
linux_os_versions: '["amazonlinux2", "amazonlinux2023", "bookworm", "noble", "jammy", "rhel-ubi9"]'
2222
linux_pre_build_command: ./.github/scripts/prebuild.sh
2323
linux_build_command: 'swift test --no-parallel'
2424
linux_swift_versions: '["nightly-main", "nightly-6.3"]'

Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,8 +1922,26 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u
19221922
public func discoveredLinkerToolsInfo(_ producer: any CommandProducer, _ delegate: any CoreClientTargetDiagnosticProducingDelegate, at toolPath: Path) async -> (any DiscoveredCommandLineToolSpecInfo)? {
19231923
do {
19241924
do {
1925+
// -version_details is an Apple ld specific option providing parseable output; try that first
19251926
let commandLine = [toolPath.str, "-version_details"]
19261927
return try await producer.discoveredCommandLineToolSpecInfo(delegate, nil, commandLine, { executionResult in
1928+
struct LDVersionDetails: Decodable {
1929+
let version: Version
1930+
let architectures: Set<String>
1931+
}
1932+
1933+
let details: LDVersionDetails
1934+
do {
1935+
details = try JSONDecoder().decode(LDVersionDetails.self, from: executionResult.stdout)
1936+
} catch {
1937+
throw CommandLineOutputJSONParsingError(commandLine: commandLine, data: executionResult.stdout, hostOS: producer.hostOperatingSystem)
1938+
}
1939+
1940+
return DiscoveredLdLinkerToolSpecInfo(linker: .ld64, toolPath: toolPath, toolVersion: details.version, architectures: details.architectures)
1941+
})
1942+
} catch let e as CommandLineOutputJSONParsingError {
1943+
let vCommandLine = [toolPath.str, "-v"]
1944+
return try await producer.discoveredCommandLineToolSpecInfo(delegate, nil, vCommandLine, { executionResult in
19271945
let gnuLD = [
19281946
#/GNU ld version (?<version>[\d.]+)-.*/#,
19291947
#/GNU ld \(GNU Binutils.*\) (?<version>[\d.]+)/#,
@@ -1934,8 +1952,8 @@ public func discoveredLinkerToolsInfo(_ producer: any CommandProducer, _ delegat
19341952

19351953
let goLD = [
19361954
#/GNU gold version (?<version>[\d.]+)-.*/#,
1937-
#/GNU gold \(GNU Binutils.*\) (?<version>[\d.]+)/#, // Ubuntu "GNU gold (GNU Binutils for Ubuntu 2.38) 1.16", Debian "GNU gold (GNU Binutils for Debian 2.40) 1.16"
1938-
#/GNU gold \(version .*\) (?<version>[\d.]+)/#, // Fedora "GNU gold (version 2.40-14.fc39) 1.16", RHEL "GNU gold (version 2.35.2-54.el9) 1.16", Amazon "GNU gold (version 2.29.1-31.amzn2.0.1) 1.14"
1955+
#/GNU gold \(GNU Binutils.*\) (?<version>[\d.]+)/#, // Ubuntu "GNU gold (GNU Binutils for Ubuntu 2.38) 1.16", Debian "GNU gold (GNU Binutils for Debian 2.40) 1.16"
1956+
#/GNU gold \(version .*\) (?<version>[\d.]+)/#, // Fedora "GNU gold (version 2.40-14.fc39) 1.16", RHEL "GNU gold (version 2.35.2-54.el9) 1.16", Amazon "GNU gold (version 2.29.1-31.amzn2.0.1) 1.14"
19391957
]
19401958

19411959
if let match = try goLD.compactMap({ try $0.firstMatch(in: String(decoding: executionResult.stdout, as: UTF8.self)) }).first {
@@ -1950,23 +1968,6 @@ public func discoveredLinkerToolsInfo(_ producer: any CommandProducer, _ delegat
19501968
return DiscoveredLdLinkerToolSpecInfo(linker: .linkExe, toolPath: toolPath, toolVersion: try Version(String(match.output.version)), architectures: Set())
19511969
}
19521970

1953-
struct LDVersionDetails: Decodable {
1954-
let version: Version
1955-
let architectures: Set<String>
1956-
}
1957-
1958-
let details: LDVersionDetails
1959-
do {
1960-
details = try JSONDecoder().decode(LDVersionDetails.self, from: executionResult.stdout)
1961-
} catch {
1962-
throw CommandLineOutputJSONParsingError(commandLine: commandLine, data: executionResult.stdout, hostOS: producer.hostOperatingSystem)
1963-
}
1964-
1965-
return DiscoveredLdLinkerToolSpecInfo(linker: .ld64, toolPath: toolPath, toolVersion: details.version, architectures: details.architectures)
1966-
})
1967-
} catch let e as CommandLineOutputJSONParsingError {
1968-
let vCommandLine = [toolPath.str, "-v"]
1969-
return try await producer.discoveredCommandLineToolSpecInfo(delegate, nil, vCommandLine, { executionResult in
19701971
let lld = [
19711972
#/LLD (?<version>[\d.]+).*/#,
19721973
]

Sources/SWBTestSupport/SkippedTestSupport.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ extension Trait where Self == Testing.ConditionTrait {
233233
}
234234
}
235235

236-
package static func requireSystemPackages(apt: String..., yum: String..., freebsd: String..., openbsd: String..., sourceLocation: SourceLocation = #_sourceLocation) -> Self {
236+
package static func requireSystemPackages(apt: String..., dnf: String..., freebsd: String..., openbsd: String..., sourceLocation: SourceLocation = #_sourceLocation) -> Self {
237237
enabled("required system packages are not installed") {
238238
func installCommand(packageManagerPath: Path, packageNames: String) -> String {
239239
switch packageManagerPath.basenameWithoutSuffix {
@@ -272,14 +272,19 @@ extension Trait where Self == Testing.ConditionTrait {
272272

273273
let apt = try await checkInstalled(hostOS: .linux, packageManagerPath: Path("/usr/bin/apt"), args: ["list", "--installed", "apt"], packages: apt, regex: #/(?<name>.+)\//#)
274274

275-
// spelled `--installed` in newer versions of yum, but Amazon Linux 2 is on older versions
276-
let yum = try await checkInstalled(hostOS: .linux, packageManagerPath: Path("/usr/bin/yum"), args: ["list", "installed", "yum"], packages: yum, regex: #/(?<name>.+)\./#)
275+
let dnf = try await {
276+
guard localFS.exists(Path("/usr/bin/dnf")) else {
277+
// spelled `--installed` in newer versions of yum, but Amazon Linux 2 is on older versions
278+
return try await checkInstalled(hostOS: .linux, packageManagerPath: Path("/usr/bin/yum"), args: ["list", "installed", "yum"], packages: dnf, regex: #/(?<name>.+)\./#)
279+
}
280+
return try await checkInstalled(hostOS: .linux, packageManagerPath: Path("/usr/bin/dnf"), args: ["list", "--installed", "dnf"], packages: dnf, regex: #/(?<name>.+)\./#)
281+
}()
277282

278283
let freebsd = try await checkInstalled(hostOS: .freebsd, packageManagerPath: Path("/usr/sbin/pkg"), args: ["info"], packages: freebsd, regex: #/^Name(?:[ ]+): (?<name>.+)$/#)
279284

280285
let openbsd = try await checkInstalled(hostOS: .openbsd, packageManagerPath: Path("/usr/sbin/pkg_info"), args: ["-A"], packages: openbsd, regex: #/^(?<name>.+)-.*/#)
281286

282-
return apt && yum && freebsd && openbsd
287+
return apt && dnf && freebsd && openbsd
283288
}
284289
}
285290

Tests/SWBBuildSystemTests/BuildOperationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
10021002
}
10031003

10041004
/// Check that environment variables are propagated from the user environment correctly.
1005-
@Test(.requireSDKs(.host), .skipHostOS(.windows), .requireSystemPackages(apt: "yacc", yum: "byacc"))
1005+
@Test(.requireSDKs(.host), .skipHostOS(.windows), .requireSystemPackages(apt: "yacc", dnf: "byacc"))
10061006
func userEnvironment() async throws {
10071007
try await withTemporaryDirectory { tmpDirPath async throws -> Void in
10081008
let testWorkspace = TestWorkspace(
@@ -2902,7 +2902,7 @@ That command depends on command in Target 'agg2' (project \'aProject\'): script
29022902
}
29032903

29042904
/// Check non-UTF8 encoded shell scripts don't cause any unexpected issues.
2905-
@Test(.requireSDKs(.host), .skipHostOS(.windows), .requireSystemPackages(apt: "xxd", yum: "vim-common", freebsd: "xxd", openbsd: "vim"))
2905+
@Test(.requireSDKs(.host), .skipHostOS(.windows), .requireSystemPackages(apt: "xxd", dnf: "vim-common", freebsd: "xxd", openbsd: "vim"))
29062906
func nonUTF8ShellScript() async throws {
29072907
try await withTemporaryDirectory { tmpDir in
29082908
let testWorkspace = TestWorkspace(

Tests/SWBCoreTests/CommandLineToolSpecDiscoveredInfoTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ import SWBMacro
242242
}
243243
}
244244

245-
@Test(.skipHostOS(.windows), .requireSystemPackages(apt: "libtool", yum: "libtool", freebsd: "libtool", openbsd: "libtool"))
245+
@Test(.skipHostOS(.windows), .requireSystemPackages(apt: "libtool", dnf: "libtool", freebsd: "libtool", openbsd: "libtool"))
246246
func discoveredLibtoolSpecInfo() async throws {
247247
try await withSpec(LibtoolLinkerSpec.self, .deferred) { (info: DiscoveredLibtoolLinkerToolSpecInfo) in
248248
#expect(info.toolPath.basename == "libtool")

0 commit comments

Comments
 (0)