Skip to content

Commit f8b7316

Browse files
authored
Merge pull request #20 from GlobalTypeSystem/gts-spec-0.13
feat: rebase the gts-python to gts spec 0.13
2 parents 7e5d532 + 0d0cf22 commit f8b7316

36 files changed

Lines changed: 5158 additions & 814 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ wheels/
2929
*.egg
3030

3131
# Virtual environments
32+
.venv/
3233
venv/
3334
ENV/
3435
env/

‎.gts-spec‎

Submodule .gts-spec updated 97 files

‎Makefile‎

Lines changed: 99 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
CI := 1
22

3-
.PHONY: help build dev-fmt all check fmt lint mypy test security update-spec e2e coverage
3+
# These recipes rely on POSIX tools (command -v, touch, rm -rf, sleep, kill,
4+
# cat) and POSIX syntax (background jobs, inline env assignments). Require Bash
5+
# explicitly so GNU Make does not fall back to cmd.exe via COMSPEC on Windows.
6+
# On Windows, run these targets from a Bash environment (e.g. Git Bash / MSYS2).
7+
SHELL := /bin/bash
8+
9+
# Python: PYTHON_BOOTSTRAP is used only to create the virtual environment;
10+
# PYTHON is the venv interpreter used by all other targets.
11+
PYTHON_BOOTSTRAP ?= $(shell command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
12+
PY_ENV_DIR ?= .venv
13+
ifeq ($(OS),Windows_NT)
14+
PYTHON ?= $(PY_ENV_DIR)/Scripts/python
15+
else
16+
PYTHON ?= $(PY_ENV_DIR)/bin/python
17+
endif
18+
PY_ENV_STAMP := $(PY_ENV_DIR)/.stamp
19+
INSTALL_STAMP := $(PY_ENV_DIR)/.install-stamp
20+
21+
ifneq ($(filter install-local uninstall-local,$(MAKECMDGOALS)),)
22+
ifeq ($(origin PYTHON),file)
23+
$(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))
24+
endif
25+
endif
26+
27+
.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
428

529
# Default target - show help
630
.DEFAULT_GOAL := help
@@ -9,61 +33,103 @@ CI := 1
933
help:
1034
@awk '/^# / { desc=substr($$0, 3) } /^[a-zA-Z0-9_-]+:/ && desc { target=$$1; sub(/:$$/, "", target); printf "%-20s - %s\n", target, desc; desc="" }' Makefile | sort
1135

12-
# Build/install the package in development mode
13-
build:
14-
pip install -e ./gts
36+
# -------- Environment --------
1537

16-
# Fix formatting issues
17-
dev-fmt:
18-
ruff format gts/src
38+
# Create/update the virtual environment and install dev/test dependencies
39+
py-env: $(PY_ENV_STAMP)
1940

