diff --git a/Dockerfile b/Dockerfile index c662bf3..0a95989 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ LABEL "com.github.actions.description"="Run tests on a webpage via Google's Ligh LABEL "com.github.actions.icon"="check-square" LABEL "com.github.actions.color"="yellow" -LABEL version="0.3.0" +LABEL version="0.3.2" LABEL repository="https://github.com/jakejarvis/lighthouse-action" LABEL homepage="https://jarv.is/" LABEL maintainer="Jake Jarvis " diff --git a/README.md b/README.md index 5354175..e1d6c24 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This action integrates Google's helpful [Lighthouse audits](https://developers.google.com/web/tools/lighthouse/) for webpages — specifically testing for Performance, Accessibility, Best Practices, SEO, and Progressive Web Apps. Right now, the action will print the five scores (out of 100) to the output and upload HTML and JSON versions of the report as artifacts. In the next release, the action will let you specify thresholds for each test and optionally fail this step if they are not met.

Example HTML report

-

Example command line output

+

Example command line output

Example HTML report

Inspired by [GoogleChromeLabs/lighthousebot](https://github.com/GoogleChromeLabs/lighthousebot). diff --git a/entrypoint.sh b/entrypoint.sh index eed8fd6..38fa935 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,16 +8,17 @@ PULL_REQUEST_NUMBER=$(jq .number "$GITHUB_EVENT_PATH") # If this is a PR and Netlify is configured, plan to check the deploy preview and generate its unique URL. # Otherwise, simply check the provided live URL. if [ -n "$INPUT_NETLIFY_SITE" ] && [ -n "$PULL_REQUEST_NUMBER" ] && [ "$PULL_REQUEST_NUMBER" != "null" ]; then - REPORT_URL="https://deploy-preview-${PULL_REQUEST_NUMBER}--${INPUT_NETLIFY_SITE}" + REPORT_URL="https://deploy-preview-$PULL_REQUEST_NUMBER--$INPUT_NETLIFY_SITE" else - REPORT_URL=${INPUT_URL} + REPORT_URL=$INPUT_URL fi # Prepare directory for audit results and sanitize URL to a valid and unique filename. OUTPUT_FOLDER="report" +# shellcheck disable=SC2001 OUTPUT_FILENAME=$(echo "$REPORT_URL" | sed 's/[^a-zA-Z0-9]/_/g') -OUTPUT_PATH="./$OUTPUT_FOLDER/$OUTPUT_FILENAME" -mkdir "$OUTPUT_FOLDER" +OUTPUT_PATH="$GITHUB_WORKSPACE/$OUTPUT_FOLDER/$OUTPUT_FILENAME" +mkdir -p "$OUTPUT_FOLDER" # Clarify in logs which URL we're auditing. printf "* Beginning audit of %s ...\n\n" "$REPORT_URL" @@ -35,14 +36,16 @@ SCORE_PWA=$(jq '.categories["pwa"].score' "$OUTPUT_PATH".report.json) # Print scores to standard output (0 to 100 instead of 0 to 1). # Using hacky bc b/c bash hates floating point arithmetic... -printf "\n* Completed audit of %s !" "$REPORT_URL" -printf "\n* Scores are printed below and detailed results are saved in ./report\n\n" -printf "%s\n" "+-------------------------------+" +printf "\n* Completed audit of %s ! Scores are printed below:\n\n" "$REPORT_URL" +printf "+-------------------------------+\n" printf "| Performance: %.0f\t|\n" "$(echo "$SCORE_PERFORMANCE*100" | bc -l)" printf "| Accessibility: %.0f\t|\n" "$(echo "$SCORE_ACCESSIBILITY*100" | bc -l)" printf "| Best Practices: %.0f\t|\n" "$(echo "$SCORE_PRACTICES*100" | bc -l)" printf "| SEO: %.0f\t|\n" "$(echo "$SCORE_SEO*100" | bc -l)" printf "| Progressive Web App: %.0f\t|\n" "$(echo "$SCORE_PWA*100" | bc -l)" -printf "%s\n" "+-------------------------------+" +printf "+-------------------------------+\n\n" +printf "* Detailed results are saved here, use https://github.com/actions/upload-artifact to retrieve them:\n" +printf " %s\n" "$OUTPUT_PATH.report.html" +printf " %s\n" "$OUTPUT_PATH.report.json" exit 0 diff --git a/screenshots/screenshot-output.png b/screenshots/screenshot-output.png index 6b8ead5..cf6b301 100644 Binary files a/screenshots/screenshot-output.png and b/screenshots/screenshot-output.png differ