Feat/gts spec v0.7 #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| # Cancel previous runs for the same ref to save CI minutes. | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| PIP_DISABLE_PIP_VERSION_CHECK: 1 | |
| jobs: | |
| test: | |
| name: Test Suite (${{ matrix.os }}, python=${{ matrix.python }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-latest, windows-latest, macos-latest ] | |
| python: [ '3.11' ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ./gts | |
| pip install pytest pytest-cov ruff mypy httpx | |
| - name: Show Python version | |
| run: python --version | |
| # Formatting check (fast fail for style issues) | |
| - name: ruff format (check) | |
| run: ruff format --check gts/src | |
| # Linting | |
| - name: ruff check | |
| run: ruff check gts/src | |
| # Type checking | |
| - name: mypy | |
| run: mypy gts/src/gts --ignore-missing-imports | |
| continue-on-error: true | |
| # Unit tests (skip if no tests exist) | |
| - name: pytest | |
| shell: bash | |
| run: | | |
| if [ -n "$(find tests/ -name 'test_*.py' -o -name '*_test.py' 2>/dev/null)" ]; then | |
| pytest tests/ -v --no-header | |
| else | |
| echo "No unit tests found in tests/, skipping..." | |
| fi | |
| security: | |
| name: Security (pip-audit on Ubuntu) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ./gts | |
| pip install pip-audit | |
| # Run security audit but do not fail CI (as requested). | |
| - name: pip-audit | |
| run: pip-audit | |
| continue-on-error: true | |
| coverage: | |
| name: Code Coverage (pytest-cov) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ./gts | |
| pip install pytest pytest-cov | |
| # Generate coverage report (skip if no tests exist) | |
| - name: Coverage | |
| run: | | |
| if [ -n "$(find tests/ -name 'test_*.py' -o -name '*_test.py' 2>/dev/null)" ]; then | |
| pytest tests/ --cov=gts --cov-report=xml --cov-report=term | |
| else | |
| echo "No unit tests found in tests/, skipping coverage..." | |
| fi | |
| # Upload to Codecov; do not fail CI if Codecov is down/misconfigured. | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage.xml | |
| fail_ci_if_error: false | |
| # token: ${{ secrets.CODECOV_TOKEN }} # Uncomment if required for private repos | |
| e2e: | |
| name: E2E Tests (gts-spec) | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| # Install httprunner first to get pydantic<1.9 constraint | |
| pip install httprunner pytest requests | |
| # Then install gts (will use already-installed pydantic v1) | |
| pip install -e ./gts | |
| - name: Run e2e tests | |
| run: | | |
| # Start server in background with logs | |
| gts server --port 8000 > .server.log 2>&1 & | |
| SERVER_PID=$! | |
| echo "Started GTS server with PID $SERVER_PID" | |
| # Wait for server to be ready | |
| echo "Waiting for GTS server to start..." | |
| for i in $(seq 1 30); do | |
| if ! kill -0 $SERVER_PID 2>/dev/null; then | |
| echo "ERROR: Server process died unexpectedly" | |
| echo "=== Server logs ===" | |
| cat .server.log || true | |
| exit 1 | |
| fi | |
| if curl -sf http://127.0.0.1:8000/entities > /dev/null 2>&1; then | |
| echo "GTS server is ready!" | |
| break | |
| fi | |
| if [ $i -eq 30 ]; then | |
| echo "ERROR: GTS server failed to start within 30 seconds" | |
| echo "=== Server logs ===" | |
| cat .server.log || true | |
| kill $SERVER_PID 2>/dev/null || true | |
| exit 1 | |
| fi | |
| echo "Attempt $i/30: Server not ready yet, waiting..." | |
| sleep 1 | |
| done | |
| # Run tests | |
| pytest -p no:cacheprovider ./.gts-spec/tests -v | |
| TEST_EXIT=$? | |
| # Stop server | |
| echo "Stopping GTS server..." | |
| kill $SERVER_PID 2>/dev/null || true | |
| wait $SERVER_PID 2>/dev/null || true | |
| exit $TEST_EXIT |