Skip to content

Eric/cus 9 - Socket CLI v2 #50

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

Merged
merged 11 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR Preview
on:
pull_request:
types: [opened, synchronize]
types: [opened, synchronize, ready_for_review]

jobs:
preview:
Expand All @@ -12,9 +12,15 @@ jobs:
with:
python-version: '3.x'

# Install all dependencies from pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .

- name: Set preview version
run: |
BASE_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
BASE_VERSION=$(python -c "from socketsecurity import __version__; print(__version__)")
PREVIEW_VERSION="${BASE_VERSION}.dev${{ github.event.pull_request.number }}${{ github.event.pull_request.commits }}"
echo "VERSION=${PREVIEW_VERSION}" >> $GITHUB_ENV

Expand All @@ -25,7 +31,7 @@ jobs:

# Verify the change
echo "Updated version in __init__.py:"
cat socketsecurity/__init__.py | grep "__version__"
python -c "from socketsecurity import __version__; print(__version__)"

- name: Check if version exists on Test PyPI
id: version_check
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
with:
python-version: '3.x'

# Install all dependencies from pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .

- name: Get Version
id: version
run: |
Expand Down Expand Up @@ -104,4 +110,4 @@ jobs:
socketdev/cli:latest
socketdev/cli:${{ env.VERSION }}
build-args: |
CLI_VERSION=${{ env.VERSION }}
CLI_VERSION=${{ env.VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Version Check
on:
pull_request:
types: [opened, synchronize]
types: [opened, synchronize, ready_for_review]
paths:
- 'socketsecurity/**'
- 'setup.py'
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ dist
*.build
*.dist
*.egg-info
test
*.env
run_container.sh
*.zip
bin
scripts/*.py
*.json
!tests/**/*.json
markdown_overview_temp.md
markdown_security_temp.md
.DS_Store
*.pyc
test.py
*.cpython-312.pyc`
file_generator.py
.env.local
.coverage
.env.local
Pipfile
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.PHONY: setup compile-deps sync-deps clean test lint init-tools local-dev first-time-setup update-deps dev-setup sync-all first-time-local-setup

# Environment variable for local SDK path (optional)
SOCKET_SDK_PATH ?= ../socket-sdk-python

# Environment variable to control local development mode
USE_LOCAL_SDK ?= false

# === High-level workflow targets ===

# First-time repo setup after cloning (using PyPI packages)
first-time-setup: clean setup

# First-time setup for local development (using local SDK)
first-time-local-setup:
$(MAKE) clean
$(MAKE) USE_LOCAL_SDK=true dev-setup

# Update dependencies after changing pyproject.toml
update-deps: compile-deps sync-deps

# Setup for local development
dev-setup: clean local-dev setup

# Sync all dependencies after pulling changes
sync-all: sync-deps

# === Implementation targets ===

# Creates virtual environment and installs pip-tools
init-tools:
python -m venv .venv
. .venv/bin/activate && pip install pip-tools

# Installs dependencies needed for local development
# Currently: socket-sdk-python from test PyPI or local path
local-dev: init-tools
ifeq ($(USE_LOCAL_SDK),true)
. .venv/bin/activate && pip install -e $(SOCKET_SDK_PATH)
endif

# Creates/updates requirements.txt files with locked versions based on pyproject.toml
compile-deps: local-dev
. .venv/bin/activate && pip-compile --output-file=requirements.txt pyproject.toml
. .venv/bin/activate && pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
. .venv/bin/activate && pip-compile --extra=test --output-file=requirements-test.txt pyproject.toml

# Creates virtual environment and installs dependencies from pyproject.toml
setup: compile-deps
. .venv/bin/activate && pip install -e ".[dev,test]"

# Installs exact versions from requirements.txt into your virtual environment
sync-deps:
. .venv/bin/activate && pip-sync requirements.txt requirements-dev.txt requirements-test.txt
ifeq ($(USE_LOCAL_SDK),true)
. .venv/bin/activate && pip install -e $(SOCKET_SDK_PATH)
endif

# Removes virtual environment and cache files
clean:
rm -rf .venv
find . -type d -name "__pycache__" -exec rm -rf {} +

test:
pytest

lint:
ruff check .
ruff format --check .
16 changes: 0 additions & 16 deletions Pipfile

This file was deleted.

207 changes: 0 additions & 207 deletions Pipfile.lock

This file was deleted.

Loading
Loading