Skip to content

Commit 1cc540b

Browse files
author
github-actions[bot]
committed
🔧GitHub Actions workflow to update requirements after Dependabot merges
1 parent a0a8da8 commit 1cc540b

File tree

5 files changed

+98
-43
lines changed

5 files changed

+98
-43
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Update Requirements after Dependabot Merge
2+
3+
# ワークフローの処理の流れ:
4+
# 1. トリガー条件:
5+
# - プルリクエストマージ時
6+
# - Dependabotによる実行であること
7+
# 2. 環境のセットアップ(Ubuntu、Python、Poetry)
8+
# 3. poetry.lockファイルの更新
9+
# 4. 依存関係のインストール(更新されたlockファイルを使用)
10+
# 5. requirements.txtとrequirements-dev.txtの生成
11+
# 6. 変更のコミットとプッシュ(poetry.lockを含む)
12+
13+
on:
14+
pull_request:
15+
types: [closed]
16+
17+
jobs:
18+
update-requirements:
19+
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4.2.2
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.PAT_FOR_PUSHES }}
26+
- name: Set up Python
27+
uses: actions/setup-python@v5.4.0
28+
with:
29+
python-version: '3.13'
30+
- name: Install Poetry
31+
run: pip install poetry
32+
- name: Add plugin
33+
run: poetry self add poetry-plugin-export
34+
- name: Update lock file
35+
run: poetry lock
36+
- name: Install dependencies
37+
run: poetry install
38+
- name: Update requirements files
39+
run: |
40+
poetry export -f requirements.txt -o requirements.txt --without-hashes
41+
poetry export -f requirements.txt -o requirements-dev.txt --without-hashes --with dev
42+
- name: Commit and push changes
43+
run: |
44+
git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com"
45+
git config --local user.name "github-actions[bot]"
46+
git add requirements.txt requirements-dev.txt poetry.lock
47+
git commit -m ":wrench:Update requirements files after dependency update [skip ci]" || echo "No changes to commit"
48+
git push

.pre-commit-config.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ repos:
3232
- id: poetry-lock
3333
verbose: true
3434

35+
# [Note] poetry export is not done in pre-commit, but in GitHub Actions (update-requirements-after-dependabot.yml)
3536
# https://github.com/python-poetry/poetry-plugin-export?tab=readme-ov-file#usage
36-
- repo: https://github.com/python-poetry/poetry-plugin-export.git
37-
rev: 1.9.0
38-
hooks:
39-
- id: poetry-export
40-
args: ["-f", "requirements.txt", "-o", "requirements.txt", "--without-hashes"]
41-
verbose: true
42-
files: ^pyproject\.toml$
43-
- id: poetry-export
44-
args: ["--with", "dev", "-f", "requirements.txt", "-o", "requirements-dev.txt", "--without-hashes"]
45-
verbose: true
46-
files: ^pyproject\.toml$
37+
#- repo: https://github.com/python-poetry/poetry-plugin-export.git
38+
# rev: 1.9.0
39+
# hooks:
40+
# - id: poetry-export
41+
# args: ["-f", "requirements.txt", "-o", "requirements.txt", "--without-hashes"]
42+
# verbose: true
43+
# files: ^pyproject\.toml$
44+
# - id: poetry-export
45+
# args: ["--with", "dev", "-f", "requirements.txt", "-o", "requirements-dev.txt", "--without-hashes"]
46+
# verbose: true
47+
# files: ^pyproject\.toml$
4748

4849
# https://github.com/shellcheck-py/shellcheck-py?tab=readme-ov-file#usage
4950
- repo: https://github.com/shellcheck-py/shellcheck-py

poetry.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# For poetry versiion(>=2.0.0)
12
#[project]
23
#name = "mkdocs-macros-utils"
34
#version = "0.0.7"
@@ -35,11 +36,7 @@
3536
#repository = "https://github.com/7rikazhexde/mkdocs-macros-utils"
3637
#documentation = "https://7rikazhexde.github.io/mkdocs-macros-utils/"
3738

38-
# Build system configuration
39-
[build-system]
40-
requires = ["poetry-core>=2.0.0,<3.0.0"]
41-
build-backend = "poetry.core.masonry.api"
42-
39+
# For poetry versiion(<2.0.0)
4340
[tool.poetry]
4441
name = "mkdocs-macros-utils"
4542
version = "0.0.7"
@@ -72,6 +69,11 @@ pytest-mock = "^3.14.0"
7269
pytest-xdist = "^3.6.1"
7370
taskipy = "^1.14.1"
7471

72+
# Build system configuration
73+
[build-system]
74+
requires = ["poetry-core>=2.0.0,<3.0.0"]
75+
build-backend = "poetry.core.masonry.api"
76+
7577
# Task runner configuration
7678
[tool.taskipy.tasks]
7779
test_coverage_verbose = "pytest -s -vv --cov=mkdocs_macros_utils --cov-branch --cov-report term-missing --cov-report html"
@@ -94,6 +96,7 @@ warn_return_any = true
9496
warn_unused_ignores = true
9597
warn_redundant_casts = true
9698

99+
# Overrides mypy ignore import settings
97100
[[tool.mypy.overrides]]
98101
module = ["mkdocs.*","mkdocs_macros.*","jinja2.*","ruamel.*","pygments.*"]
99102
ignore_missing_imports = true

tests/python/mkdocs_macros_utils/test__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ def test_on_files() -> None:
129129
config = Config(schema=[])
130130
result = on_files(files, config)
131131

132+
# Normalize paths to use forward slashes for consistent comparison
133+
paths = [f.src_path.replace("\\", "/") for f in result]
134+
expected_style_css = f"{MACROS_UTILS_DIR}/style.css".replace("\\", "/")
135+
132136
# Verify files are processed correctly
133-
paths = [f.src_path for f in result]
134137
assert "test.md" in paths
135-
assert f"{MACROS_UTILS_DIR}/style.css" in paths
138+
assert expected_style_css in paths
136139
assert "other/file.md" in paths
137140

138141

0 commit comments

Comments
 (0)