Skip to content

Commit

Permalink
enhance(audit): parse skipped webhooks and show messaging (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper authored Nov 1, 2023
1 parent fb65911 commit 9ba4e43
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cypress/fixtures/hooks_5.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"host": "github.com",
"event": "push",
"branch": "main",
"error": "",
"status": "success",
"error": "skipping build since only init and clone steps found — it is likely no rulesets matched for the webhook payload",
"status": "skipped",
"link": "https://github.com/github/octocat/settings/hooks"
},
{
Expand Down
21 changes: 21 additions & 0 deletions cypress/integration/hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ context('Hooks', () => {
beforeEach(() => {
cy.get('[data-test=hooks-row]').first().as('firstHook');
cy.get('[data-test=hooks-row]').last().as('lastHook');
cy.get('[data-test=hooks-row]').last().prev().prev().as('skipHook');
});
it('should show source id', () => {
cy.get('@firstHook').within(() => {
Expand Down Expand Up @@ -106,6 +107,26 @@ context('Hooks', () => {
});
});
});
context('skipped', () => {
beforeEach(() => {
cy.get('@skipHook').within(() => {
cy.get('.hook-status').as('skipped');
});
});
it('should have failure styles', () => {
cy.get('@skipped').should('have.class', '-skipped');
});
context('message', () => {
beforeEach(() => {
cy.get('[data-test=hooks-skipped]').as('message');
});
it('should show skip message', () => {
cy.get('@message').contains(
'skipping build since only init and clone steps found — it is likely no rulesets matched for the webhook payload',
);
});
});
});
context('successful redeliver hook', () => {
beforeEach(() => {
cy.redeliverHook();
Expand Down
28 changes: 22 additions & 6 deletions src/elm/Pages/Hooks.elm
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,26 @@ renderHookError hook =
)
|> Array.toList
|> List.filterMap identity

msgRow =
case hook.status of
"skipped" ->
tr [ class "skipped-data", Util.testAttribute "hooks-skipped" ]
[ td [ attribute "colspan" "6" ]
[ code [ class "skipped-content" ]
lines
]
]

_ ->
tr [ class "error-data", Util.testAttribute "hooks-error" ]
[ td [ attribute "colspan" "6" ]
[ code [ class "error-content" ]
lines
]
]
in
tr [ class "error-data", Util.testAttribute "hooks-error" ]
[ td [ attribute "colspan" "6" ]
[ code [ class "error-content" ]
lines
]
]
msgRow


{-| hookStatusToRowClass : takes hook status string and returns style class
Expand All @@ -226,5 +239,8 @@ hookStatusToRowClass status =
"success" ->
class "-success"

"skipped" ->
class "-skipped"

_ ->
class "-error"
21 changes: 21 additions & 0 deletions src/elm/SvgBuilder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,24 @@ hookSuccess =
]


{-| hookSkipped: produces the svg for the hook status skipped
-}
hookSkipped : Html msg
hookSkipped =
svg
[ class "hook-status"
, class "-skipped"
, strokeWidth "2"
, viewBox "0 0 44 44"
, width "20"
, height "20"
, ariaHidden
]
[ Svg.path [ attribute "vector-effect" "non-scaling-stroke", d "M15 20.1l6.923 6.9L42 5" ] []
, Svg.path [ attribute "vector-effect" "non-scaling-stroke", d "M43 22v16.333A4.668 4.668 0 0138.333 43H5.667A4.668 4.668 0 011 38.333V5.667A4.668 4.668 0 015.667 1h25.666" ] []
]


{-| hookFailure: produces the svg for the hook status failure
-}
hookFailure : Html msg
Expand Down Expand Up @@ -484,6 +502,9 @@ hookStatusToIcon status =
"success" ->
hookSuccess

"skipped" ->
hookSkipped

_ ->
hookFailure

Expand Down
26 changes: 26 additions & 0 deletions src/scss/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,39 @@ td .key .list-item {
}
}

.table-base tr.skipped-data {
color: var(--color-text);

border-bottom: 1px solid var(--color-bg-light);
border-left: 2px solid var(--color-cyan);

td {
padding-top: 0;
}
}

.table-base tr.-error {
border-bottom: none;
border-left: 2px solid var(--color-red);
}

.table-base tr.-skipped {
border-bottom: none;
border-left: 2px solid var(--color-cyan);
}

.table-base .error-content {
color: var(--color-red-light);
font-size: 0.8em;
white-space: pre-wrap;
}

.table-base .skipped-content {
color: var(--color-text);
font-size: 0.8em;
white-space: pre-wrap;
}

.hook-status {
fill: none;
}
Expand All @@ -121,6 +143,10 @@ td .key .list-item {
stroke: var(--color-green);
}

.hook-status.-skipped {
stroke: var(--color-cyan);
}

.hook-status.-failure {
stroke: var(--color-red);
}
Expand Down

0 comments on commit 9ba4e43

Please sign in to comment.