Skip to content

Commit 53dcd74

Browse files
authored
ci: switch back to dependabot (with custom config) (#53)
1 parent 032c41f commit 53dcd74

3 files changed

Lines changed: 71 additions & 6 deletions

File tree

.github/dependabot.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# enable dependabot's scanning but do not allow creation of pull requests
3+
# (please use 'scripts/update_dependencies' to update the dependencies)
4+
#
5+
# - dependabot does not understand PEP-621 repositories (pyproject.toml)
6+
# - dependabot expects the filename to end in '<...>requirements.txt' and
7+
# ignores requirements-dev.txt ('dev-requirements.txt' would work but
8+
# that's kinda stupid since the requirements files are no longer grouped
9+
# by name -> we should optimize for humans instead of computers)
10+
# - renovate supports PEP-621 but it gets confused since we provide
11+
# requirements.txt which makes it ignore pyproject.toml and pdm.lock
12+
#
13+
# --> provide our own mechanism to update requirements*.txt AND pdm.lock
14+
15+
version: 2
16+
17+
updates:
18+
- package-ecosystem: pip
19+
directory: "/"
20+
schedule:
21+
interval: daily
22+
time: "13:00"
23+
groups:
24+
python-packages:
25+
patterns:
26+
- "*"
27+
open-pull-requests-limit: 0

renovate.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/update_dependencies

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
#
3+
# update Python dependencies using PDM
4+
# (requires `gh auth login`)
5+
#
6+
7+
set -e
8+
set -u
9+
10+
branch_name="fb-update-dependencies_`date +'%s'`"
11+
12+
git stash save
13+
current_branch=`git branch --show-current`
14+
git checkout master
15+
git pull
16+
git checkout -b $branch_name
17+
pdm update --update-all
18+
git add --update
19+
git commit -m "chore: update dependencies (pdm update --update-all)"
20+
git push --set-upstream origin $branch_name
21+
git checkout $current_branch
22+
23+
# restore original state
24+
git checkout $current_branch
25+
if git stash show ; then
26+
git stash pop
27+
fi
28+
29+
# if present: use GitHub CLI tools to create a pull request
30+
if command -v gh >/dev/null ; then
31+
# I'm sorry but this is the best I could come up with to test if there
32+
# is a label "dependencies".
33+
# - 'gh label list' limits its output to 30 tags
34+
# - '--search' will find close matches (e.g. typos) and is not reliable
35+
# - --jq='.[] | select(.name=="...")' does not indicate if there was no
36+
# result ('...|jq -e' would, but that would require jq to be installed)
37+
if ! gh label list --search="dep" --json='name' --jq='.[]["name"]'|grep -q "^dependencies$" ; then
38+
gh label create dependencies --color="#0366d6"
39+
fi
40+
gh pr create --assignee="@me" --base=master --head=$branch_name --fill --label="dependencies"
41+
else
42+
echo "GitHub CLI tools not found. Unable to create a pull request."
43+
echo "-> https://github.com/cli/cli"
44+
fi

0 commit comments

Comments
 (0)