capture return code from lhci command and proceed
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Robert Kaussow 2020-07-17 10:21:55 +02:00
parent 473a2dfc7e
commit 4ff54ef5c9
Signed by: xoxys
GPG Key ID: 65362AE74AF98B61
2 changed files with 22 additions and 15 deletions

View File

@ -1,3 +1,2 @@
- ENHANCEMENT
- remove `LHCI_REPO_NAME`, could be handled within the CI
- fix `PATH` order to force use wrapper scripts as default
- BUGFIX
- capture return code from lhci command and proceed with post-processing

View File

@ -3,7 +3,7 @@ set -eo pipefail
CONFIG="${LHCI_BASE_DIR%/}/.lighthouserc.yml"
/usr/local/bin/lhci "$@"
/usr/local/bin/lhci "$@" || ERROR=true
if [ -f "$CONFIG" ]; then
@ -15,18 +15,26 @@ if [ -f "$CONFIG" ]; then
DIST="${LHCI_BASE_DIR%/}/${UPLOAD_OUTPUT_DIR%/}/dist"
mkdir -p "${DIST}"
printf "\nPost-process report files...\n"
for ITEM in $(jq -r '.[] | select( .isRepresentativeRun == true ) | @base64' < "${MANIFEST}"); do
JSON=$(echo "${ITEM}" | base64 -d)
FILE_DATE=$(date '+%Y%m%d%H%M')
if [ -f "$CONFIG" ]; then
printf "\nPost-process report files...\n"
for ITEM in $(jq -r '.[] | select( .isRepresentativeRun == true ) | @base64' < "${MANIFEST}"); do
JSON=$(echo "${ITEM}" | base64 -d)
FILE_DATE=$(date '+%Y%m%d%H%M')
FILENAME=$(echo "${JSON}" | jq -r '.htmlPath')
HASH=$(sha1sum "$FILENAME")
FILENAME_NEW="${HASH:0:8}-$FILE_DATE"
URL=$(echo "${JSON}" | jq -r '.url')
FILENAME=$(echo "${JSON}" | jq -r '.htmlPath')
HASH=$(sha1sum "$FILENAME")
FILENAME_NEW="${HASH:0:8}-$FILE_DATE"
URL=$(echo "${JSON}" | jq -r '.url')
cp "${FILENAME}" "${DIST}/${FILENAME_NEW}.html"
echo "Report for ${URL} will be uploaded to ${LHCI_SERVER_URL%/}/$(basename "${FILENAME_NEW}").html"
done
cp "${FILENAME}" "${DIST}/${FILENAME_NEW}.html"
echo "Report for ${URL} will be uploaded to ${LHCI_SERVER_URL%/}/$(basename "${FILENAME_NEW}").html"
done
else
printf "\nPost-processing skipped. Manifest not found!\n"
fi
fi
fi
if [ -n "$ERROR" ]; then
exit 1
fi