Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
JavaReleaseMenu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱鹏程
JavaReleaseMenu
Commits
c86ed293
Commit
c86ed293
authored
Nov 18, 2026
by
zpc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish release interface and expose locked batch progress and outcomes
parent
cd3a975e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
228 additions
and
6 deletions
+228
-6
Info.plist
Info.plist
+2
-2
ProjectSettings.swift
Sources/JavaReleaseMenu/ProjectSettings.swift
+6
-1
ReleaseStyle.swift
Sources/JavaReleaseMenu/ReleaseStyle.swift
+40
-1
SplitReleaseModel.swift
Sources/JavaReleaseMenu/SplitReleaseModel.swift
+73
-2
SplitReleasePanel.swift
Sources/JavaReleaseMenu/SplitReleasePanel.swift
+0
-0
ReleaseRunnerTests.swift
Tests/ReleaseCoreTests/ReleaseRunnerTests.swift
+107
-0
No files found.
Info.plist
View file @
c86ed293
...
...
@@ -19,9 +19,9 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
APPL
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.4.
1
<
/string
>
<
string
>
1.4.
2
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
string
>
1
1
<
/string
>
<
string
>
1
2
<
/string
>
<
k
e
y
>
LSMinimumSystemVersion
<
/k
e
y
>
<
string
>
14.0
<
/string
>
<
k
e
y
>
LSUIElement
<
/k
e
y
>
...
...
Sources/JavaReleaseMenu/ProjectSettings.swift
View file @
c86ed293
...
...
@@ -21,6 +21,7 @@ struct ProjectSettings: View {
Label
(
"新建项目"
,
systemImage
:
"plus"
)
}
.
buttonStyle
(
SettingsButtonStyle
())
.
help
(
"创建新的本地项目配置"
)
}
.
padding
(
.
horizontal
,
22
)
.
padding
(
.
vertical
,
17
)
...
...
@@ -38,6 +39,7 @@ struct ProjectSettings: View {
.
menuStyle
(
.
borderlessButton
)
.
menuIndicator
(
.
hidden
)
.
accessibilityLabel
(
"已保存的项目"
)
.
help
(
"选择一个项目来查看和编辑设置"
)
}
section
(
"项目"
,
icon
:
"folder"
)
{
...
...
@@ -96,6 +98,7 @@ struct ProjectSettings: View {
}
}
.
labelsHidden
()
.
help
(
"默认优先 mvnd,未安装时使用 mvn;也可明确选择 mvn"
)
}
mavenField
(
"mvn"
,
path
:
$
draft
.
mavenPath
)
mavenField
(
"mvnd"
,
path
:
$
draft
.
mvndPath
)
...
...
@@ -128,6 +131,7 @@ struct ProjectSettings: View {
Button
(
"保存"
,
action
:
save
)
.
buttonStyle
(
SettingsButtonStyle
(
prominent
:
true
))
.
keyboardShortcut
(
.
defaultAction
)
.
help
(
"检查并保存当前项目设置"
)
}
}
.
padding
(
.
horizontal
,
22
)
...
...
@@ -285,6 +289,7 @@ struct ProjectSettings: View {
private
struct
SettingsButtonStyle
:
ButtonStyle
{
var
prominent
=
false
@Environment(\.isEnabled)
private
var
enabled
func
makeBody
(
configuration
:
Configuration
)
->
some
View
{
configuration
.
label
...
...
@@ -295,7 +300,7 @@ private struct SettingsButtonStyle: ButtonStyle {
.
modifier
(
ReleaseHover
(
base
:
prominent
?
ReleaseColors
.
action
:
ReleaseColors
.
surface
,
highlight
:
prominent
?
ReleaseColors
.
actionHover
:
ReleaseColors
.
hover
,
radius
:
6
))
.
overlay
{
RoundedRectangle
(
cornerRadius
:
6
)
.
strokeBorder
(
ReleaseColors
.
border
)
.
allowsHitTesting
(
false
)
}
.
opacity
(
configuration
.
isPressed
?
0.72
:
1
)
.
opacity
(
!
enabled
?
0.4
:
configuration
.
isPressed
?
0.72
:
1
)
.
contentShape
(
Rectangle
())
}
}
Sources/JavaReleaseMenu/ReleaseStyle.swift
View file @
c86ed293
...
...
@@ -8,6 +8,9 @@ enum ReleaseColors {
static
let
muted
=
Color
(
red
:
0.62
,
green
:
0.66
,
blue
:
0.73
)
static
let
blue
=
Color
(
red
:
0.31
,
green
:
0.62
,
blue
:
1
)
static
let
action
=
Color
(
red
:
0.13
,
green
:
0.35
,
blue
:
0.86
)
static
let
success
=
Color
(
red
:
0.32
,
green
:
0.80
,
blue
:
0.54
)
static
let
warning
=
Color
(
red
:
0.98
,
green
:
0.68
,
blue
:
0.31
)
static
let
danger
=
Color
(
red
:
1
,
green
:
0.40
,
blue
:
0.42
)
static
let
hover
=
Color
(
red
:
0.17
,
green
:
0.22
,
blue
:
0.29
)
static
let
actionHover
=
Color
(
red
:
0.20
,
green
:
0.46
,
blue
:
0.98
)
}
...
...
@@ -41,6 +44,8 @@ struct ReleaseButtonStyle: ButtonStyle {
var
base
:
Color
=
.
clear
var
prominent
=
false
var
radius
:
CGFloat
=
7
var
disabledOpacity
:
Double
=
0.40
@Environment(\.isEnabled)
private
var
enabled
func
makeBody
(
configuration
:
Configuration
)
->
some
View
{
configuration
.
label
...
...
@@ -50,6 +55,40 @@ struct ReleaseButtonStyle: ButtonStyle {
highlight
:
prominent
?
ReleaseColors
.
actionHover
:
ReleaseColors
.
hover
,
radius
:
radius
)
)
.
opacity
(
configuration
.
isPressed
?
0.82
:
1
)
.
opacity
(
!
enabled
?
disabledOpacity
:
configuration
.
isPressed
?
0.82
:
1
)
}
}
struct
ReleaseIconButton
:
View
{
let
symbol
:
String
let
title
:
String
var
tint
:
Color
=
ReleaseColors
.
muted
let
action
:
()
->
Void
var
body
:
some
View
{
Button
(
action
:
action
)
{
Image
(
systemName
:
symbol
)
.
font
(
.
system
(
size
:
12
,
weight
:
.
medium
))
.
foregroundStyle
(
tint
)
.
frame
(
width
:
28
,
height
:
28
)
.
contentShape
(
RoundedRectangle
(
cornerRadius
:
6
))
}
.
buttonStyle
(
ReleaseButtonStyle
(
radius
:
6
))
.
help
(
title
)
.
accessibilityLabel
(
title
)
}
}
struct
ReleaseStatusBadge
:
View
{
let
title
:
String
let
symbol
:
String
let
color
:
Color
var
body
:
some
View
{
Label
(
title
,
systemImage
:
symbol
)
.
font
(
.
system
(
size
:
10
,
weight
:
.
medium
))
.
foregroundStyle
(
color
)
.
padding
(
.
horizontal
,
7
)
.
padding
(
.
vertical
,
4
)
.
background
(
color
.
opacity
(
0.10
),
in
:
Capsule
())
}
}
Sources/JavaReleaseMenu/SplitReleaseModel.swift
View file @
c86ed293
...
...
@@ -2,6 +2,19 @@ import Foundation
import
Observation
import
ReleaseCore
struct
ReleaseRunSummary
{
let
total
:
Int
let
completed
:
Int
let
running
:
Int
let
queued
:
Int
let
succeeded
:
Int
let
failed
:
Int
let
skipped
:
Int
let
isBatch
:
Bool
let
isPaused
:
Bool
let
estimatedPercentage
:
Int
}
private
struct
SavedPane
:
Codable
{
var
id
:
UUID
var
projectID
:
UUID
...
...
@@ -33,6 +46,8 @@ final class ReleasePaneState: Identifiable {
var
search
=
""
var
availableModules
:
[
String
]
=
[]
var
servers
:
[
InventoryTarget
]
=
[]
var
loadingServers
=
false
var
inventoryError
:
String
?
var
state
:
State
=
.
idle
var
phase
:
ReleasePhase
?
var
result
:
ReleaseResult
?
...
...
@@ -96,10 +111,13 @@ final class ReleasePaneState: Identifiable {
func
refreshServers
(
for
project
:
ReleaseProject
)
{
inventoryTask
?
.
cancel
()
servers
=
[]
inventoryError
=
nil
loadingServers
=
project
.
type
==
.
cityKeeper
guard
project
.
type
==
.
cityKeeper
else
{
return
}
inventoryTask
=
Task
{
let
targets
=
await
Task
.
detached
{
Result
{
try
project
.
inventoryTargets
()
}
}
.
value
guard
!
Task
.
isCancelled
else
{
return
}
loadingServers
=
false
switch
targets
{
case
let
.
success
(
found
):
servers
=
found
...
...
@@ -107,7 +125,7 @@ final class ReleasePaneState: Identifiable {
self
.
server
=
nil
}
case
let
.
failure
(
error
):
self
.
e
rror
=
error
.
localizedDescription
inventoryE
rror
=
error
.
localizedDescription
}
}
}
...
...
@@ -140,6 +158,7 @@ final class SplitReleaseModel {
private
var
unread
=
false
private
var
runIDs
=
Set
<
UUID
>
()
private
var
runResults
:
[
UUID
:
ReleaseResult
]
=
[:]
private
var
skippedIDs
=
Set
<
UUID
>
()
private
var
batchStarted
:
Date
?
private
var
completionTask
:
Task
<
Void
,
Never
>
?
private(set)
var
completionDuration
:
Int
?
...
...
@@ -186,12 +205,62 @@ final class SplitReleaseModel {
var
progressPercentage
:
Int
?
{
let
active
=
panes
.
filter
{
runIDs
.
contains
(
$0
.
id
)
}
guard
isRunning
,
!
runIDs
.
isEmpty
else
{
return
nil
}
let
completed
=
runResults
.
count
let
completed
=
runResults
.
count
+
skippedIDs
.
count
let
partial
=
active
.
filter
{
$0
.
state
==
.
running
}
.
reduce
(
0
)
{
$0
+
(
$1
.
phase
?
.
estimatedPercentage
??
0
)
}
return
min
(
99
,
(
completed
*
100
+
partial
)
/
runIDs
.
count
)
}
var
runSummary
:
ReleaseRunSummary
?
{
guard
!
runIDs
.
isEmpty
else
{
return
nil
}
let
active
=
panes
.
filter
{
runIDs
.
contains
(
$0
.
id
)
&&
$0
.
state
==
.
running
}
return
ReleaseRunSummary
(
total
:
runIDs
.
count
,
completed
:
runResults
.
count
,
running
:
active
.
count
,
queued
:
queued
.
count
,
succeeded
:
runResults
.
values
.
filter
{
$0
.
status
==
.
succeeded
}
.
count
,
failed
:
runResults
.
values
.
filter
{
$0
.
status
!=
.
succeeded
}
.
count
,
skipped
:
skippedIDs
.
count
,
isBatch
:
batch
,
isPaused
:
!
active
.
isEmpty
&&
active
.
allSatisfy
(\
.
paused
),
estimatedPercentage
:
progressPercentage
??
100
)
}
func
readinessMessage
(
for
pane
:
ReleasePaneState
)
->
String
?
{
guard
let
project
=
project
(
for
:
pane
)
else
{
return
"请先选择项目"
}
if
pane
.
modules
.
isEmpty
{
return
"请选择至少一个模块"
}
if
project
.
type
==
.
cityKeeper
{
if
pane
.
profileID
==
nil
||
!
project
.
profiles
.
contains
(
where
:
{
$0
.
id
==
pane
.
profileID
})
{
return
"请选择发布配置"
}
if
pane
.
loadingServers
{
return
"正在读取服务器清单…"
}
if
pane
.
inventoryError
!=
nil
{
return
"服务器清单读取失败,请检查 hosts 配置"
}
if
!
ReleaseProject
.
containsInventoryTarget
(
pane
.
server
??
""
,
in
:
pane
.
servers
)
{
return
"请选择发布服务器"
}
}
return
nil
}
func
canPublish
(
_
pane
:
ReleasePaneState
)
->
Bool
{
!
isRunning
&&
readinessMessage
(
for
:
pane
)
==
nil
}
var
canPublishAll
:
Bool
{
panes
.
count
>
1
&&
!
isRunning
&&
panes
.
allSatisfy
{
readinessMessage
(
for
:
$0
)
==
nil
}
}
var
publishAllHelp
:
String
{
if
isRunning
{
return
"发布正在执行,完成后可再次发布;进度为按阶段估算"
}
if
panes
.
count
<
2
{
return
"增加一个不同项目的窗口后可一起发布"
}
if
let
pane
=
panes
.
first
(
where
:
{
readinessMessage
(
for
:
$0
)
!=
nil
}),
let
message
=
readinessMessage
(
for
:
pane
)
{
return
"
\(
project
(
for
:
pane
)?
.
name
??
"项目"
)
:
\(
message
)
"
}
return
"发布所有窗口中的项目;存在构建或服务器冲突时会自动排队"
}
var
indicator
:
ReleaseStatus
?
{
if
isRunning
{
return
nil
}
if
completionTask
!=
nil
{
return
.
succeeded
}
...
...
@@ -325,6 +394,7 @@ final class SplitReleaseModel {
batchStarted
=
Date
()
runIDs
=
Set
(
prepared
.
map
{
$0
.
pane
.
id
})
runResults
.
removeAll
()
skippedIDs
.
removeAll
()
if
together
,
prepared
.
count
>
1
{
let
cityJobs
=
prepared
.
filter
{
$0
.
project
.
type
==
.
cityKeeper
&&
$0
.
action
==
.
standard
...
...
@@ -423,6 +493,7 @@ final class SplitReleaseModel {
jobs
.
removeValue
(
forKey
:
pane
.
id
)
if
result
.
status
!=
.
succeeded
&&
batch
{
for
id
in
queued
{
skippedIDs
.
insert
(
id
)
jobs
[
id
]?
.
pane
.
state
=
.
skipped
jobs
[
id
]?
.
pane
.
error
=
"前序项目失败,未执行"
jobs
.
removeValue
(
forKey
:
id
)
...
...
Sources/JavaReleaseMenu/SplitReleasePanel.swift
View file @
c86ed293
This diff is collapsed.
Click to expand it.
Tests/ReleaseCoreTests/ReleaseRunnerTests.swift
View file @
c86ed293
...
...
@@ -61,6 +61,113 @@ final class ReleaseRunnerTests: XCTestCase {
XCTAssertTrue
(
restored
.
panes
.
contains
{
$0
.
log
.
contains
(
"first task completed"
)
})
}
@MainActor
func
testBatchProgressLocksRepeatedSubmissionAndReportsCompletion
()
async
throws
{
let
first
=
try
Fixture
()
let
second
=
try
Fixture
()
defer
{
first
.
remove
();
second
.
remove
()
}
for
fixture
in
[
first
,
second
]
{
try
"printf 'launch
\\
n' >> launch-count
\n
sleep 0.4
\n
printf 'done
\\
n'
\n
"
.
write
(
to
:
fixture
.
local
.
appending
(
path
:
"release.sh"
),
atomically
:
true
,
encoding
:
.
utf8
)
}
let
storage
=
first
.
base
.
appending
(
path
:
"progress-state"
)
let
settings
=
AppModel
(
storage
:
storage
)
var
alpha
=
first
.
project
;
alpha
.
name
=
"Alpha"
var
beta
=
second
.
project
;
beta
.
name
=
"Beta"
try
settings
.
save
(
alpha
);
try
settings
.
save
(
beta
)
settings
.
projectID
=
alpha
.
id
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
model
.
add
()
XCTAssertTrue
(
model
.
canPublishAll
)
model
.
publishAll
()
let
initial
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
initial
.
total
,
2
)
XCTAssertEqual
(
initial
.
running
,
1
)
XCTAssertEqual
(
initial
.
queued
,
1
)
XCTAssertEqual
(
initial
.
completed
,
0
)
XCTAssertFalse
(
model
.
canPublishAll
)
XCTAssertTrue
(
model
.
publishAllHelp
.
contains
(
"正在执行"
))
model
.
publishAll
()
model
.
publish
(
model
.
panes
[
0
])
XCTAssertEqual
(
model
.
runSummary
?
.
total
,
2
)
for
_
in
0
..<
300
where
model
.
isRunning
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
10
))
}
let
completed
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
completed
.
completed
,
2
)
XCTAssertEqual
(
completed
.
succeeded
,
2
)
XCTAssertEqual
(
completed
.
failed
,
0
)
XCTAssertEqual
(
completed
.
queued
,
0
)
XCTAssertEqual
(
completed
.
estimatedPercentage
,
100
)
XCTAssertTrue
(
model
.
canPublishAll
)
for
fixture
in
[
first
,
second
]
{
let
count
=
try
String
(
contentsOf
:
fixture
.
local
.
appending
(
path
:
"launch-count"
),
encoding
:
.
utf8
)
XCTAssertEqual
(
count
.
split
(
separator
:
"
\n
"
)
.
count
,
1
)
}
}
@MainActor
func
testReadinessExplainsMissingModulesConfigurationAndServer
()
async
throws
{
let
fixture
=
try
Fixture
()
defer
{
fixture
.
remove
()
}
try
fixture
.
createCityKeeperFixture
()
var
project
=
fixture
.
project
project
.
type
=
.
cityKeeper
project
.
inventoryPath
=
"hosts"
project
.
toolPath
=
fixture
.
local
.
appending
(
path
:
"bin"
)
.
path
let
storage
=
fixture
.
base
.
appending
(
path
:
"readiness-state"
)
let
settings
=
AppModel
(
storage
:
storage
)
try
settings
.
save
(
project
)
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
let
pane
=
try
XCTUnwrap
(
model
.
panes
.
first
)
pane
.
modules
=
[]
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"模块"
))
pane
.
modules
=
[
"gateway"
]
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"配置"
))
var
profile
=
DeployProfile
();
profile
.
file
=
"deploy.yaml"
project
.
profiles
=
[
profile
]
try
settings
.
save
(
project
)
pane
.
profileID
=
profile
.
id
for
_
in
0
..<
100
where
pane
.
loadingServers
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
20
))
}
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"服务器"
))
pane
.
server
=
try
XCTUnwrap
(
pane
.
servers
.
first
?
.
name
)
XCTAssertTrue
(
model
.
canPublish
(
pane
))
pane
.
loadingServers
=
true
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"正在读取"
))
pane
.
loadingServers
=
false
pane
.
inventoryError
=
"inventory failed"
XCTAssertFalse
(
model
.
canPublish
(
pane
))
XCTAssertTrue
(
try
XCTUnwrap
(
model
.
readinessMessage
(
for
:
pane
))
.
contains
(
"读取失败"
))
}
@MainActor
func
testFailedBatchSummaryIncludesUnstartedProjects
()
async
throws
{
let
first
=
try
Fixture
()
let
second
=
try
Fixture
()
defer
{
first
.
remove
();
second
.
remove
()
}
try
"printf 'failure
\\
n'
\n
exit 3
\n
"
.
write
(
to
:
first
.
local
.
appending
(
path
:
"release.sh"
),
atomically
:
true
,
encoding
:
.
utf8
)
let
storage
=
first
.
base
.
appending
(
path
:
"failed-summary"
)
let
settings
=
AppModel
(
storage
:
storage
)
var
alpha
=
first
.
project
;
alpha
.
name
=
"Alpha"
var
beta
=
second
.
project
;
beta
.
name
=
"Beta"
try
settings
.
save
(
alpha
);
try
settings
.
save
(
beta
)
settings
.
projectID
=
alpha
.
id
let
model
=
SplitReleaseModel
(
settings
:
settings
,
storage
:
storage
)
model
.
add
()
model
.
publishAll
()
for
_
in
0
..<
200
where
model
.
isRunning
{
try
await
Task
.
sleep
(
for
:
.
milliseconds
(
10
))
}
let
summary
=
try
XCTUnwrap
(
model
.
runSummary
)
XCTAssertEqual
(
summary
.
total
,
2
)
XCTAssertEqual
(
summary
.
completed
,
1
)
XCTAssertEqual
(
summary
.
failed
,
1
)
XCTAssertEqual
(
summary
.
skipped
,
1
)
XCTAssertEqual
(
summary
.
queued
,
0
)
model
.
remove
(
model
.
panes
[
1
])
XCTAssertEqual
(
model
.
runSummary
?
.
skipped
,
1
)
XCTAssertEqual
(
model
.
indicator
,
.
failed
)
}
@MainActor
func
testIdlePaneCanCloseWhileAnotherReleaseRuns
()
async
throws
{
let
first
=
try
Fixture
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment