Skip to content

Commit cf1cdc0

Browse files
MelvinKljoaopalet
andauthored
feat: adds automatic dependency update (#78)
Co-authored-by: João Palet <joao.palet@outlook.com>
1 parent 0e2c317 commit cf1cdc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+596
-491
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Dependency-Updater
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
dependency_updater:
10+
name: Dependency-Updater
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Install Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.8"
19+
- name: Poetry Python dependeny updater
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
run: |
23+
git config --global user.name "SDK Releaser Bot"
24+
git config --global user.email "noreply@stackit.de"
25+
26+
pip install poetry
27+
make update-dependencies
28+
for file in $(git diff --name-only | grep poetry.lock); do
29+
# Extract the service for which the dependencies have been updated
30+
dirpath=$(dirname $file)
31+
pr_name=$(echo "Dependency Updater: ${dirpath}")
32+
33+
# Check if a PR already exists for the package
34+
if gh pr list --state open | grep -q "${pr_name}"; then
35+
echo "Pr for $dirpath already exists. Skipping."
36+
else
37+
# Create PR
38+
branch_name="dependency-updater-$dirpath"
39+
git checkout -b "$branch_name"
40+
git add "$file"
41+
git commit -m "chore: dependency update"
42+
git push --set-upstream origin "$branch_name"
43+
echo $(git status)
44+
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
45+
git checkout main
46+
fi
47+
done
48+

Makefile

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@ SERVICES_DIR := services
22

33
install:
44
# install core
5-
pip install core
5+
pip install core/
66
# install services
77
@for f in $(shell ls ${SERVICES_DIR}); do pip install ${SERVICES_DIR}/$${f}; done
88

9-
install-dev:
10-
# install core
11-
pip install -e core && poetry install -C core --only dev --no-root
9+
install-dev:
1210
# install services
13-
@for f in $(shell ls ${SERVICES_DIR}); do pip install -e ${SERVICES_DIR}/$${f};poetry install -C ${SERVICES_DIR}/$${f} --only dev --no-root; done
11+
@for f in $(shell ls ${SERVICES_DIR}); do set -e;poetry install -C ${SERVICES_DIR}/$${f} --no-root;pip install -e ${SERVICES_DIR}/$${f}; done
12+
# install core. This needs to be done last or it will get overriden by the dependency installation of the services
13+
poetry install -C core --no-root; pip install -e core
1414

1515
test:
1616
# test core
17-
cd core && pytest && cd ..
17+
cd core && poetry install --with dev && pytest
1818
# test services
19-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f}; sh -c 'pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; done
19+
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f}; poetry install --with dev;sh -c 'pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; done
2020

21-
lint:
22-
# lint examples
23-
flake8 --toml-config $(word 1, $(wildcard $(SERVICES_DIR)/*))/pyproject.toml --black-config $(word 1, $(wildcard $(SERVICES_DIR)/*))/pyproject.toml examples;
21+
lint:
2422
# lint core
23+
cd core && poetry install --no-root --only dev &&flake8 .
24+
# lint examples. Use configuration from core
2525
flake8 --toml-config core/pyproject.toml --black-config core/pyproject.toml examples;
2626
# lint services
27-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};flake8 .; cd ../..; done
27+
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry install --no-root --only dev; flake8 .; cd ../..; done
2828

29-
lock:
29+
update-dependencies:
3030
# lock core
31-
cd core;poetry lock --no-update;cd..;
31+
cd core && poetry lock
3232
# lock services
33-
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry lock --no-update; cd ../..; done
33+
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry lock; cd ../..; done

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ If you encounter any issues or have suggestions for improvements, please open an
158158
## Contribute
159159

160160
### Installing in editable mode
161-
For developing it is recommended to install `poetry`, which can be installed via:
162-
```bash
163-
pip install poetry
161+
For developing it is recommended to install [`poetry`](https://python-poetry.org/). An installation guide can be found [here](https://python-poetry.org/docs/#installation).
164162

165163
For development it is best to install the packages in editable mode.
166164
You can install a single package in editable mode using the following command:
@@ -181,6 +179,9 @@ If you want to install all services in editable mode, as well as the dev-depende
181179
```bash
182180
make install-dev
183181
```
182+
When using the `make install-dev` command it is important to prevent `poetry` from creating a different environment for every package.
183+
This can be achieved by running `poetry config virtualenvs.create false`, but there are multiple way to achieve this. You can check the [`poetry` docs](https://python-poetry.org/docs/configuration/) to see which option fits best for you.
184+
184185
## License
185186

186187
Apache 2.0

core/poetry.lock

+70-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/pyproject.toml

+20-17
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,29 @@ packages = [
1818

1919
[tool.poetry.dependencies]
2020
python = ">=3.8,<4.0"
21-
pyjwt = "^2.9.0"
22-
pydantic = "^2.9.2"
23-
urllib3 = "^2.2.3"
24-
cryptography = "^43.0.1"
25-
requests = "^2.32.3"
21+
pyjwt = ">=2.9.0"
22+
pydantic = ">=2.9.2"
23+
urllib3 = ">=2.2.3"
24+
cryptography = ">=43.0.1"
25+
requests = ">=2.32.3"
2626

2727

2828
[tool.poetry.group.dev.dependencies]
29-
black = "24.8.0"
30-
pytest = "^8.3.3"
31-
flake8 = "^5.0.3"
32-
flake8-black = "^0.3.6"
33-
flake8-pyproject = "^1.2.3"
34-
flake8-quotes = "^3.4.0"
35-
flake8-bandit = "^4.1.1"
36-
flake8-bugbear = "^23.1.14"
37-
flake8-eradicate = "^1.5.0"
38-
flake8-eol = "^0.0.8"
39-
autoimport = "^1.6.1"
40-
isort = "^5.13.2"
29+
black = ">=24.8.0"
30+
pytest = ">=8.3.3"
31+
flake8 = [
32+
{ version= ">=5.0.3", python="<3.12"},
33+
{ version= ">=6.0.1", python=">=3.12"}
34+
]
35+
flake8-black = ">=0.3.6"
36+
flake8-pyproject = ">=1.2.3"
37+
flake8-quotes = ">=3.4.0"
38+
flake8-bandit = ">=4.1.1"
39+
flake8-bugbear = ">=23.1.14"
40+
flake8-eradicate = ">=1.5.0"
41+
flake8-eol = ">=0.0.8"
42+
autoimport = ">=1.6.1"
43+
isort = ">=5.13.2"
4144

4245
[project.urls]
4346
Homepage = "https://github.com/stackitcloud/stackit-sdk-python"

0 commit comments

Comments
 (0)