Test Python Package / unit-tests (pull_request) Successful in 12s
Code Quality Pipeline / code-quality (pull_request) Successful in 19s
PR Title Check / check-title (pull_request) Successful in 31s
Test Python Package / integration-tests (pull_request) Successful in 23s
Test Python Package / coverage-report (pull_request) Successful in 10s
Route Python hooks through uv run with versions pinned in uv.lock, add explicit Ruff settings, and extend the dependency bot to run pre-commit autoupdate. Co-authored-by: Cursor <cursoragent@cursor.com>
71 lines
2.1 KiB
Bash
Executable File
71 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
: "${API_URL:?API_URL is required}"
|
|
: "${REPO_OWNER:?REPO_OWNER is required}"
|
|
: "${REPO_NAME:?REPO_NAME is required}"
|
|
: "${CI_RUNNER_TOKEN:?CI_RUNNER_TOKEN is required}"
|
|
: "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}"
|
|
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
|
|
|
|
BRANCH="${BRANCH:-renovate/auto-deps-update}"
|
|
BASE_BRANCH="${BASE_BRANCH:-main}"
|
|
LOCKFILE="${LOCKFILE:-uv.lock}"
|
|
PRE_COMMIT_CONFIG="${PRE_COMMIT_CONFIG:-.pre-commit-config.yaml}"
|
|
|
|
if git diff --quiet "$LOCKFILE" && git diff --quiet "$PRE_COMMIT_CONFIG"; then
|
|
echo "No dependency updates available."
|
|
exit 0
|
|
fi
|
|
|
|
git config user.name "CI Bot"
|
|
git config user.email "ci-bot@example.com"
|
|
git add "$LOCKFILE" "$PRE_COMMIT_CONFIG"
|
|
git commit -m "chore(deps): update dependencies [automated]"
|
|
|
|
git remote set-url origin "https://x-access-token:${CI_RUNNER_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
|
git push origin "HEAD:${BRANCH}"
|
|
|
|
if curl -s "${API_URL}/repos/${REPO_OWNER}/${REPO_NAME}/pulls?state=open" \
|
|
-H "Authorization: token ${CI_RUNNER_TOKEN}" \
|
|
| BRANCH="$BRANCH" python3 -c '
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
branch = os.environ["BRANCH"]
|
|
prs = json.load(sys.stdin)
|
|
sys.exit(0 if any(pr.get("head", {}).get("ref") == branch for pr in prs) else 1)
|
|
'; then
|
|
echo "Pull request already exists; branch push updates it."
|
|
exit 0
|
|
fi
|
|
|
|
PAYLOAD=$(BRANCH="$BRANCH" BASE_BRANCH="$BASE_BRANCH" python3 -c '
|
|
import json
|
|
import os
|
|
|
|
print(
|
|
json.dumps(
|
|
{
|
|
"title": "chore(deps): update dependencies",
|
|
"body": (
|
|
"This PR was created automatically to update dependencies.\n\n"
|
|
"- `uv.lock`: upgraded Python dependencies\n"
|
|
"- `.pre-commit-config.yaml`: updated remote hook revs via "
|
|
"`pre-commit autoupdate`"
|
|
),
|
|
"head": os.environ["BRANCH"],
|
|
"base": os.environ["BASE_BRANCH"],
|
|
}
|
|
)
|
|
)
|
|
')
|
|
|
|
curl -sf -X POST "${API_URL}/repos/${REPO_OWNER}/${REPO_NAME}/pulls" \
|
|
-H "Authorization: token ${CI_RUNNER_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$PAYLOAD"
|
|
|
|
echo "Created pull request."
|