Skip to content

Commit 59271f5

Browse files
committed
ci
1 parent 066533a commit 59271f5

File tree

5 files changed

+57
-119
lines changed

5 files changed

+57
-119
lines changed

.github/workflows/ci.yaml

+2-78
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,14 @@ on:
33
pull_request:
44
push:
55
branches:
6-
- master
6+
- ci
77
concurrency:
88
# Cancels pending runs when a PR gets updated.
99
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
1010
cancel-in-progress: true
1111
jobs:
12-
x86_64-linux-debug:
13-
timeout-minutes: 420
14-
runs-on: [self-hosted, Linux, x86_64]
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v3
18-
- name: Build and Test
19-
run: sh ci/x86_64-linux-debug.sh
20-
x86_64-linux-release:
21-
timeout-minutes: 420
22-
runs-on: [self-hosted, Linux, x86_64]
23-
steps:
24-
- name: Checkout
25-
uses: actions/checkout@v3
26-
- name: Build and Test
27-
run: sh ci/x86_64-linux-release.sh
28-
aarch64-linux-debug:
29-
timeout-minutes: 480
30-
runs-on: [self-hosted, Linux, aarch64]
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v3
34-
- name: Build and Test
35-
run: sh ci/aarch64-linux-debug.sh
36-
aarch64-linux-release:
37-
timeout-minutes: 480
38-
runs-on: [self-hosted, Linux, aarch64]
39-
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v3
42-
- name: Build and Test
43-
run: sh ci/aarch64-linux-release.sh
44-
x86_64-macos-release:
45-
runs-on: "macos-11"
46-
env:
47-
ARCH: "x86_64"
48-
steps:
49-
- name: Checkout
50-
uses: actions/checkout@v3
51-
- name: Build and Test
52-
run: ci/x86_64-macos-release.sh
53-
aarch64-macos-debug:
54-
runs-on: [self-hosted, macOS, aarch64]
55-
env:
56-
ARCH: "aarch64"
57-
steps:
58-
- name: Checkout
59-
uses: actions/checkout@v3
60-
- name: Build and Test
61-
run: ci/aarch64-macos-debug.sh
62-
aarch64-macos-release:
63-
runs-on: [self-hosted, macOS, aarch64]
64-
env:
65-
ARCH: "aarch64"
66-
steps:
67-
- name: Checkout
68-
uses: actions/checkout@v3
69-
- name: Build and Test
70-
run: ci/aarch64-macos-release.sh
71-
x86_64-windows-debug:
72-
runs-on: windows-latest
73-
env:
74-
ARCH: "x86_64"
75-
steps:
76-
- name: Checkout
77-
uses: actions/checkout@v3
78-
- name: Build and Test
79-
run: ci/x86_64-windows-debug.ps1
8012
x86_64-windows-release:
13+
timeout-minutes: 120
8114
runs-on: windows-latest
8215
env:
8316
ARCH: "x86_64"
@@ -86,12 +19,3 @@ jobs:
8619
uses: actions/checkout@v3
8720
- name: Build and Test
8821
run: ci/x86_64-windows-release.ps1
89-
aarch64-windows:
90-
runs-on: [self-hosted, Windows, aarch64]
91-
env:
92-
ARCH: "aarch64"
93-
steps:
94-
- name: Checkout
95-
uses: actions/checkout@v3
96-
- name: Build and Test
97-
run: ci/aarch64-windows.ps1

ci/x86_64-windows-release.ps1

+1-39
Original file line numberDiff line numberDiff line change
@@ -53,48 +53,10 @@ ninja install
5353
CheckLastExitCode
5454

