Skip to content
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

Feature/1 initial repository setup #2

Merged
merged 36 commits into from
May 21, 2024

Conversation

miroslavpojer
Copy link
Collaborator

Create the initial version of the project.
Populate by logic from the origin project and integrate.

Closes #1

@miroslavpojer miroslavpojer self-assigned this May 9, 2024
@Zejnilovic Zejnilovic self-requested a review May 9, 2024 12:19
core.setFailed('No "Release notes" found in PR comments')
} else {
console.log('"Release notes" found in comments');
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in commit - 0c435b7.

uses: actions/github-script@v7
with:
script: |
const newTag = core.getInput('tag-name');
Copy link
Collaborator

Choose a reason for hiding this comment

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

line 5 is tagName here it is tag-name. Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in commit - 0c435b7.

Comment on lines +3 to +10
on:
pull_request:
types: [closed]
branches: [ master ]

jobs:
copy_release_notes:
if: github.event.pull_request.merged == true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not on push to master?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The logic is to migrate all Release notes comments from PR to related Issues only when PR is closed.
By push, there would be repeated duplication.

body: commentBody
});
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in commit - 0c435b7.

run: |
echo "Extracted Release Note Body:"
echo "${{ steps.get-comments.outputs.releaseNoteBody }}"
echo "RELEASE_NOTE_BODY<<EOF" >> $GITHUB_ENV
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this maybe missing a =?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Where?

const regexPattern = /([Cc]los(e|es|ed)|[Ff]ix(es|ed)?|[Rr]esolv(e|es|ed))\s*#\s*([0-9]+)/g;

let match;
while ((match = regexPattern.exec(description)) !== null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have an issue to wrap my head around this one

Copy link
Collaborator Author

@miroslavpojer miroslavpojer May 15, 2024

Choose a reason for hiding this comment

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

This is a regex detector of the mentioned Issue in the PR description. It does not look nice, yes.

.github/workflows/unit_tests.yml Outdated Show resolved Hide resolved
.gitignore Outdated
Comment on lines 160 to 161
#.idea/
/.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

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

pick one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in commit - bcb84a5.

README.md Outdated
Comment on lines 107 to 111
- **Submit Pull Requests**: Feel free to fork the repository, make changes, and submit a pull request. Please ensure your code adheres to the existing style and all tests pass.
- **Report Issues**: If you encounter any bugs or issues, please report them via the repository's [Issues page](https://github.com/AbsaOSS/living-doc-generator/issues).
- **Suggest Enhancements**: Have ideas on how to make this action better? Open an issue to suggest enhancements.

Before contributing, please review our [contribution guidelines](https://github.com/AbsaOSS/living-doc-generator/blob/master/CONTRIBUTING.md) for more detailed information.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- **Submit Pull Requests**: Feel free to fork the repository, make changes, and submit a pull request. Please ensure your code adheres to the existing style and all tests pass.
- **Report Issues**: If you encounter any bugs or issues, please report them via the repository's [Issues page](https://github.com/AbsaOSS/living-doc-generator/issues).
- **Suggest Enhancements**: Have ideas on how to make this action better? Open an issue to suggest enhancements.
Before contributing, please review our [contribution guidelines](https://github.com/AbsaOSS/living-doc-generator/blob/master/CONTRIBUTING.md) for more detailed information.
Before contributing, please review our [contribution guidelines](https://github.com/AbsaOSS/living-doc-generator/blob/master/CONTRIBUTING.md) for more detailed information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in commit - bcb84a5.

@miroslavpojer miroslavpojer marked this pull request as ready for review May 16, 2024 08:02
@miroslavpojer
Copy link
Collaborator Author

miroslavpojer commented May 16, 2024

Release notes:

  • Empty project populated by all required project logic stuff.
  • Introduced Python code solution for data mining from GH repositories and Projects
  • Introduced GH Action logic to provide Python code to be used by GH Action usage.
  • Usage of action tested in the example project.

See the default action step definition:

```yaml
- name: Generate Living Documentation
Copy link
Collaborator

@MobiTikula MobiTikula May 16, 2024

Choose a reason for hiding this comment

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

May change name to Living Documentation Generator everywhere in README as it is in action.yml file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have checked the file and fixed capital in 1st line. Other variations in the file still make sense to me.
Please provide reasons for the change in local meanings.

import re


def extract_args():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Type hints and proper method / script documentation has to be added to the whole controller.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please address this in the SPIKE issue as one of the goals.

run_script('convert_features_to_pages.py', env_vars)


if __name__ == '__main__':
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is different pattern, than we usually have in our scripts, where we don't initialize main method. I would refactor the code so the scripts are consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please address this in the SPIKE issue as one of the goals.
This version aimed to provide a migrated solution that worked well enough to close previous projects.
No deep analysis was included, as this step prevented us from developing the final project.


if __name__ == '__main__':
print("Starting Living Documentation generation.")
main()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This PR is seriously very big, almost no one will be able to review it fully in detail within reasonable amount of time. Better would be to create a few smaller ones. In your case, in particular, you could add one script at a time. One PR for clean_env_before_mining.py and related functionality, another for github_query_issues.py etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This version aimed to provide a migrated solution that worked well enough to close previous projects.
The Python scripts are the goal of that migration. We are working on collecting refactoring notes in parallel.

  • in a previous project
  • in a local project in SPIKE issue

Yes, it is big, but the script is the same. Only the main method and env variables loading differ.
All scripts need to be refactored. Adding a format check and using OOP will be the first steps; then, more reviews should follow.

env.update(env_vars)

# Running the script with updated environment
result = subprocess.run(['python3', script_name], env=env, text=True, capture_output=True, check=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

calling Python from Python using subprocess is definitely not that common. Why not to call it directly? If env vars are the only reason, you can encapsulate them into a data class (I proposed something like that already in: #4 (comment)) and pass to each main function of each module, just an example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See the solution proposal linked on following review comment.


# Clean environment before mining
print("Data mining for Living Documentation")
run_script('clean_env_before_mining.py', env_vars)
Copy link
Collaborator

Choose a reason for hiding this comment

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

hardcoding python script name like this is definitely weird. I'd just import and call it directly as a standard Python call

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have prepared a solution proposal for the clean script - see commit 56c6fc9.
@MobiTikula, Can you address the refactoring of the rest of the scripts in SPIKE?

# Set to store the names of repositories that have been used
set_of_used_repos = set()

if os.path.isdir(PROJECT_DIRECTORY):
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function is quite nested and I feel like almost a bit too long. Consider simplifying it and perhaps even break it down into multiple functions.

Btw, I like this approach to 'flatten' the code a bit - instead of:

if something:
   do_something_complex_and_nested

to:

if not something:
   return

do_something_complex_and_nested

by following this second approach, your do_something_complex_and_nested code block is not nested any more :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is cool: https://peps.python.org/pep-0020/

Flat is better than nested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As this was overtaken by migration, let's make this a note to refactor SPIKE @MobiTikula .

@miroslavpojer miroslavpojer merged commit c8121fb into master May 21, 2024
3 checks passed
@miroslavpojer miroslavpojer deleted the feature/1-Initial-repository-setup branch May 21, 2024 10:13
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.

Initial repository setup
4 participants