Skip to content

Fix stale didYouMean props #114

Fix stale didYouMean props

Fix stale didYouMean props #114

Workflow file for this run

name: Version Check
on:
pull_request:
types: [opened, synchronize, ready_for_review]
paths:
- 'socketdev/**'
- 'pyproject.toml'
- 'uv.lock'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
check_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Fetch all history for all branches
persist-credentials: false
- name: Check version increment
id: version_check
run: |
# Get version from current PR
PR_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
# Get version from main branch
git checkout origin/main
MAIN_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
export PR_VERSION
export MAIN_VERSION
# Compare against both main and latest published PyPI release.
python3 <<'PY'
import json
import os
import urllib.request
from packaging import version
pr_ver = version.parse(os.environ["PR_VERSION"])
main_ver = version.parse(os.environ["MAIN_VERSION"])
with urllib.request.urlopen("https://pypi.org/pypi/socketdev/json") as response:
pypi_data = json.load(response)
published_versions = []
for raw in pypi_data.get("releases", {}).keys():
parsed = version.parse(raw)
if not parsed.is_prerelease and not parsed.is_devrelease:
published_versions.append(parsed)
pypi_ver = max(published_versions) if published_versions else version.parse("0.0.0")
required_floor = max(main_ver, pypi_ver)
if pr_ver <= required_floor:
print(
f"❌ Version must be greater than main and PyPI! "
f"Main: {main_ver}, PyPI: {pypi_ver}, PR: {pr_ver}"
)
raise SystemExit(1)
print(
f"✅ Version properly incremented. "
f"Main: {main_ver}, PyPI: {pypi_ver}, PR: {pr_ver}"
)
PY
- name: Require uv.lock update when pyproject changes
run: |
CHANGED_FILES="$(git diff --name-only origin/main...HEAD)"
if echo "$CHANGED_FILES" | grep -qx 'pyproject.toml'; then
if ! echo "$CHANGED_FILES" | grep -qx 'uv.lock'; then
echo "❌ pyproject.toml changed, but uv.lock was not updated."
echo "Run 'uv lock' and commit uv.lock with the version bump."
exit 1
fi
fi
- name: Manage PR Comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
if: always()
env:
MAIN_VERSION: ${{ env.MAIN_VERSION }}
PR_VERSION: ${{ env.PR_VERSION }}
CHECK_RESULT: ${{ steps.version_check.outcome }}
with:
script: |
const success = process.env.CHECK_RESULT === 'success';
const prNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const comments = await github.rest.issues.listComments({
owner: owner,
repo: repo,
issue_number: prNumber,
});
const versionComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Version Check')
);
if (versionComment) {
if (success) {
// Delete the warning comment if check passes
await github.rest.issues.deleteComment({
owner: owner,
repo: repo,
comment_id: versionComment.id
});
} else {
// Update existing warning
await github.rest.issues.updateComment({
owner: owner,
repo: repo,
comment_id: versionComment.id,
body: `❌ **Version Check Failed**\n\nPlease increment...`
});
}
} else if (!success) {
// Create new warning comment only if check fails
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: prNumber,
body: `❌ **Version Check Failed**\n\nPlease increment...`
});
}