Skip to content

feat: adds automatic dependency update #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/dependency-checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Dependency-Updater

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
dependency_updater:
name: Dependency-Updater
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Poetry Python dependeny updater
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --global user.name "SDK Releaser Bot"
git config --global user.email "[email protected]"

pip install poetry
make update-dependencies
for file in $(git diff --name-only | grep poetry.lock); do
# Extract the service for which the dependencies have been updated
dirpath=$(dirname $file)
pr_name=$(echo "Dependency Updater: ${dirpath}")

# Check if a PR already exists for the package
if gh pr list --state open | grep -q "${pr_name}"; then
echo "Pr for $dirpath already exists. Skipping."
else
# Create PR
branch_name="dependency-updater-$dirpath"
git checkout -b "$branch_name"
git add "$file"
git commit -m "chore: dependency update"
git push --set-upstream origin "$branch_name"
echo $(git status)
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
git checkout main
fi
done

28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ SERVICES_DIR := services

install:
# install core
pip install core
pip install core/
# install services
@for f in $(shell ls ${SERVICES_DIR}); do pip install ${SERVICES_DIR}/$${f}; done

install-dev:
# install core
pip install -e core && poetry install -C core --only dev --no-root
install-dev:
# install services
@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
@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
# install core. This needs to be done last or it will get overriden by the dependency installation of the services
poetry install -C core --no-root; pip install -e core

test:
# test core
cd core && pytest && cd ..
cd core && poetry install --with dev && pytest
# test services
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f}; sh -c 'pytest || ([ $$? = 5 ] && exit 0 || exit $$?)'; cd ../..; done
@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

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

lock:
update-dependencies:
# lock core
cd core;poetry lock --no-update;cd..;
cd core && poetry lock
# lock services
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry lock --no-update; cd ../..; done
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry lock; cd ../..; done
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ If you encounter any issues or have suggestions for improvements, please open an
## Contribute

### Installing in editable mode
For developing it is recommended to install `poetry`, which can be installed via:
```bash
pip install poetry
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).

For development it is best to install the packages in editable mode.
You can install a single package in editable mode using the following command:
Expand All @@ -181,6 +179,9 @@ If you want to install all services in editable mode, as well as the dev-depende
```bash
make install-dev
```
When using the `make install-dev` command it is important to prevent `poetry` from creating a different environment for every package.
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.

## License

Apache 2.0
87 changes: 70 additions & 17 deletions core/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 20 additions & 17 deletions core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
pyjwt = "^2.9.0"
pydantic = "^2.9.2"
urllib3 = "^2.2.3"
cryptography = "^43.0.1"
requests = "^2.32.3"
pyjwt = ">=2.9.0"
pydantic = ">=2.9.2"
urllib3 = ">=2.2.3"
cryptography = ">=43.0.1"
requests = ">=2.32.3"


[tool.poetry.group.dev.dependencies]
black = "24.8.0"
pytest = "^8.3.3"
flake8 = "^5.0.3"
flake8-black = "^0.3.6"
flake8-pyproject = "^1.2.3"
flake8-quotes = "^3.4.0"
flake8-bandit = "^4.1.1"
flake8-bugbear = "^23.1.14"
flake8-eradicate = "^1.5.0"
flake8-eol = "^0.0.8"
autoimport = "^1.6.1"
isort = "^5.13.2"
black = ">=24.8.0"
pytest = ">=8.3.3"
flake8 = [
{ version= ">=5.0.3", python="<3.12"},
{ version= ">=6.0.1", python=">=3.12"}
]
flake8-black = ">=0.3.6"
flake8-pyproject = ">=1.2.3"
flake8-quotes = ">=3.4.0"
flake8-bandit = ">=4.1.1"
flake8-bugbear = ">=23.1.14"
flake8-eradicate = ">=1.5.0"
flake8-eol = ">=0.0.8"
autoimport = ">=1.6.1"
isort = ">=5.13.2"

[project.urls]
Homepage = "https://github.com/stackitcloud/stackit-sdk-python"
Expand Down
Loading
Loading