File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Update README
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - ' src/datamodel_code_generator/__main__.py'
8+ pull_request :
9+ branches : [main]
10+ paths :
11+ - ' src/datamodel_code_generator/__main__.py'
12+
13+ permissions :
14+ contents : write
15+
16+ jobs :
17+ update-readme :
18+ if : github.event_name == 'push' || !github.event.pull_request.head.repo.fork
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+ ref : ${{ github.head_ref || github.ref }}
25+ token : ${{ secrets.GITHUB_TOKEN }}
26+ - name : Install the latest version of uv
27+ uses : astral-sh/setup-uv@v5
28+ - name : Install tox
29+ run : uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
30+ - name : Setup environment
31+ run : tox run -vv --notest --skip-missing-interpreters false -e readme
32+ env :
33+ UV_PYTHON_PREFERENCE : " only-managed"
34+ - name : Update README
35+ run : .tox/readme/bin/python scripts/update_command_help_on_markdown.py
36+ - name : Commit and push if changed
37+ run : |
38+ git config user.name "github-actions[bot]"
39+ git config user.email "github-actions[bot]@users.noreply.github.com"
40+ git add README.md docs/index.md
41+ git diff --staged --quiet || git commit -m "docs: update command help in README
42+
43+ 🤖 Generated by GitHub Actions"
44+ git push
Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ jobs:
127127 - dev
128128 - docs
129129 - pkg_meta
130- - readme
131130 steps :
132131 - uses : actions/checkout@v4
133132 with :
Original file line number Diff line number Diff line change 1+ ci :
2+ skip : [readme]
3+
14repos :
25- repo : https://github.com/python-jsonschema/check-jsonschema
36 rev : 0.35.0
@@ -29,3 +32,11 @@ repos:
2932 additional_dependencies :
3033 - tomli
3134 exclude : " ^tests/|^CODE_OF_CONDUCT.md"
35+ - repo : local
36+ hooks :
37+ - id : readme
38+ name : Update README command help
39+ entry : bash -c 'test -x .tox/fix/bin/python || tox run -e fix --notest -qq; .tox/fix/bin/python scripts/update_command_help_on_markdown.py'
40+ language : system
41+ files : ^(src/datamodel_code_generator/__main__\.py|README\.md|docs/index\.md)$
42+ pass_filenames : false
Original file line number Diff line number Diff line change @@ -64,21 +64,22 @@ def main() -> Exit:
6464 """Update or validate command help in target markdown files."""
6565 help_text = get_help ()
6666 arg_parser .add_argument (
67- "--validate " ,
67+ "--check " ,
6868 action = "store_true" ,
69- help = "Validate the file content is up to date" ,
69+ help = "Check if the file content is up to date without modifying " ,
7070 )
7171 args = arg_parser .parse_args ()
72- validate : bool = args .validate
72+ check : bool = args .check
7373
7474 for file_path in TARGET_MARKDOWN_FILES :
7575 with file_path .open ("r" ) as f :
7676 markdown_text = f .read ()
7777 new_markdown_text = inject_help (markdown_text , help_text )
78- if validate and new_markdown_text != markdown_text :
79- return Exit .ERROR
80- with file_path .open ("w" ) as f :
81- f .write (new_markdown_text )
78+ if new_markdown_text != markdown_text :
79+ if check :
80+ return Exit .ERROR
81+ with file_path .open ("w" ) as f :
82+ f .write (new_markdown_text )
8283 return Exit .OK
8384
8485
Original file line number Diff line number Diff line change @@ -56,15 +56,14 @@ dependency_groups =
5656
5757[testenv:fix]
5858description = format the code base to adhere to our styles, and complain about what we cannot do automatically
59- skip_install = true
6059commands =
6160 pre-commit run --all-files --show-diff-on-failure
6261dependency_groups = fix
6362
6463[testenv:readme]
65- description = Update help in readme
64+ description = Check help in readme is up to date
6665commands =
67- python scripts/update_command_help_on_markdown.py {posargs:--validate }
66+ python scripts/update_command_help_on_markdown.py {posargs:--check }
6867dependency_groups =
6968no_default_groups = true
7069
You can’t perform that action at this time.
0 commit comments