Skip to content

Commit 13e8d5b

Browse files
authored
Merge branch 'main' into send-tar-hash
2 parents 5141faf + 21dabb7 commit 13e8d5b

45 files changed

Lines changed: 323 additions & 271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr-build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,35 @@ on:
88
types: [opened, reopened, synchronize]
99

1010
jobs:
11+
verify-signatures:
12+
name: Verify commit signatures
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check all commits are signed
16+
env:
17+
GH_TOKEN: ${{ github.token }}
18+
run: |
19+
commits=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits --paginate)
20+
unsigned_commits=""
21+
22+
while IFS='|' read -r sha author verified; do
23+
if [ "$verified" != "true" ]; then
24+
unsigned_commits="$unsigned_commits - $sha by $author\n"
25+
fi
26+
done < <(echo "$commits" | jq -r '.[] | "\(.sha)|\(.commit.author.name)|\(.commit.verification.verified)"')
27+
28+
if [ -n "$unsigned_commits" ]; then
29+
echo "::error::The following commits are not signed:"
30+
echo -e "$unsigned_commits"
31+
echo ""
32+
echo "Please sign your commits. See:"
33+
echo " - https://github.com/apple/containerization/blob/main/CONTRIBUTING.md#pull-requests"
34+
echo " - https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits"
35+
exit 1
36+
fi
37+
38+
echo "All commits are signed!"
39+
1140
build:
1241
name: Invoke build
1342
uses: ./.github/workflows/common.yml

.github/workflows/pr-label-apply.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,12 @@ jobs:
2929
run-id: ${{ github.event.workflow_run.id }}
3030
pattern: pr-metadata-*
3131
merge-multiple: false
32-
continue-on-error: true
3332
id: download-artifact
3433

3534
- name: Read PR number
3635
id: pr-number
3736
run: |
38-
METADATA_DIR=$(find . -type d -name "pr-metadata-*" 2>/dev/null | head -n 1)
39-
40-
if [ -z "$METADATA_DIR" ]; then
41-
echo "No metadata found"
42-
exit 1
43-
fi
44-
45-
PR_NUMBER=$(cat "${METADATA_DIR}/pr-number.txt")
37+
PR_NUMBER=$(cat "pr-number.txt")
4638
echo "number=${PR_NUMBER}" >> $GITHUB_OUTPUT
4739
echo "PR Number: ${PR_NUMBER}"
4840

BUILDING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Attach debugger to the XPC helpers using their launchd service labels:
137137
% container system start
138138
% container run -d --name test debian:bookworm sleep infinity
139139
test
140-
% launchd list | grep container
140+
% launchctl list | grep container
141141
27068 0 com.apple.container.container-network-vmnet.default
142142
27072 0 com.apple.container.container-core-images
143143
26980 0 com.apple.container.apiserver

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import PackageDescription
2323
let releaseVersion = ProcessInfo.processInfo.environment["RELEASE_VERSION"] ?? "0.0.0"
2424
let gitCommit = ProcessInfo.processInfo.environment["GIT_COMMIT"] ?? "unspecified"
2525
let builderShimVersion = "0.8.0"
26-
let scVersion = "0.24.5"
26+
let scVersion = "0.25.0"
2727

