Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gha): displays extra data in gha output #154

Merged
merged 5 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ A full example of the `axe-devhub-action` can be seen at [`.github/workflows/tes

## Outputs

| name | description |
| ------------- | -------------------------------------------------- |
| `project` | Project associated with your API key |
| `axe_url` | URL for viewing axe issues detected on your commit |
| `issue_count` | Number of axe issues detected |
| name | description |
| ---------------------------- | -------------------------------------------------- |
| `project` | Project associated with your API key |
| `axe_url` | URL for viewing axe issues detected on your commit |
| `issue_count` | Number of axe issues detected |
| `created_at` | DateTime when run occurred |
| `resolved_issues` | Number of axe issues resolved |
| `difference_in_page_states` | Difference in number of page states detected |
| `page_states` | Number of page states detected |
| `issues_over_a11y_threshold` | Number of issues over a11y threshold |
40 changes: 34 additions & 6 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,55 @@ Response=$(
--url "$SERVER_URL/api-pub/v1/axe-watcher/gh/$COMMIT_SHA"
)

IssueCount=$(echo "$Response" | jq .last_run_violation_count)
LastRunCreatedAt=$(echo "$Response" | jq -r .last_run_created_at)
LastRunViolationCount=$(echo "$Response" | jq -r .last_run_violation_count)
LastRunPageStateCount=$(echo "$Response" | jq -r .last_run_page_state_count)
LastRunNewViolationCount=$(echo "$Response" | jq -r .last_run_new_violation_count)
LastRunResolvedViolationCount=$(echo "$Response" | jq -r .last_run_resolved_violation_count)
IssuesOverA11yThreshold=$(echo "$Response" | jq .issues_over_a11y_threshold)
AxeURL=$(echo "$Response" | jq -r .axe_url)
ProjectName=$(echo "$Response" | jq -r .project_name)
DifferenceInPageStateCount=$(echo "$Response" | jq -r .difference_in_page_states)

# Only set outs when running in GitHub Actions.
if [ -n "${GITHUB_OUTPUT+x}" ]; then
echo "project=$ProjectName" >>"$GITHUB_OUTPUT"
echo "axe_url=$SERVER_URL$AxeURL" >>"$GITHUB_OUTPUT"
echo "issue_count=$IssueCount" >>"$GITHUB_OUTPUT"
echo "created_at=$LastRunCreatedAt" >>"$GITHUB_OUTPUT"
davidg-dq marked this conversation as resolved.
Show resolved Hide resolved
echo "issue_count=$LastRunViolationCount" >>"$GITHUB_OUTPUT"
echo "new_issues=$LastRunNewViolationCount" >> "$GITHUB_OUTPUT"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_issues, resolved_issues, difference_in_page_states are all only meaningful if there was a previous session for us to compare to. In the comparable summary UI we use for list items in the devhub frontend's "commits" view, we omit them if there wasn't a previous session.

I wonder if it might make more sense for us to update the walnut route to specify those properties as undefined or null if there wasn't a previous session, and to omit them here (from both GITHUB_OUTPUT and stdout) if so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a great idea. Would you like me to go ahead and work on modifying the output from the walnut route?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that'd be good, but it doesn't have to block this PR

echo "resolved_issues=$LastRunResolvedViolationCount" >> "$GITHUB_OUTPUT"
echo "issues_over_a11y_threshold=$IssuesOverA11yThreshold" >>"$GITHUB_OUTPUT"
echo "difference_in_page_states=$DifferenceInPageStateCount" >> "$GITHUB_OUTPUT"
echo "page_states=$LastRunPageStateCount" >> "$GITHUB_OUTPUT"
fi

echo "Project: $ProjectName"
echo "axe DevHub found $IssueCount accessibility violations."
echo "axe Developer Hub accessibility results:"
echo "$LastRunViolationCount violations found"
echo "$LastRunPageStateCount page states found"
echo "$LastRunNewViolationCount new issues found"
echo "$LastRunResolvedViolationCount issues resolved"

existing_issues_count=$(( $LastRunViolationCount - $LastRunNewViolationCount ))
existing_issues_count=$(( existing_issues_count < 0 ? 0 : existing_issues_count ))

echo "$existing_issues_count previous issues remain"

if [ "$DifferenceInPageStateCount" -gt 0 ]; then
echo "$DifferenceInPageStateCount more page states"
elif [ "$DifferenceInPageStateCount" -lt 0 ]; then
AbsoluteDifference=$(( -DifferenceInPageStateCount ))
echo "$AbsoluteDifference fewer page states"
else
echo "No change in page state count"
fi

if [ "$ENABLE_A11Y_THRESHOLD" = "true" ]; then
echo "axe DevHub found $IssuesOverA11yThreshold accessibility violations over your a11y threshold."
echo "$IssuesOverA11yThreshold accessibility violations over your a11y threshold."
fi

echo "See the full report on axe DevHub: $SERVER_URL$AxeURL"
echo "See full report at $SERVER_URL$AxeURL"


if [ "$ENABLE_A11Y_THRESHOLD" = "true" ]; then
Expand All @@ -59,6 +87,6 @@ if [ "$ENABLE_A11Y_THRESHOLD" = "true" ]; then
fi
fi

if [ "$IssueCount" -gt 0 ]; then
if [ "$LastRunViolationCount" -gt 0 ]; then
exit 1
fi
Loading