Skip to content

Fix providing version directly#16

Open
MicahWW wants to merge 3 commits intosindrel:mainfrom
MicahWW:main
Open

Fix providing version directly#16
MicahWW wants to merge 3 commits intosindrel:mainfrom
MicahWW:main

Conversation

@MicahWW
Copy link

@MicahWW MicahWW commented Oct 15, 2025

When using the Python script directly, instead of the Action, it will error because no file format is given.

$ python ./src/get_cycle.py --product python --version 2.7
A regex must be provided when using text format.

This doesn't happen when using the action because a default file type of yaml is given.

file_format:
required: false
description: "Format of the file containing the version information."
default: "yaml"

The other options are not used when the version is defined, as seen in the get_product_cycle function below, so duplicating that logic on the option validation fixes the issue.

if not args.version:
with open(file=args.file_path, mode='r', encoding='utf8') as file:
file_contents = file.read()
if args.file_format in ['yaml', 'json']:
print(f"Looking for version in file '{args.file_path}' using key '{args.file_key}'...")
version = _get_version_from_structured_file(args, file_contents)
elif args.file_format == 'text':
print(f"Looking for version in file '{args.file_path}' using regex '{args.regex}'...")
version = _extract_value_from_string(args.regex, file_contents)
else:
version = args.version

@sindrel sindrel self-assigned this Oct 16, 2025
@sindrel sindrel requested a review from Copilot October 16, 2025 06:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where running the Python script directly with a version parameter fails due to unnecessary validation of file-related parameters. When a version is provided directly, the script should skip file-related validations since the version supersedes file parsing logic.

Key changes:

  • Modified argument validation to skip file-related checks when version is provided
  • Added integration test to verify the fix works correctly with the GitHub Action

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/get_cycle.py Updated validation logic to only check file_path and related parameters when version is not supplied
.github/workflows/integrations-tests.yml Added test case for Python version 2.7 to verify version-only usage works correctly

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sindrel
Copy link
Owner

sindrel commented Oct 16, 2025

Hi @MicahWW, thanks for opening the pull request.

If I understand correctly, you want to fix this so it's easier to run the Python script directly, and not use it as a GitHub Action. I don't think this is a use-case I have considered. Could you provide any examples of why/when you would want to run it directly?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MicahWW
Copy link
Author

MicahWW commented Oct 16, 2025

In the long run I am planning on just using your action but before I started using it I wanted to give the code a once over to see what was going on and what the expected output would be like before adding it to my repo, so I ran a test in my terminal which is when I noticed the issue and started working on a fix.
After I did all that, I started working on the pull request and that is when I noticed that it wasn't affecting the action due to the default value given there.

TLDR: I don't plan on using the script directly, I just happened to stumble across the issue by chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants