Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework pip-query #11

Merged
merged 14 commits into from
Jan 26, 2025
91 changes: 91 additions & 0 deletions .github/workflows/test-pyton.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright (C) 2025 Serghei Iakovlev <[email protected]>
#
# This file is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <https://www.gnu.org/licenses/>.

---
name: Test Python Code

on:
push:
paths:
- 'bin/pip-query'
pull_request:
paths:
- 'bin/pip-query'

env:
PYTHONUNBUFFERED: '1'

defaults:
run:
shell: bash

jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

# The maximum number of minutes to let a workflow run
# before GitHub automatically cancels it. Default: 360
timeout-minutes: 30

strategy:
# When set to true, GitHub cancels
# all in-progress jobs if any matrix job fails.
fail-fast: false

matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Restore pip-query cache
uses: actions/cache@v4
with:
path: ~/.cache/pip-query
key: ${{ runner.os }}-pip-query-${{ hashFiles('**/pip-query') }}
restore-keys: |
${{ runner.os }}-pip-query-

- name: Run tests
run: |
chmod +x bin/pip-query
python3 bin/pip-query --test

- name: Test script execution
run: |
# Test basic functionality
python3 bin/pip-query requests

# Test with max packages option
python3 bin/pip-query --max-packages 5 flask

# Test version output
python3 bin/pip-query --version

# Test help output
python3 bin/pip-query --help

- name: Success Reporting
if: success()
run: git log --format=fuller -5
23 changes: 13 additions & 10 deletions bin/mkllmproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
}

# Print usage information
usage() {
cat << EOF
${SCRIPT_NAME} - LLM project scaffolding tool [version ${VERSION}]
Expand Down Expand Up @@ -79,7 +78,7 @@ Examples:

Positional parameters:
name Project name (optional)
If not provided, will prompt interactively;
If not provided, will prompt interactively
Command options:
-h, --help Show this help message
-V, --version Show program's version number
Expand Down Expand Up @@ -147,16 +146,20 @@ while [[ $# -gt 0 ]]; do
break
;;
-*)
echo "${SCRIPT_NAME}: invalid option: $1"
usage
{
echo "${SCRIPT_NAME}: invalid option: $1"
echo "Try '${SCRIPT_NAME} --help' for more information."
} 1>&2
exit 1
;;
*)
if [[ -z "$project_name" ]]; then
project_name="$1"
else
echo "${SCRIPT_NAME}: unexpected argument: $1"
usage
{
echo "${SCRIPT_NAME}: unexpected argument: $1"
echo "Try '${SCRIPT_NAME} --help' for more information."
} 1>&2
exit 1
fi
shift
Expand All @@ -168,28 +171,28 @@ done
if [[ -n "$project_path" ]]; then
if [[ ! -d "$project_path" ]]; then
mkdir -p "$project_path" || {
echo "${SCRIPT_NAME}: failed to create directory $project_path"
echo "${SCRIPT_NAME}: failed to create directory $project_path" >&2
exit 1
}
fi
cd "$project_path" || {
echo "${SCRIPT_NAME}: failed to change to directory $project_path"
echo "${SCRIPT_NAME}: failed to change to directory $project_path" >&2
exit 1
}
fi

# Validate project name if provided as argument
if [[ -n "$project_name" ]]; then
if [[ -z "${project_name// }" ]]; then
echo "${SCRIPT_NAME}: project name cannot be empty"
echo "${SCRIPT_NAME}: project name cannot be empty" >&2
exit 1
fi
else
# Prompt for project name if not provided
while [[ -z "${project_name// }" ]]; do
read -rp "Enter project name: " project_name
if [[ -z "${project_name// }" ]]; then
echo "${SCRIPT_NAME}: project name cannot be empty"
echo "${SCRIPT_NAME}: project name cannot be empty" >&2
fi
done
fi
Expand Down
Loading
Loading