From 2d5c7e8f5b45f738ac741f1add0b1442e11aadd9 Mon Sep 17 00:00:00 2001 From: YouSiki Date: Sat, 18 Jan 2025 11:59:50 +0800 Subject: [PATCH] Update deployment step to include testing and validate output differences --- .github/workflows/ci.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99251af..5a9032c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: sarif_file: /tmp/lint.sarif wait-for-processing: true deploy: - name: Deploy to Cloudflare Workers + name: Deploy to Cloudflare Workers and test runs-on: ubuntu-latest steps: - name: Checkout repository @@ -107,5 +107,14 @@ jobs: run: echo "DEPLOYED_URL=$(echo $CMD_OUTPUT | grep -o 'https://[^ ]*')" >> $GITHUB_ENV - name: Test the deployed version run: | - curl -s -I $DEPLOYED_URL/ | grep -q "200 OK" && \ - curl -s -I $DEPLOYED_URL/images/favicon.ico | grep -q "200 OK" + curl -s $DEPLOYED_URL > /tmp/deployed.html + curl -s https://mikanani.me > /tmp/expected.html + total_lines=$(wc -l < /tmp/expected.html) + diff_lines=$(diff /tmp/expected.html /tmp/deployed.html | grep -c "^[<>]") + diff_percentage=$(echo "scale=2; $diff_lines * 100 / $total_lines" | bc) + if (( $(echo "$diff_percentage > 5" | bc -l) )); then + echo "Difference is too large: $diff_percentage%" + exit 1 + else + echo "Difference is acceptable: $diff_percentage%" + fi