Skip to content

Commit 739628a

Browse files
committed
Workflow: Add floor value check
1 parent 609c653 commit 739628a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/build-push.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
ref: ${{ github.event.workflow_run.head_branch }}
3939
- uses: actions/setup-node@v5
4040
with:
41-
node-version: 18
41+
node-version: 22
4242
- name: Installing packages
4343
run: cd performance && npm ci
4444
- name: Generating lighthouse reports for PR...
@@ -58,14 +58,21 @@ jobs:
5858
continue-on-error: true
5959
run: |
6060
FIELDS=("performance" "accessibility")
61+
TOLERANCE=0.05
62+
FLOOR_VALUE=90
6163
for FIELD in "${FIELDS[@]}"; do
6264
PR_VALUE=$(cat lighthouse-reports/pr-report.json | jq -r ".categories.$FIELD.score")
6365
MAIN_VALUE=$(cat lighthouse-reports/main-report.json | jq -r ".categories.$FIELD.score")
6466
echo "$FIELD: PR - $PR_VALUE | Main - $MAIN_VALUE"
6567
68+
if (( $(echo "$PR_VALUE < $FLOOR_VALUE" | bc -l) )); then
69+
echo "Error: $FIELD score in PR ($PR_VALUE) is less than accepted value ($FLOOR_VALUE)"
70+
exit 1
71+
fi
72+
6673
if [ $FIELD = "performance" ]; then
67-
LOWER_BOUND=$(echo "$MAIN_VALUE - 0.05" | bc)
68-
UPPER_BOUND=$(echo "$MAIN_VALUE + 0.05" | bc)
74+
LOWER_BOUND=$(echo "$MAIN_VALUE - $TOLERANCE" | bc)
75+
UPPER_BOUND=$(echo "$MAIN_VALUE + $TOLERANCE" | bc)
6976
if (( $(echo "$PR_VALUE < $LOWER_BOUND" | bc -l) || $(echo "$PR_VALUE > $UPPER_BOUND" | bc -l) )); then
7077
echo "Error: $FIELD score in PR ($PR_VALUE) is less than in MAIN ($MAIN_VALUE)"
7178
exit 1

0 commit comments

Comments
 (0)