orta / cocoapods-keys

A key value store for storing per-developer environment and application keys
MIT License
1.55k stars 92 forks source link

Can't give travis machine keychain access #166

Open loudmouth opened 7 years ago

loudmouth commented 7 years ago

When running my tests on travis, after setting my key with cocoapods keys and running bundle exec pod install, for some reason the header files for my Keys are not found during compilation.

My best guess as to why this is happening is that I am unable to give Ruby keychain access—the reason that I have made this assumption is that with a freshly installed Ruby, my own machine gives me a UI prompt to give access when running bundle exec pod install

Is there something I am missing here in my use of cocoapods-keys? Or do I need to investigate scripting the enabling of keychain access?

marcelofabri commented 7 years ago

Maybe you should use ENV vars on CI so you don't actually need the keychain?

From README:

It's rarely a good idea to mess around with the keychain in your CI, so keys will look for an environment var with the same string before looking in the keychain. Also you could create a .env file in your project folder.

loudmouth commented 7 years ago

Hey @marcelofabri, thanks for the quick reply.

I of course did have environment variables encrypted in travis, but they did not have the same name as the key. One thing that I'm unclear on from this snippet of the README, which I had originally missed, is do I need to call pod keys set ... ... in the case that an environment variable with the same name exists?

marcelofabri commented 7 years ago

I don't this it's needed - see the circle.yml from Artsy

loudmouth commented 7 years ago

I have successfully witnessed cocoapods-key use a local environment variable on my own machine instead of using a key in the keychain. To test this, I deleted the Pods/ directory, deleted the relevant keychain key, and ran pod install. This correctly generated a working header file with the relevant key.

However, despite the fact that I have now encrypted my variable in travis with the same variable name as the key name, these header files are still missing during compilation in Travis. I'm not quite sure how to proceed at this point. The logs for the branch I am testing are here specifically for the job in the build with CONTENFUL_SDK='CMA'

loudmouth commented 7 years ago

@marcelofabri I don't fully understand the circle.yml file as I have never used circle before. What does from_admin indicate in this case?

loudmouth commented 7 years ago

I found out the reason for my missing header files:

While debugging, I frequently cleared key(s) from my machine with bundle exec pod keys rm $KeyName; then deintegrated, cleaned, and reinstalled pods to try to mimic a fresh travis environment. I finally tried doing everything with a truly fresh environment on another computer. I soon found out that the header files generated by cocoapods-keys had different names on the two different machines. After reading issue #151 (also about inconsistent header names) I tracked down the yml file(s) that lived in the ~/.cocoapods/keys directory. Once I deleted the yml file(s), then reinstalled, the header files were given consistent naming. My headers are now found by the travis machines.

I would have expected rm keys to clear the associated yml file but instead I observed:

$ bundle exec pod keys rm KeyName
[!] Removed value for ManagementAPIAccessToken, and deleted associated key in Keychain.
$ ls ~/.cocoapods/keys/
14440bd08baddf719269311b94ff03cc.yml

Is this the expected behavior of keys rm?

orta commented 7 years ago

I don't think anyone really thought of deleting the yml file once all keys were removed, welcome to have that added 👍

pavankatariaog commented 5 years ago

Hi, has the removal of the yml file been added since?

orta commented 5 years ago

Nope, you're welcome to take a look