2828
let package = Package(
2929
name: "container",

Sources/ContainerBuild/BuildImageResolver.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ struct BuildImageResolver: BuildPipelineHandler {
2626
let contentStore: ContentStore
2727
let quiet: Bool
2828
let output: FileHandle
29+
let pull: Bool
2930

30-
public init(_ contentStore: ContentStore, quiet: Bool = false, output: FileHandle = FileHandle.standardError) throws {
31+
public init(_ contentStore: ContentStore, quiet: Bool = false, output: FileHandle = FileHandle.standardError, pull: Bool = false) throws {
3132
self.contentStore = contentStore
3233
self.quiet = quiet
3334
self.output = output
35+
self.pull = pull
3436
}
3537

3638
func accept(_ packet: ServerStream) throws -> Bool {
@@ -72,6 +74,9 @@ struct BuildImageResolver: BuildPipelineHandler {
7274
defer { progress.finish() }
7375
progress.start()
7476

77+
if self.pull {
78+
return try await ClientImage.pull(reference: ref, platform: platform, progressUpdate: progress.handler)
79+
}
7580
// Use fetch() which checks cache first, then pulls if needed
7681
return try await ClientImage.fetch(reference: ref, platform: platform, progressUpdate: progress.handler)
7782
}()

Sources/ContainerBuild/BuildPipelineHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public actor BuildPipeline {
3030
[
3131
try BuildFSSync(URL(filePath: config.contextDir)),
3232
try BuildRemoteContentProxy(config.contentStore),
33-
try BuildImageResolver(config.contentStore, quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
33+
try BuildImageResolver(config.contentStore, quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError, pull: config.pull),
3434
try BuildStdio(quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
3535
]
3636
}

Sources/ContainerBuild/Builder.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public struct Builder: Sendable {
251251
public let exports: [BuildExport]
252252
public let cacheIn: [String]
253253
public let cacheOut: [String]
254+
public let pull: Bool
254255

255256
public init(
256257
buildID: String,
@@ -268,6 +269,7 @@ public struct Builder: Sendable {
268269
exports: [BuildExport],
269270
cacheIn: [String],
270271
cacheOut: [String],
272+
pull: Bool
271273
) {
272274
self.buildID = buildID
273275
self.contentStore = contentStore
@@ -284,6 +286,7 @@ public struct Builder: Sendable {
284286
self.exports = exports
285287
self.cacheIn = cacheIn
286288
self.cacheOut = cacheOut
289+
self.pull = pull
287290
}
288291
}
289292
}

Sources/ContainerCommands/BuildCommand.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ extension Application {
131131
@Argument(help: "Build directory")
132132
var contextDir: String = "."
133133

134+
@Flag(name: .long, help: "Pull latest image")
135+
var pull: Bool = false
136+
134137
public func run() async throws {
135138
do {
136139
let timeout: Duration = .seconds(300)
@@ -153,10 +156,10 @@ extension Application {
153156
}
154157

155158
group.addTask { [vsockPort, cpus, memory, log, dnsNameservers] in
159+
let client = ContainerClient()
156160
while true {
157161
do {
158-
let container = try await ClientContainer.get(id: "buildkit")
159-
let fh = try await container.dial(vsockPort)
162+
let fh = try await client.dial(id: "buildkit", port: vsockPort)
160163

161164
let threadGroup: MultiThreadedEventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
162165
let b = try Builder(socket: fh, group: threadGroup)
@@ -313,7 +316,7 @@ extension Application {
313316
}
314317
return results
315318
}()
316-
group.addTask { [terminal, buildArg, contextDir, label, noCache, target, quiet, cacheIn, cacheOut] in
319+
group.addTask { [terminal, buildArg, contextDir, label, noCache, target, quiet, cacheIn, cacheOut, pull] in
317320
let config = Builder.BuildConfig(
318321
buildID: buildID,
319322
contentStore: RemoteContentStoreClient(),
@@ -329,7 +332,8 @@ extension Application {
329332
quiet: quiet,
330333
exports: exports,
331334
cacheIn: cacheIn,
332-
cacheOut: cacheOut
335+
cacheOut: cacheOut,
336+
pull: pull
333337
)
334338
progress.finish()
335339

Sources/ContainerCommands/Builder/BuilderDelete.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ extension Application {
3939

4040
public func run() async throws {
4141
do {
42-
let container = try await ClientContainer.get(id: "buildkit")
42+
let client = ContainerClient()
43+
let container = try await client.get(id: "buildkit")
4344
if container.status != .stopped {
4445
guard force else {
4546
throw ContainerizationError(.invalidState, message: "BuildKit container is not stopped, use --force to override")
4647
}
47-
try await container.stop()
48+
try await client.stop(id: container.id)
4849
}
49-
try await container.delete()
50+
try await client.delete(id: container.id)
5051
} catch {
5152
if error is ContainerizationError {
5253
if (error as? ContainerizationError)?.code == .notFound {

0 commit comments

Comments
 (0)