Initial commit: threatzone Python SDK 1.0.0 #1
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] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| # Cancel in-progress runs on the same ref when a new commit lands | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| name: Lint + format (ruff) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: latest | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev | |
| - name: ruff check | |
| run: uv run ruff check src/ tests/ | |
| - name: ruff format --check | |
| run: uv run ruff format --check src/ tests/ | |
| type-check: | |
| name: Type check (mypy) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: latest | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev | |
| - name: mypy | |
| run: uv run mypy src/threatzone | |
| test: | |
| name: Unit tests (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| env: | |
| UV_PYTHON: ${{ matrix.python-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: latest | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev --python ${{ matrix.python-version }} | |
| - name: Run tests | |
| run: uv run pytest tests/ -v --tb=short | |
| - name: Run tests with coverage | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| uv run pytest tests/ \ | |
| --cov=src/threatzone \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| --cov-fail-under=75 | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.12' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| build: | |
| name: Build distribution | |
| runs-on: ubuntu-latest | |
| needs: [lint, type-check, test] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: latest | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev | |
| - name: Build wheel and sdist | |
| run: uv build | |
| - name: Check distribution contents | |
| run: | | |
| ls -la dist/ | |
| uv run python -m zipfile -l dist/*.whl | head -30 | |
| - name: Verify wheel imports cleanly | |
| run: | | |
| uv run --with ./dist/*.whl python -c " | |
| import threatzone | |
| print(f'threatzone version: {threatzone.__version__}') | |
| assert threatzone.__version__, 'version missing' | |
| " | |
| - name: Upload distribution artifacts | |
| # Skip under nektos/act — upload-artifact@v4 requires ACTIONS_RUNTIME_TOKEN | |
| # which act cannot provide(learned it after countless errors dear readers...). Runs normally on real GitHub. | |
| if: ${{ !env.ACT }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| retention-days: 7 |