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

Fix Inheritance-Break Validation Functionality #373 #385

Merged
merged 28 commits into from
Jul 6, 2022

Conversation

ep-linden
Copy link
Contributor

No description provided.

@ep-linden ep-linden marked this pull request as draft June 9, 2022 19:08
@ep-linden
Copy link
Contributor Author

Still in the progress of reorganizing and adding test cases.

@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2022

Codecov Report

Merging #385 (1550bc2) into main (3e43e12) will decrease coverage by 0.45%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
- Coverage   80.85%   80.40%   -0.46%     
==========================================
  Files          62       62              
  Lines        2387     2388       +1     
==========================================
- Hits         1930     1920      -10     
- Misses        457      468      +11     
Impacted Files Coverage Δ
gitlabform/configuration/core.py 74.60% <100.00%> (+2.24%) ⬆️
gitlabform/configuration/groups.py 100.00% <100.00%> (+4.00%) ⬆️
gitlabform/configuration/projects_and_groups.py 100.00% <100.00%> (ø)
gitlabform/processors/single_entity_processor.py 83.87% <0.00%> (-9.68%) ⬇️
gitlabform/processors/util/branch_protector.py 64.10% <0.00%> (-9.41%) ⬇️
gitlabform/gitlab/projects.py 51.14% <0.00%> (-5.35%) ⬇️
gitlabform/gitlab/branches.py 82.25% <0.00%> (-3.23%) ⬇️
gitlabform/gitlab/core.py 92.36% <0.00%> (ø)
gitlabform/core.py 65.00% <0.00%> (+5.00%) ⬆️

@ep-linden ep-linden marked this pull request as ready for review June 13, 2022 20:40
@ep-linden
Copy link
Contributor Author

A lot of the changes were for the test cases.

The "fix" is removing the check for group configs if the common config doesn't exist just to keep it simple for now. I did add one test case to ensure nothing is broken if the flag is set in the group and the common config doesn't exist.

As mentioned previously in our Slack discussion, it will make our codebase more complicated to limit where the inheritance-break flag can be set.

Fatal will exit the program anyway
By passing in additional parameters to the validation function users can better find where they set the invalid inheritance-break flag.
Merging configs is more costly performance-wise. If we can validate early then the merging doesn't have to run.
If common config and group config doesn't exist then we can use group_and_project to capture the full section name.
The invalid tests for projects and groups are added so far.
If the parent key doesn't exist then the inheritance-break flag is set outside a setting.
Tests are nested within classes. I personally think it just looks cleaner. Removed redundant test cases and settings within fixtures.
Added two more test cases with the flag set at the group level.
…l is the highest level

Since the inheritance-break validation in groups was providing false errors, there needs to be a check to see if the merging breaks if there is nothing to inherit from.
@gdubicki
Copy link
Member

I did this rebase because I have added updates to main branch to resolve the issue of the flaky tests, @ep-linden.

@gdubicki
Copy link
Member

I took the liberty to push a minor code deduplication into your branch, @ep-linden. Please check out the changes above.

@gdubicki
Copy link
Member

I also wanted to (arguably) improve the tests a bit with tdslinden#1, but the tests don't pass after such change. Can you take a look a that please, @ep-linden? I think that the change might be worth it and that maybe we have found a real issue here.

Since group and subgroups configs will be processed through the get_effective_config_for_group function, tests were added to account for that.
Clearly stated whether the test is using get_config_for_project or get_config_for_group.
Add another test case to show the usage of breaking the inheritance from the group settings.

Modify the test cases to include group_settings
Logic is added to groups.py to validate group level config
@gdubicki gdubicki merged commit 4f94204 into gitlabform:main Jul 6, 2022
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.

None yet

3 participants