Skip to content

Commit

Permalink
lock0
Browse files Browse the repository at this point in the history
  • Loading branch information
vivodi committed Jan 15, 2025
1 parent 11105ee commit bac61aa
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 15 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ concurrency:
env:
UV_VERSION: 0.5.18 # renovate: datasource=pypi depName=uv
jobs:
check-lockfile-status:
name: Check Lockfile Status
runs-on: ubuntu-latest
env:
PYTHON_VERSION: '3.13' # renovate: datasource=python-version depName=python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install uv
uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a # v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
version: ${{ env.UV_VERSION }}
- run: uv lock --locked
tests:
name: Run Tests
runs-on: ${{ matrix.operating-system }}
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/uv-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Enforce Lockfile Status
on: [ push, pull_request_target]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.13' # renovate: datasource=python-version depName=python
UV_VERSION: 0.5.18 # renovate: datasource=pypi depName=uv
jobs:
uv-lock:
name: uv lock
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: check for mergeability
if: github.event_name == 'pull_request_target'
env:
GH_TOKEN: ${{ github.token }}
run: |
retryCount=3
retryInterval=5
while true; do
echo "Checking whether the pull request can be merged"
prInfo=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/"$GITHUB_REPOSITORY"/pulls/${{ github.event.pull_request.number }})
mergeable=$(jq -r .mergeable <<< "$prInfo")
if [[ "$mergeable" == "null" ]]; then
if (( retryCount == 0 )); then
echo "Not retrying anymore, probably GitHub is having internal issues"
exit 1
else
(( retryCount -= 1 )) || true
echo "GitHub is still computing whether this PR can be merged, waiting $retryInterval seconds before trying again ($retryCount retries left)"
sleep "$retryInterval"
(( retryInterval *= 2 )) || true
fi
else
break
fi
done
if [[ "$mergeable" == "true" ]]; then
echo "The PR can be merged"
else
echo "The PR cannot be merged, it has a merge conflict, cancelling the workflow..."
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_ID"/cancel
sleep 60
# If it's still not canceled after a minute, something probably went wrong, just exit
exit 1
fi
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
path: merge
- name: Install uv
uses: astral-sh/setup-uv@887a942a15af3a7626099df99e897a18d9e5ab3a # v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
version: ${{ env.UV_VERSION }}
- run: |
if [[ ${{github.event_name}} == "push" ]]
then
uv lock
else
uv lock --directory merge
mv merge/uv.lock uv.lock
fi
if ! git diff --exit-code
then
git config user.email github-actions[bot]@users.noreply.github.com
git config user.name github-actions[bot]
git add uv.lock
git commit -m "Enforce lockfile status"
if ! git push
then
echo "failed=1" >> "$GITHUB_ENV"
fi
fi
- uses: actions/github-script@v7
if: env.failed == 1
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `The \`uv.lock\` file is missing or needs to be updated and we can't automatically fix it for you because you didn't check the 'Allow edits by maintainers' box.
Please check the box and push again or manually run
\`\`\`
uv lock
\`\`\``
})
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ authors = [
license = { file = "LICENSE" }
dynamic = ["version", "optional-dependencies"]
dependencies = [
"apscheduler ~=3.11",
"apscheduler ~=3.10",
"beautifulsoup4 ~=4.12",
"colorama ~=0.4.6",
"feedparser ~=6.0",
Expand Down

0 comments on commit bac61aa

Please sign in to comment.