Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@ jobs:
- run: ruff check .
- run: ruff format --check .
- run: pytest -q

bootstrap:
# Three launcher bugs shipped because CI installed dependencies itself and
# never ran start.sh. This runs it the way a new contributor does: clean
# checkout, no venv, no .env, no API key.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: start.sh bootstraps a clean checkout
run: ./start.sh test
- name: start.sh setup is idempotent
run: ./start.sh setup
- name: modes that need no key do not demand one
run: |
test ! -f .env || { echo "start.sh test should not create .env"; exit 1; }
47 changes: 28 additions & 19 deletions start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,39 @@ if errorlevel 1 (
)
)

rem -- key --------------------------------------------------------------
if not exist ".env" (
copy ".env.example" ".env" >nul
echo.
echo created .env - add your Groq key, then run this again
echo free key: https://console.groq.com/keys
echo.
exit /b 1
)

findstr /r /c:"^GROQ_TOKEN=..*" ".env" >nul 2>&1
if errorlevel 1 (
echo.
echo .env has no GROQ_TOKEN - add one, then run this again
echo free key: https://console.groq.com/keys
echo.
exit /b 1
)

rem -- run --------------------------------------------------------------
set "MODE=%~1"
if "%MODE%"=="" set "MODE=run"
if not "%MODE%"=="" shift

rem -- key --------------------------------------------------------------
rem Only the modes that actually talk to the API. The test suite is offline,
rem and `check` exists precisely to diagnose a missing key, so demanding one
rem from either would be backwards.
set "NEEDS_KEY="
if /i "%MODE%"=="run" set "NEEDS_KEY=1"
if /i "%MODE%"=="demo" set "NEEDS_KEY=1"
if /i "%MODE%"=="ask" set "NEEDS_KEY=1"

if defined NEEDS_KEY (
if not exist ".env" (
copy ".env.example" ".env" >nul
echo.
echo created .env - add your Groq key, then run this again
echo free key: https://console.groq.com/keys
echo.
exit /b 1
)
findstr /r /c:"^GROQ_TOKEN=..*" ".env" >nul 2>&1
if errorlevel 1 (
echo.
echo .env has no GROQ_TOKEN - add one, then run this again
echo free key: https://console.groq.com/keys
echo.
exit /b 1
)
)

if /i "%MODE%"=="run" goto :run
if /i "%MODE%"=="demo" goto :demo
if /i "%MODE%"=="check" goto :check
Expand Down
36 changes: 21 additions & 15 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,30 @@ if ! "$PY" -c 'import groq, rich, pydantic, dotenv' >/dev/null 2>&1; then
"$PY" -m pip install --quiet -e ".[dev]"
fi

# ── key ───────────────────────────────────────────────────────────────
if [ ! -f .env ]; then
cp .env.example .env
printf '\n created .env — add your Groq key, then run this again\n'
printf ' free key: https://console.groq.com/keys\n\n'
exit 1
fi

if ! grep -qE '^GROQ_TOKEN=.+' .env; then
printf '\n .env has no GROQ_TOKEN — add one, then run this again\n'
printf ' free key: https://console.groq.com/keys\n\n'
exit 1
fi

# ── run ───────────────────────────────────────────────────────────────
MODE="${1:-run}"
shift || true

# ── key ───────────────────────────────────────────────────────────────
# Only the modes that actually talk to the API. The whole test suite is
# offline, and `check` exists precisely to diagnose a missing key, so
# demanding one from either would be backwards.
case "$MODE" in
run|demo|ask)
if [ ! -f .env ]; then
cp .env.example .env
printf '\n created .env — add your Groq key, then run this again\n'
printf ' free key: https://console.groq.com/keys\n\n'
exit 1
fi
if ! grep -qE '^GROQ_TOKEN=.+' .env; then
printf '\n .env has no GROQ_TOKEN — add one, then run this again\n'
printf ' free key: https://console.groq.com/keys\n\n'
exit 1
fi
;;
esac

# ── run ───────────────────────────────────────────────────────────────
case "$MODE" in
run) exec "$PY" -m intelli_oppo "$@" ;;
demo) exec "$PY" -m intelli_oppo --demo "$@" ;;
Expand Down
Loading