create summary.md from lhci reports
This commit is contained in:
parent
80be57afe7
commit
4c127c2628
4
overlay/templates/summary.md
Normal file
4
overlay/templates/summary.md
Normal file
@ -0,0 +1,4 @@
|
||||
### LHCI Report Overview
|
||||
|
||||
| URL | Performance | Accessibility | Best-Practices | SEO | PWA | Report |
|
||||
| --- | ----------- | ------------- | -------------- | --- | --- | ------ |
|
@ -3,10 +3,10 @@ set -eo pipefail
|
||||
|
||||
CONFIG="${LHCI_BASE_DIR%/}/.lighthouserc.yml"
|
||||
|
||||
/usr/local/bin/lhci "$@" || ERROR=true
|
||||
|
||||
if [ -f "$CONFIG" ]; then
|
||||
exec 5>&1
|
||||
OUT=$(/usr/local/bin/lhci "$@" | tee /dev/fd/5) || ERROR=true
|
||||
|
||||
if [ -f "$CONFIG" ] && echo "$OUT" | grep -q "Done running Lighthouse"; then
|
||||
UPLOAD_TARGET=$(yq r "${CONFIG}" --defaultValue "" ci.upload.target)
|
||||
UPLOAD_OUTPUT_DIR=$(yq r "${CONFIG}" --defaultValue "" ci.upload.outputDir)
|
||||
|
||||
@ -16,6 +16,8 @@ if [ -f "$CONFIG" ]; then
|
||||
mkdir -p "${DIST}"
|
||||
|
||||
if [ -f "$CONFIG" ]; then
|
||||
cp /templates/summary.md "${DIST}/summary.md"
|
||||
|
||||
printf "\nPost-process report files...\n"
|
||||
for ITEM in $(jq -r '.[] | select( .isRepresentativeRun == true ) | @base64' < "${MANIFEST}"); do
|
||||
JSON=$(echo "${ITEM}" | base64 -d)
|
||||
@ -24,10 +26,19 @@ if [ -f "$CONFIG" ]; then
|
||||
FILENAME=$(echo "${JSON}" | jq -r '.htmlPath')
|
||||
HASH=$(sha1sum "$FILENAME")
|
||||
FILENAME_NEW="${HASH:0:8}-$FILE_DATE"
|
||||
DONWLOAD=${LHCI_SERVER_URL%/}/$(basename "${FILENAME_NEW}").html
|
||||
|
||||
URL=$(echo "${JSON}" | jq -r '.url')
|
||||
PERF=$(echo "${JSON}" | jq -r '.summary.performance')
|
||||
ACCESS=$(echo "${JSON}" | jq -r '.summary.accessibility')
|
||||
PRACTICE=$(echo "${JSON}" | jq -r '.summary["best-practices"]')
|
||||
SEO=$(echo "${JSON}" | jq -r '.summary.seo')
|
||||
PWA=$(echo "${JSON}" | jq -r '.summary.pwa')
|
||||
|
||||
cp "${FILENAME}" "${DIST}/${FILENAME_NEW}.html"
|
||||
echo "Report for ${URL} will be uploaded to ${LHCI_SERVER_URL%/}/$(basename "${FILENAME_NEW}").html"
|
||||
echo "Report for ${URL} will be uploaded to ${DONWLOAD}"
|
||||
|
||||
echo "| \`${URL}\` | $(echo "scale=0;($PERF*100)/1" | bc) % | $(echo "scale=0;($ACCESS*100)/1" | bc) % | $(echo "scale=0;($PRACTICE*100)/1" | bc) % | $(echo "scale=0;($SEO*100)/1" | bc) % | $(echo "scale=0;($PWA*100)/1" | bc) % |" >> "${DIST}/summary.md"
|
||||
done
|
||||
else
|
||||
printf "\nPost-processing skipped. Manifest not found!\n"
|
||||
|
Loading…
Reference in New Issue
Block a user