5555
Write-Output "Main test suite..."
56-
& "stage3-release\bin\zig.exe" build test docs `
56+
& "stage3-release\bin\zig.exe" build test `
5757
--zig-lib-dir "$ZIG_LIB_DIR" `
5858
--search-prefix "$PREFIX_PATH" `
5959
-Dstatic-llvm `
6060
-Dskip-non-native `
6161
-Denable-symlinks-windows
6262
CheckLastExitCode
63-
64-
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
65-
& "stage3-release\bin\zig.exe" test `
66-
..\test\behavior.zig `
67-
--zig-lib-dir "$ZIG_LIB_DIR" `
68-
-ofmt=c `
69-
-femit-bin="test-x86_64-windows-msvc.c" `
70-
--test-no-exec `
71-
-target x86_64-windows-msvc `
72-
-lc
73-
CheckLastExitCode
74-
75-
& "stage3-release\bin\zig.exe" build-obj `
76-
--zig-lib-dir "$ZIG_LIB_DIR" `
77-
-ofmt=c `
78-
-OReleaseSmall `
79-
--name compiler_rt `
80-
-femit-bin="compiler_rt-x86_64-windows-msvc.c" `
81-
--dep build_options `
82-
-target x86_64-windows-msvc `
83-
--mod root ..\lib\compiler_rt.zig `
84-
--mod build_options config.zig
85-
CheckLastExitCode
86-
87-
Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
88-
CheckLastExitCode
89-
90-
Enter-VsDevShell -VsInstallPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" `
91-
-DevCmdArguments '-arch=x64 -no_logo' `
92-
-StartInPath $(Get-Location)
93-
CheckLastExitCode
94-
95-
Write-Output "Build and run behavior tests with msvc..."
96-
& cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib
97-
CheckLastExitCode
98-
99-
& .\test-x86_64-windows-msvc.exe
100-
CheckLastExitCode

lib/std/Build/Step.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ pub fn evalZigProcess(
405405
child.stdin.?.close();
406406
child.stdin = null;
407407

408-
const term = child.wait() catch |err| {
408+
const term = child.waitTimeout() catch |err| {
409409
return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(err) });
410410
};
411411
s.result_duration_ns = timer.read();

lib/std/Build/Step/Run.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ fn spawnChildAndCollect(
10721072
else
10731073
evalGeneric(self, &child);
10741074

1075-
const term = try child.wait();
1075+
const term = try child.waitTimeout();
10761076
const elapsed_ns = timer.read();
10771077

10781078
return .{

lib/std/child_process.zig

+52
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ pub const ChildProcess = struct {
262262
return term;
263263
}
264264

265+
pub fn waitTimeout(self: *ChildProcess) !Term {
266+
const term = if (builtin.os.tag == .windows)
267+
try self.waitWindowsTimeout()
268+
else
269+
try self.waitPosix();
270+
271+
self.id = undefined;
272+
273+
return term;
274+
}
275+
265276
pub const RunResult = struct {
266277
term: Term,
267278
stdout: []u8,
@@ -371,6 +382,16 @@ pub const ChildProcess = struct {
371382
return self.term.?;
372383
}
373384

385+
fn waitWindowsTimeout(self: *ChildProcess) !Term {
386+
if (self.term) |term| {
387+
self.cleanupStreams();
388+
return term;
389+
}
390+
391+
try self.waitUnwrappedWindowsTimeout();
392+
return self.term.?;
393+
}
394+
374395
fn waitPosix(self: *ChildProcess) !Term {
375396
if (self.term) |term| {
376397
self.cleanupStreams();
@@ -403,6 +424,37 @@ pub const ChildProcess = struct {
403424
return result;
404425
}
405426

427+
fn waitUnwrappedWindowsTimeout(self: *ChildProcess) (windows.WaitForSingleObjectError || windows.GetProcessMemoryInfoError)!void {
428+
const result = windows.WaitForSingleObjectEx(self.id, std.time.ms_per_hour / 2, false) catch |err| switch (err) {
429+
error.WaitTimeOut => {
430+
_ = self.kill() catch |kill_err| {
431+
std.debug.print("kill: {}\n", .{kill_err});
432+
return err;
433+
};
434+
return;
435+
},
436+
else => {},
437+
};
438+
439+
self.term = @as(SpawnError!Term, x: {
440+
var exit_code: windows.DWORD = undefined;
441+
if (windows.kernel32.GetExitCodeProcess(self.id, &exit_code) == 0) {
442+
break :x Term{ .Unknown = 0 };
443+
} else {
444+
break :x Term{ .Exited = @as(u8, @truncate(exit_code)) };
445+
}
446+
});
447+
448+
if (self.request_resource_usage_statistics) {
449+
self.resource_usage_statistics.rusage = try windows.GetProcessMemoryInfo(self.id);
450+
}
451+
452+
os.close(self.id);
453+
os.close(self.thread_handle);
454+
self.cleanupStreams();
455+
return result;
456+
}
457+
406458
fn waitUnwrapped(self: *ChildProcess) !void {
407459
const res: os.WaitPidResult = res: {
408460
if (self.request_resource_usage_statistics) {

0 commit comments

Comments
 (0)