Skip to content

Commit cb095d1

Browse files
committed
fix
1 parent 5675efb commit cb095d1

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

routers/web/devtest/mock_actions.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func generateMockStepsLog(logCur actions.LogCursor) (stepsLog []*actions.ViewSte
2626
"::endgroup::",
2727
"message for: step={step}, cursor={cursor}",
2828
"message for: step={step}, cursor={cursor}",
29-
"message for: step={step}, cursor={cursor}",
30-
"message for: step={step}, cursor={cursor}",
31-
"message for: step={step}, cursor={cursor}",
29+
"##[group]test group for: step={step}, cursor={cursor}",
30+
"in group msg for: step={step}, cursor={cursor}",
31+
"::endgroup::",
3232
}
3333
cur := logCur.Cursor // usually the cursor is the "file offset", but here we abuse it as "line number" to make the mock easier, intentionally
3434
for i := 0; i < util.Iif(logCur.Step == 0, 3, 1); i++ {
@@ -52,6 +52,10 @@ func MockActionsRunsJobs(ctx *context.Context) {
5252
req := web.GetForm(ctx).(*actions.ViewRequest)
5353

5454
resp := &actions.ViewResponse{}
55+
resp.State.Run.TitleHTML = `mock run title <a href="/">link</a>`
56+
resp.State.Run.Status = actions_model.StatusRunning.String()
57+
resp.State.Run.CanCancel = true
58+
resp.State.Run.CanDeleteArtifact = true
5559
resp.Artifacts = append(resp.Artifacts, &actions.ArtifactsViewItem{
5660
Name: "artifact-a",
5761
Size: 100 * 1024,

web_src/js/components/RepoActionView.vue

+37-11
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,27 @@ type LogLine = {
1616
message: string;
1717
};
1818
19-
const LogLinePrefixGroup = '::group::';
20-
const LogLinePrefixEndGroup = '::endgroup::';
19+
const LogLinePrefixesGroup = ['::group::', '##[group]'];
20+
const LogLinePrefixesEndGroup = ['::endgroup::', '##[endgroup]'];
21+
22+
type LogLineCommand = {
23+
name: 'group' | 'endgroup',
24+
prefix: string,
25+
}
26+
27+
function parseLineCommand(line: LogLine): LogLineCommand | null {
28+
for (const prefix of LogLinePrefixesGroup) {
29+
if (line.message.startsWith(prefix)) {
30+
return {name: 'group', prefix};
31+
}
32+
}
33+
for (const prefix of LogLinePrefixesEndGroup) {
34+
if (line.message.startsWith(prefix)) {
35+
return {name: 'endgroup', prefix};
36+
}
37+
}
38+
return null;
39+
}
2140
2241
const sfc = {
2342
name: 'RepoActionView',
@@ -123,19 +142,20 @@ const sfc = {
123142
},
124143
125144
methods: {
145+
126146
// get the active container element, either the `job-step-logs` or the `job-log-list` in the `job-log-group`
127147
getLogsContainer(stepIndex: number) {
128148
const el = this.$refs.logs[stepIndex];
129149
return el._stepLogsActiveContainer ?? el;
130150
},
131151
// begin a log group
132-
beginLogGroup(stepIndex: number, startTime: number, line: LogLine) {
152+
beginLogGroup(stepIndex: number, startTime: number, line: LogLine, cmd: LogLineCommand) {
133153
const el = this.$refs.logs[stepIndex];
134154
const elJobLogGroupSummary = createElementFromAttrs('summary', {class: 'job-log-group-summary'},
135155
this.createLogLine(stepIndex, startTime, {
136156
index: line.index,
137157
timestamp: line.timestamp,
138-
message: line.message.substring(LogLinePrefixGroup.length),
158+
message: line.message.substring(cmd.prefix.length),
139159
}),
140160
);
141161
const elJobLogList = createElementFromAttrs('div', {class: 'job-log-list'});
@@ -147,13 +167,13 @@ const sfc = {
147167
el._stepLogsActiveContainer = elJobLogList;
148168
},
149169
// end a log group
150-
endLogGroup(stepIndex: number, startTime: number, line: LogLine) {
170+
endLogGroup(stepIndex: number, startTime: number, line: LogLine, cmd: LogLineCommand) {
151171
const el = this.$refs.logs[stepIndex];
152172
el._stepLogsActiveContainer = null;
153173
el.append(this.createLogLine(stepIndex, startTime, {
154174
index: line.index,
155175
timestamp: line.timestamp,
156-
message: line.message.substring(LogLinePrefixEndGroup.length),
176+
message: line.message.substring(cmd.prefix.length),
157177
}));
158178
},
159179
@@ -201,11 +221,12 @@ const sfc = {
201221
appendLogs(stepIndex: number, startTime: number, logLines: LogLine[]) {
202222
for (const line of logLines) {
203223
const el = this.getLogsContainer(stepIndex);
204-
if (line.message.startsWith(LogLinePrefixGroup)) {
205-
this.beginLogGroup(stepIndex, startTime, line);
224+
const cmd = parseLineCommand(line);
225+
if (cmd?.name === 'group') {
226+
this.beginLogGroup(stepIndex, startTime, line, cmd);
206227
continue;
207-
} else if (line.message.startsWith(LogLinePrefixEndGroup)) {
208-
this.endLogGroup(stepIndex, startTime, line);
228+
} else if (cmd?.name === 'endgroup') {
229+
this.endLogGroup(stepIndex, startTime, line, cmd);
209230
continue;
210231
}
211232
el.append(this.createLogLine(stepIndex, startTime, line));
@@ -393,7 +414,7 @@ export function initRepositoryActionView() {
393414
<button class="ui basic small compact button red" @click="cancelRun()" v-else-if="run.canCancel">
394415
{{ locale.cancel }}
395416
</button>
396-
<button class="ui basic small compact button tw-mr-0 tw-whitespace-nowrap link-action" :data-url="`${run.link}/rerun`" v-else-if="run.canRerun">
417+
<button class="ui basic small compact button link-action" :data-url="`${run.link}/rerun`" v-else-if="run.canRerun">
397418
{{ locale.rerun_all }}
398419
</button>
399420
</div>
@@ -539,6 +560,11 @@ export function initRepositoryActionView() {
539560
overflow-wrap: anywhere;
540561
}
541562
563+
.action-info-summary .ui.button {
564+
margin: 0;
565+
white-space: nowrap;
566+
}
567+
542568
.action-commit-summary {
543569
display: flex;
544570
flex-wrap: wrap;

0 commit comments

Comments
 (0)