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
Add support of user under allow_to_push and allowed_to_merge in protect branches method #273
Conversation
Hi @gdubicki @Pigueiras @barryib, this pull request aims to deal with
The extra parameter
To update the configuration, we can now use the gitlab api https://docs.gitlab.com/ee/api/protected_branches.html#example-with-user--group-level-access. The post data look like this:
and respect the excepted payload according to the documentation. How do I deal with the configuration to be sure to update only if there is change to make? First when I read the exiting config of the branch from gitlab api in the
Second, when I read the requested configuration (config.yml), i split it to have 4 arrays too :
Then, we compare them to see if there is change before applying the new configuration |
The approach you have taken looks good to me, @florentio . 😊 |
Please make the existing acceptance tests pass again and add new ones if needed for the coverage to not decrease, @florentio. PS Don't worry about the codecov reporting a total drop of the coverage just after you push new commits. Its report gets updated as the acceptance tests finish, which takes a few minutes. :) |
Codecov Report
@@ Coverage Diff @@
## main #273 +/- ##
===========================================
- Coverage 73.36% 19.45% -53.92%
===========================================
Files 57 57
Lines 2099 2138 +39
===========================================
- Hits 1540 416 -1124
- Misses 559 1722 +1163
Continue to review full report at Codecov.
|
Hi, Ok I will start working on acceptance tests |
@gdubicki It sounds like your Test workflow has been manually disabled. Was it desired ? |
Yes, @barryib . We have moved to running tests under this workflow: https://github.com/egnyte/gitlabform/actions/workflows/linter-and-tests.yml I am not sure why the tests are not running in the PRs now. :( |
Looks like the way to run the tests now is for me to get a branch from your fork and push it to egnyte/gitlabform.. :/ |
A few tests are flaky, but all of them are passing now. 🎊 We still need to increase the test coverage though as it has dropped a bit. |
Hi @gdubicki . I'm working on the acceptance for the feature. At the end, it should resolve codecov issue.
|
For now please share the result of such test that you have run locally as a screenshot and add the test commented out. I will deal with automating running those tests with GitHub Actions shortly.
Sure! To create protected branches you can use a fixture like this one http://github.com/egnyte/gitlabform/blob/7151d65d51ad8b9e97954db9aaa7a158b1b24d3c/tests/acceptance/test_branches.py#L10-L37 , that you use by adding a parameter to your test method with the name matching the fixture function name, f.e. here http://github.com/egnyte/gitlabform/blob/7151d65d51ad8b9e97954db9aaa7a158b1b24d3c/tests/acceptance/test_branches.py#L53-L53 . Similar thing done for the users is here: http://github.com/egnyte/gitlabform/blob/7151d65d51ad8b9e97954db9aaa7a158b1b24d3c/tests/acceptance/test_members.py#L9-L28 and then http://github.com/egnyte/gitlabform/blob/7151d65d51ad8b9e97954db9aaa7a158b1b24d3c/tests/acceptance/test_members.py#L53-L53 . |
Hi @gdubicki , bellow a full dump of my test output,
|
Hi - not sure if I've missed it. Based on the description I think only users can be specified, but not a group. Is that correct? |
Hi - not sure if I've missed it. Based on the description I think only
users can be specified, but not a group. Is that correct?
In this PR as of now - yes.
|
…ct branches method
I have (re)added a way to run the tests using GitLab Premium in a Docker container and made it possible in GitHub Actions. Note: in GitHub Actions this will only work in this repo, NOT in its forks. This is GitHub Actions' secrets' limitation/security feature. We'll see how it goes. But you can see that the tests for the new feature are passing when I pushed the commit to egnyte/gitlabform, here: https://github.com/egnyte/gitlabform/runs/3641552180?check_suite_focus=true#step:5:1581 Thank you for your contribution @florentio and @barryib ! Merging and releasing a new version with this feature in a moment. |
Thank to @florentio and to you @gdubicki.
This is the normal behavior and is what you want. The licence must remain secret in this repo only. |
Continuation of #232