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

[match] Fixes Gitlab Secure Files API limit #21205

Closed

Conversation

pawelini1
Copy link

@pawelini1 pawelini1 commented Apr 17, 2023

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

Resolves #21204

This change fixes an issue for those people who have many different certs/provision profiles/keys stored on Gitlab in a "Secure files" section. The api used currently by Fastlane does not take into account paging and it's capable of downloading only 20 such files instead of all of them (max 100). This leads to signing issues as some files might be missing.

Description

The fix itself it's quite straightforward by adding explicit page size to 100 which is the maximum number of Secure Files you can store on Gitlab repository as stated in their documentation

Limited to 100 secure files per project. Files must be smaller than 5 MB. 

on https://docs.gitlab.com/ee/api/secure_files.html

Testing Steps

I've tested it on my Match setup that involves more than 20 files on Gitlab repository. Before the fix I was getting an error:

/Users/pszymanski/Repositories/ios-credentials/vendor/bundle/ruby/2.7.0/gems/fastlane-2.212.2/fastlane_core/lib/fastlane_core/ui/interface.rb:129:in `crash!': \e[31m[!] No code signing identity found and can not create a new one because you enabled `readonly`\e[0m (FastlaneCore::Interface::FastlaneCrash)

as one of the certificates needed was not fetched as a result of that issue. After applying this fix my script finished with no issues.

@google-cla
Copy link

google-cla bot commented Apr 17, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pawelini1 pawelini1 force-pushed the gitlab-secure-files-api-limit branch from 5d1492e to 261411a Compare April 17, 2023 10:41
@darbyfrey
Copy link
Contributor

Hi @pawelini1, thanks for creating a PR for this!

Would you mind adding a test for this change too? Something like:

it 'requests 100 files from the API' do
  stub_request(:get, /gitlab.example.com/).
    to_return(status: 200, body: [].to_json)

  files = subject.files

  assert_requested(:get, /gitlab.example.com/, query: "per_page=100")
end

@getaaron would you be able to review this change when it's ready?

@getaaron
Copy link
Collaborator

Agreed on the test, and happy to merge it once that's added. Thanks for the PR @pawelini1!

@darbyfrey
Copy link
Contributor

Hi @pawelini1,

Thanks for adding the test! I noticed the build was failing and it looks like that test should go in the match/spec/storage/gitlab/client_spec.rb file. Would you mind moving it?

@getaaron
Copy link
Collaborator

getaaron commented Jul 4, 2023

Closed via #21361

Thanks for the PR, @pawelini1, and thanks @darbyfrey for fixing up the test!

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.

[match] Gitlab Secure files API limited to 20 files by default
3 participants