20-
# Run all checks and build
21-
all: check build
41+
$(PY_ENV_STAMP): gts/pyproject.toml .gts-spec/tests/requirements.txt Makefile
42+
@echo "Creating/updating Python virtual environment in $(PY_ENV_DIR)..."
43+
$(PYTHON_BOOTSTRAP) -m venv $(PY_ENV_DIR)
44+
$(PYTHON) -m pip install --upgrade pip
45+
$(PYTHON) -m pip install -r .gts-spec/tests/requirements.txt
46+
$(PYTHON) -m pip install --no-deps 'httprunner>=4,<5'
47+
$(PYTHON) -m pip install ruff mypy
48+
@touch $@
49+
50+
# Install gts package into the venv (editable, for development)
51+
install: $(INSTALL_STAMP)
52+
53+
$(INSTALL_STAMP): $(PY_ENV_STAMP) gts/pyproject.toml
54+
$(PYTHON) -m pip install -e ./gts
55+
@touch $@
56+
57+
# Build source and wheel distributions into dist/
58+
build: py-env
59+
$(PYTHON) -m pip install --upgrade build
60+
$(PYTHON) -m build --outdir dist ./gts
61+
62+
# Install the locally built wheel, equivalent to installing the published gts package
63+
install-local: build
64+
$(PYTHON) -m pip install --force-reinstall dist/gts-*.whl
65+
66+
# Uninstall gts from the selected interpreter
67+
uninstall-local:
68+
$(PYTHON) -m pip uninstall --yes gts
69+
@rm -f $(INSTALL_STAMP)
70+
71+
# Remove venv and build artifacts
72+
clean:
73+
rm -rf $(PY_ENV_DIR) dist/ gts/dist/ gts/*.egg-info
74+
75+
# -------- Code quality --------
76+
77+
# Fix formatting issues
78+
dev-fmt: py-env
79+
$(PYTHON) -m ruff format gts/src
2280

2381
# Check code formatting
24-
fmt:
25-
ruff format --check gts/src
82+
fmt: py-env
83+
$(PYTHON) -m ruff format --check gts/src
2684

2785
# Run linter (ruff)
28-
lint:
29-
ruff check gts/src
86+
lint: py-env
87+
$(PYTHON) -m ruff check gts/src
3088

3189
# Run clippy-equivalent linter with auto-fix
32-
clippy:
33-
ruff check --fix gts/src
90+
clippy: py-env
91+
$(PYTHON) -m ruff check --fix gts/src
3492

3593
# Run type checker
36-
mypy:
37-
mypy gts/src/gts --ignore-missing-imports
94+
mypy: py-env
95+
$(PYTHON) -m mypy gts/src/gts --ignore-missing-imports
3896

39-
# Run all tests
40-
test:
41-
pytest tests/ -v
97+
# -------- Tests --------
4298

43-
# Check dependencies for security vulnerabilities
44-
security:
45-
@command -v pip-audit >/dev/null || (echo "Installing pip-audit..." && pip install pip-audit)
46-
pip-audit
99+
# Run all tests
100+
test: install
101+
$(PYTHON) -m pytest tests/ -v
47102

48103
# Measure code coverage
49-
coverage:
50-
pytest tests/ --cov=gts --cov-report=xml --cov-report=term
51-
52-
# Update gts-spec submodule to latest
53-
update-spec:
54-
git submodule update --remote .gts-spec
104+
coverage: install
105+
$(PYTHON) -m pip install 'pytest-cov>=5,<7'
106+
$(PYTHON) -m pytest tests/ --cov=gts --cov-report=xml --cov-report=term
55107

56108
# Run end-to-end tests against gts-spec
57-
e2e: build
109+
e2e: install
58110
@echo "Starting server in background..."
59-
@python -m gts server --port 8000 & echo $$! > .server.pid
111+
@$(PYTHON) -m gts server --port 8000 & echo $$! > .server.pid
60112
@sleep 2
61113
@echo "Running e2e tests..."
62-
@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)
114+
@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)
63115
@echo "Stopping server..."
64116
@kill `cat .server.pid` 2>/dev/null || true
65117
@rm -f .server.pid
66118
@echo "E2E tests completed successfully"
67119

120+
# -------- Misc --------
121+
122+
# Check dependencies for security vulnerabilities
123+
security: py-env
124+
$(PYTHON) -m pip install pip-audit
125+
$(PYTHON) -m pip_audit
126+
127+
# Update gts-spec submodule to latest
128+
update-spec:
129+
git submodule update --remote .gts-spec
130+
131+
# Run all checks and build
132+
all: check build
133+
68134
# Run all quality checks
69135
check: fmt lint test e2e

‎README.md‎

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A minimal, idiomatic Python library for working with **GTS** ([Global Type Syste
66

77
## Roadmap
88

9+
Current supported GTS spec version: 0.13
10+
911
Featureset:
1012

1113
- [x] **OP#1 - ID Validation**: Verify identifier syntax using regex patterns
@@ -22,7 +24,8 @@ Featureset:
2224
- [x] **OP#9 - Version Casting**: Transform instances between compatible MINOR versions
2325
- [x] **OP#10 - Query Execution**: Filter identifier collections using the GTS query language
2426
- [x] **OP#11 - Attribute Access**: Retrieve property values and metadata using the attribute selector (`@`)
25-
- [ ] **OP#12 - Schema Validation**: Validate schema against its precedent schema
27+
- [x] **OP#12 - Type Derivation Validation**: Validate that derived GTS Type Schemas correctly extend their base chain
28+
- [x] **OP#13 - Schema Traits Validation**: Validate schema traits (`x-gts-traits-schema` / `x-gts-traits`).
2629

2730
See details in [gts/README.md](gts/README.md)
2831

@@ -32,26 +35,46 @@ Other GTS spec [Reference Implementation](https://github.com/globaltypesystem/gt
3235
- [x] **CLI** - command-line interface for all GTS operations
3336
- [x] **Web server** - a non-production web-server with REST API for the operations processing and testing
3437
- [x] **x-gts-ref support** - to support special GTS entity reference annotation in schemas
35-
- [ ] **YAML support** - to support YAML files (*.yml, *.yaml) as input files
36-
- [ ] **TypeSpec support** - add [typespec.io](https://typespec.io/) files (*.tsp) support
37-
- [ ] **UUID for instances** - to support UUID as ID in JSON instances
38+
- [x] **YAML support** - to support YAML files (*.yml, *.yaml) as input files
39+
- [x] **UUID for instances** - to support UUID as ID in JSON instances
40+
- [ ] **TypeSpec support** - direct support for [typespec.io](https://typespec.io/) files (*.tsp) input files
3841

3942
Technical Backlog:
4043

41-
- [ ] **Code coverage** - target is 90%
42-
- [ ] **Documentation** - add documentation for all the features
43-
- [ ] **Interface** - export publicly available interface and keep cli and others private
44-
- [ ] **Server API** - finalise the server API
45-
- [ ] **Final code cleanup** - remove unused code, denormalize, add critical comments, etc.
44+
- [x] **Code coverage** - target is 90%
45+
- [x] **Documentation** - add documentation for all the features
46+
- [x] **Interface** - export publicly available interface and keep cli and others private
47+
- [x] **Server API** - finalise the server API
48+
- [x] **Final code cleanup** - remove unused code, denormalize, add critical comments, etc.
4649

4750
## Installation
4851

52+
GTS requires Python 3.9 or later.
53+
54+
### Local development
55+
56+
From the repository root, build and install the same wheel artifact that will later be published and installed with `pip install gts`. `install-local` requires an explicit `PYTHON` environment variable so you choose the target interpreter:
57+
58+
```bash
59+
PYTHON=.venv/bin/python make install-local
60+
```
61+
62+
This creates the `.venv` virtual environment when needed, writes source and wheel distributions to `dist/`, and installs the wheel into the interpreter specified by `PYTHON`. Activate it to use the locally installed library and CLI:
63+
4964
```bash
50-
# install in editable mode
51-
pip install -e ./gts
65+
source .venv/bin/activate
66+
python -c "import gts; print(gts.__file__)"
67+
gts --help
68+
```
69+
70+
Use `make build` when you only need the distributable artifacts. Remove the locally installed package with `PYTHON=.venv/bin/python make uninstall-local`. For an editable installation while changing source files, use `make install`.
5271

53-
# install from PyPI, not supported yet
54-
# pip install gts
72+
### Published package
73+
74+
After `gts` is published to PyPI, install it with:
75+
76+
```bash
77+
pip install gts
5578
```
5679

5780
## Usage

0 commit comments

Comments
 (0)