Skip to content

Commit

Permalink
refactor: Update code to properly run the updater action
Browse files Browse the repository at this point in the history
  • Loading branch information
nfelt14 committed Aug 19, 2024
1 parent 53b2ae3 commit fc03d94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion actions/update-development-dependencies/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/00-docker && \
RUN python -m pip install --no-cache-dir --requirement /requirements.txt

# Run the updater script as the entrypoint
CMD ["python", "/update_development_dependencies.py"]
CMD ["python", "-u", "/update_development_dependencies.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,11 @@ def _update_pre_commit_dependencies(
repository_root_directory: The root directory of the repository.
"""
_run_cmd_in_subprocess(
f'git config --global --add safe.directory "{repository_root_directory.resolve().as_posix()}"'
f"git config --global --add safe.directory "
f'"{repository_root_directory.resolve().as_posix()}"'
)
# Update pre-commit config file
try:
_run_cmd_in_subprocess(f'"{python_executable}" -m pre_commit autoupdate --freeze')
except:
with open("/github/home/.cache/pre-commit/pre-commit.log") as f:
print(f.read())
raise
_run_cmd_in_subprocess(f'"{python_executable}" -m pre_commit autoupdate --freeze')

# Fix the formatting of the pre-commit config file
with warnings.catch_warnings():
Expand Down Expand Up @@ -249,6 +245,8 @@ def _sort_requirements_file(file_path: Path) -> None:
with file_path.open("w") as file:
file.writelines(lines)

_run_cmd_in_subprocess(f'"{python_executable}" -m poetry config warnings.export false')

for group_output_pair in dependency_groups:
if ":" in group_output_pair:
group, output_folder = group_output_pair.split(":", maxsplit=1)
Expand All @@ -268,9 +266,9 @@ def main() -> None:

args = _parse_arguments()

print(f"\nUpdating development dependencies in {args.repo_root}")
repo_root = Path(args.repo_root)
os.chdir(repo_root)
repo_root_path = Path(args.repo_root).resolve()
os.chdir(repo_root_path)
print(f"\nUpdating development dependencies in {Path.cwd()}")

_update_poetry_dependencies(
python_executable,
Expand All @@ -279,7 +277,7 @@ def main() -> None:
lock_only=not args.install_dependencies,
)
if args.update_pre_commit or args.run_pre_commit:
_update_pre_commit_dependencies(python_executable, args.repo_root)
_update_pre_commit_dependencies(python_executable, repo_root_path)
if args.dependency_groups:
_export_requirements_files(python_executable, args.dependency_groups)
if args.run_pre_commit:
Expand Down

0 comments on commit fc03d94

Please sign in to comment.