Skip to content

fix(env-loader): prevent dotenv override and preserve runtime/test va… #2

fix(env-loader): prevent dotenv override and preserve runtime/test va…

fix(env-loader): prevent dotenv override and preserve runtime/test va… #2

Workflow file for this run

name: Maatify Bootstrap Tests
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
tests:
runs-on: ubuntu-latest
env:
GH_START_ISO: ${{ github.event.head_commit.timestamp }}
APP_ENV: testing
strategy:
matrix:
php: [ "8.4" ] # ✅ Only 8.4 supported officially
steps:
- name: 🛎️ Checkout repository
uses: actions/checkout@v4
- name: ⚙️ Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: mbstring, intl, bcmath, redis
tools: composer:v2
- name: ♻️ Cache Composer packages
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: 📦 Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: 🧪 Run PHPUnit tests
env:
CI: true
run: composer run-script test
- name: 📄 Validate README & composer.json
run: |
test -f README.md
composer validate --no-check-all
- name: 🐳 Docker Build Check
run: docker build -t maatify/bootstrap:test -f docker/Dockerfile .
- name: 📲 Notify Telegram
if: always()
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_CI_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CI_CHAT_ID }}
run: |
START_TS=$(date -u -d "$GH_START_ISO" +%s)
END_TS=$(date +%s)
START_TIME=$(date -u -d "@$START_TS" +"%H:%M:%S UTC")
END_TIME=$(date -u +"%H:%M:%S UTC")
DURATION=$((END_TS - START_TS))
if [ "$DURATION" -lt 60 ]; then
DURATION_STR="${DURATION}s"
else
DURATION_STR="$(($DURATION / 60))m $(($DURATION % 60))s"
fi
STATUS="✅ Tests passed successfully!"
COLOR="🟢"
HEADER="Maatify CI Report"
if grep -q "FAILURES!" phpunit.log || [ "${{ job.status }}" != "success" ]; then
STATUS="❌ Some tests failed. Please review the log."
COLOR="🔴"
HEADER="Maatify CI Alert"
fi
PROJECT="maatify/bootstrap"
BRANCH="$GITHUB_REF_NAME"
ACTOR="$GITHUB_ACTOR"
URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
MESSAGE="📢 <b>${HEADER}</b>
${COLOR} ${STATUS}
📦 <b>Project:</b> ${PROJECT}
🧱 <b>Branch:</b> ${BRANCH}
👷‍♂️ <b>Committer:</b> ${ACTOR}
⏱ <b>Start:</b> ${START_TIME}
🕒 <b>End:</b> ${END_TIME}
📈 <b>Duration:</b> ${DURATION_STR}
🔗 <a href='${URL}'>View Run Log</a>"
PAYLOAD=$(jq -n \
--arg chat_id "$TELEGRAM_CHAT_ID" \
--arg text "$MESSAGE" \
--arg parse_mode "HTML" \
'{chat_id: $chat_id, text: $text, parse_mode: $parse_mode}')
RESPONSE=$(curl -s -o /tmp/tg_resp.json -w "%{http_code}" \
-X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d "$PAYLOAD")
echo "Raw Telegram Response (HTTP $RESPONSE):"
cat /tmp/tg_resp.json
if [ "$RESPONSE" -ne 200 ]; then
echo "⚠️ Telegram notification failed (HTTP $RESPONSE)" >> $GITHUB_STEP_SUMMARY
cat /tmp/tg_resp.json >> $GITHUB_STEP_SUMMARY
else
echo "✅ Telegram notification sent successfully." >> $GITHUB_STEP_SUMMARY
fi