-
Notifications
You must be signed in to change notification settings - Fork 5
feat: rebase the gts-python to gts spec 0.13 #20
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
base: main
Are you sure you want to change the base?
Changes from all commits
70f4079
ce47301
1c0c3ba
52ef751
83ef3b3
85f886b
fc6c41d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ wheels/ | |
| *.egg | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
| venv/ | ||
| ENV/ | ||
| env/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,24 @@ | ||
| CI := 1 | ||
|
|
||
| .PHONY: help build dev-fmt all check fmt lint mypy test security update-spec e2e coverage | ||
| # Python: PYTHON_BOOTSTRAP is used only to create the virtual environment; | ||
| # PYTHON is the venv interpreter used by all other targets. | ||
| PYTHON_BOOTSTRAP ?= $(shell command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3) | ||
| PY_ENV_DIR ?= .venv | ||
| ifeq ($(OS),Windows_NT) | ||
| PYTHON ?= $(PY_ENV_DIR)/Scripts/python | ||
| else | ||
| PYTHON ?= $(PY_ENV_DIR)/bin/python | ||
| endif | ||
| PY_ENV_STAMP := $(PY_ENV_DIR)/.stamp | ||
| INSTALL_STAMP := $(PY_ENV_DIR)/.install-stamp | ||
|
|
||
| ifneq ($(filter install-local uninstall-local,$(MAKECMDGOALS)),) | ||
| ifeq ($(origin PYTHON),file) | ||
| $(error PYTHON must be set for local package targets (examples: venv: PYTHON=.venv/bin/python3.13 make install-local; global: PYTHON=python3.13 make install-local)) | ||
| endif | ||
| endif | ||
|
|
||
| .PHONY: help py-env install build install-local uninstall-local clean dev-fmt all check fmt lint clippy mypy test security update-spec e2e coverage | ||
|
|
||
| # Default target - show help | ||
| .DEFAULT_GOAL := help | ||
|
|
@@ -9,20 +27,54 @@ CI := 1 | |
| help: | ||
| @awk '/^# / { desc=substr($$0, 3) } /^[a-zA-Z0-9_-]+:/ && desc { target=$$1; sub(/:$$/, "", target); printf "%-20s - %s\n", target, desc; desc="" }' Makefile | sort | ||
|
|
||
| # Build/install the package in development mode | ||
| build: | ||
| pip install -e ./gts | ||
| # -------- Environment -------- | ||
|
|
||
| # Create/update the virtual environment and install dev/test dependencies | ||
| py-env: $(PY_ENV_STAMP) | ||
|
|
||
| $(PY_ENV_STAMP): gts/pyproject.toml .gts-spec/tests/requirements.txt | ||
| @echo "Creating/updating Python virtual environment in $(PY_ENV_DIR)..." | ||
| $(PYTHON_BOOTSTRAP) -m venv $(PY_ENV_DIR) | ||
| $(PYTHON) -m pip install --upgrade pip | ||
| $(PYTHON) -m pip install -r .gts-spec/tests/requirements.txt | ||
| $(PYTHON) -m pip install --no-deps 'httprunner>=4,<5' | ||
| @touch $@ | ||
|
|
||
| # Install gts package into the venv (editable, for development) | ||
| install: $(INSTALL_STAMP) | ||
|
|
||
| $(INSTALL_STAMP): $(PY_ENV_STAMP) gts/pyproject.toml | ||
| $(PYTHON) -m pip install -e ./gts | ||
| @touch $@ | ||
|
|
||
| # Build source and wheel distributions into dist/ | ||
| build: py-env | ||
| $(PYTHON) -m pip install --upgrade build | ||
| $(PYTHON) -m build --outdir dist ./gts | ||
|
|
||
| # Install the locally built wheel, equivalent to installing the published gts package | ||
| install-local: build | ||
| $(PYTHON) -m pip install --force-reinstall dist/gts-*.whl | ||
|
|
||
| # Uninstall gts from the selected interpreter | ||
| uninstall-local: | ||
| $(PYTHON) -m pip uninstall --yes gts | ||
| @rm -f $(INSTALL_STAMP) | ||
|
|
||
| # Remove venv and build artifacts | ||
| clean: | ||
| rm -rf $(PY_ENV_DIR) dist/ gts/dist/ gts/*.egg-info | ||
|
|
||
| # -------- Code quality -------- | ||
|
|
||
| # Fix formatting issues | ||
| dev-fmt: | ||
| ruff format gts/src | ||
|
|
||
| # Run all checks and build | ||
| all: check build | ||
|
|
||
| # Check code formatting | ||
| fmt: | ||
| ruff format --check gts/src | ||
| @$(PYTHON) -m ruff --version >/dev/null 2>&1 || { echo "Ruff is required. Install it with: $(PYTHON) -m pip install ruff"; exit 1; } | ||
| $(PYTHON) -m ruff format --check gts/src | ||
|
|
||
| # Run linter (ruff) | ||
| lint: | ||
|
|
@@ -36,34 +88,42 @@ clippy: | |
| mypy: | ||
| mypy gts/src/gts --ignore-missing-imports | ||
|
|
||
| # Run all tests | ||
| test: | ||
| pytest tests/ -v | ||
| # -------- Tests -------- | ||
|
|
||
| # Check dependencies for security vulnerabilities | ||
| security: | ||
| @command -v pip-audit >/dev/null || (echo "Installing pip-audit..." && pip install pip-audit) | ||
| pip-audit | ||
| # Run all tests | ||
| test: install | ||
| $(PYTHON) -m pytest tests/ -v | ||
|
|
||
| # Measure code coverage | ||
| coverage: | ||
| pytest tests/ --cov=gts --cov-report=xml --cov-report=term | ||
|
|
||
| # Update gts-spec submodule to latest | ||
| update-spec: | ||
| git submodule update --remote .gts-spec | ||
| coverage: install | ||
| $(PYTHON) -m pip install 'pytest-cov>=5,<7' | ||
| $(PYTHON) -m pytest tests/ --cov=gts --cov-report=xml --cov-report=term | ||
|
|
||
| # Run end-to-end tests against gts-spec | ||
| e2e: build | ||
| e2e: install | ||
| @echo "Starting server in background..." | ||
| @python -m gts server --port 8000 & echo $$! > .server.pid | ||
| @$(PYTHON) -m gts server --port 8000 & echo $$! > .server.pid | ||
| @sleep 2 | ||
| @echo "Running e2e tests..." | ||
| @PYTHONDONTWRITEBYTECODE=1 pytest -p no:cacheprovider --log-file=e2e.log ./.gts-spec/tests || (kill `cat .server.pid` 2>/dev/null; rm -f .server.pid; exit 1) | ||
| @PYTHONDONTWRITEBYTECODE=1 $(PYTHON) -m pytest -p no:cacheprovider --log-file=e2e.log ./.gts-spec/tests || (kill `cat .server.pid` 2>/dev/null; rm -f .server.pid; exit 1) | ||
| @echo "Stopping server..." | ||
| @kill `cat .server.pid` 2>/dev/null || true | ||
| @rm -f .server.pid | ||
| @echo "E2E tests completed successfully" | ||
|
|
||
| # -------- Misc -------- | ||
|
|
||
| # Check dependencies for security vulnerabilities | ||
| security: py-env | ||
| $(PYTHON) -m pip install pip-audit | ||
| $(PYTHON) -m pip_audit | ||
|
Comment on lines
+117
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Makefile target definitions ---'
cat -n Makefile | sed -n '70,115p'
printf '%s\n' '--- dependency files ---'
git ls-files | grep -E '(^|/)(pyproject\.toml|requirements[^/]*\.txt|setup\.cfg|setup\.py)$|(^|/)Makefile$' | sort
printf '%s\n' '--- GTS dependency declarations ---'
for f in $(git ls-files | grep -E '(^|/)pyproject\.toml$|(^|/)requirements[^/]*\.txt$' | grep -E '(^|/)gts/|\.gts-spec/'); do
printf '\n### %s\n' "$f"
cat -n "$f"
doneRepository: GlobalTypeSystem/gts-python Length of output: 2753 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Makefile setup and install targets ---'
cat -n Makefile | sed -n '1,70p'
printf '%s\n' '--- root requirements.txt ---'
cat -n requirements.txt
printf '%s\n' '--- submodule status and tracked dependency paths ---'
git submodule status -- .gts-spec || true
git ls-tree HEAD .gts-spec
git ls-files .gts-spec | sed -n '1,40p'Repository: GlobalTypeSystem/gts-python Length of output: 2981 Security Misconfiguration (CWE-1395) Make
🤖 Prompt for AI Agents |
||
|
|
||
| # Update gts-spec submodule to latest | ||
| update-spec: | ||
| git submodule update --remote .gts-spec | ||
|
|
||
| # Run all checks and build | ||
| all: check build | ||
|
|
||
| # Run all quality checks | ||
| check: fmt lint test e2e | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: GlobalTypeSystem/gts-python
Length of output: 3638
🏁 Script executed:
Repository: GlobalTypeSystem/gts-python
Length of output: 9063
🌐 Web query:
GNU Make for Windows default shell COMSPEC SHELL command line recipe documentation💡 Result:
On Windows, GNU Make determines the shell used to execute recipe commands through a specific hierarchy of variables and environment settings [1][2]. 1. SHELL Variable: GNU Make primarily uses the SHELL variable to determine which shell program to invoke [1]. Unlike on Unix, where SHELL is generally ignored to ensure Makefile portability, GNU Make on Windows will use the value of SHELL if it is defined in the environment [1][3]. 2. COMSPEC Environment Variable: If the SHELL variable is not set (either in the Makefile or the environment), GNU Make falls back to the COMSPEC environment variable, which is a standard Windows environment variable that typically points to cmd.exe [1][2][3]. 3. Default Fallback: If neither SHELL nor COMSPEC is defined, the default shell is typically sh.exe, which GNU Make searches for on the system PATH [4][5]. Key Technical Notes: - Shell Invocation: GNU Make does not always invoke a shell for every recipe line [6][7]. It first attempts to execute commands directly if they do not contain special shell characters (such as redirection operators like > or |, or other shell-specific syntax) [6][7]. If a command does not require shell features, Make will attempt to run the executable directly, bypassing the shell specified in SHELL or COMSPEC [6][7]. - Makefile Overrides: You can explicitly define the shell to be used for a specific project by setting the SHELL variable directly within your Makefile (e.g., SHELL = C:/Windows/System32/cmd.exe) [1][2]. - MAKESHELL Variable: On some ports (particularly older DOS/Windows versions), an environment variable named MAKESHELL can be used to override both SHELL and COMSPEC, taking the highest precedence [8][3]. For consistent behavior across different environments, it is best practice to define SHELL explicitly within your Makefile rather than relying on environment variables like COMSPEC, which can vary between machines [1].
Citations:
Define the shell contract for Windows Make targets.
Makefiledoes not setSHELL, so GNU Make can usecmd.exethroughCOMSPEC. In that mode,command -v,touch,rm -rf,sleep, background-process syntax,kill,cat, and POSIX environment assignments are not valid.py-envcan fail before writing.stamp;cleanande2ecan also fail. The Windows CI job does not run these Make targets. Require Bash explicitly or add Windows-specific branches, then testpy-env,clean, ande2eon the supported Windows shell.🤖 Prompt for AI Agents