• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool that allows to cache Carthage/Build folder in Amazon S3.

CarthageCache

Build Status Code Climate Test Coverage Gem Version

CarthageCache allows Carthage users to have a shared cache of their Carthage/Build folder backed by Amazon S3.

Most libraries don't provide pre-compiled binaries, .framework files, in their releases. Even if they do, due to Swift lack of ABI, you might be forced to use --no-use-binaries flag and compile all your dependencies. Which, depending on the amount of dependencies and their size it could take significant time.

When you add slow building environments like Travis CI to the mix, a project bootstrap could take around 25 minutes just to build all your dependencies. Which is a lot for every push or pull request. You want your build and test to run really fast.

CarthageCache generates a hash key based on the content of your Cartfile.resolved and the current installed version of Swift. Then it checks if there is a cache archive (a zip file of your Carthage/Build directory) associated to that hash. If there is one it will download it and install it in your project avoiding the need to run carthage bootstrap.

Do you want to improve carthage_cache? Check all the issues tagged with help-wanted!. I'll be more than happy to review your pull request.

Installation

Add this line to your application's Gemfile:

gem 'carthage_cache'

And then execute:

$ bundle

Or install it yourself as:

$ gem install carthage_cache

Setup

AWS credentials

First of all you need to configure your AWS credentials. You can do this by a .carthage_cache.yml file. CarthageCache will try to find this file in the current working directory. It is recommended to generate this file in each project you want to use CarthageCache.

To generate a .carthage_cache.yml you just need to run

carthage_cache config

You can also set your credentials using the following environmental variables

Or if you prefer using AWS Named Profiles, you can use the following environmental variables instead

  • AWS_REGION
  • AWS_PROFILE

AWS S3 bucket

CarthageCache will assume there is a bucket named carthage-cache. You can change the bucket to be used by using the option -b or --bucket-name.

IAM Policy

Once you create the bucket, you will need to create a user. Go to the IAM section and create a new user. Create a new group, and add the new user to that group. Create a policy with the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "autogenerated-id",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::carthage-cache"
            ]
        },
        {
            "Sid": "autogenerated-id",
            "Effect": "Allow",
            "Action": [
                "s3:DeleteObject",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::carthage-cache/*"
            ]
        }
    ]
}

Don't forget to attach the policy to the group and make sure to replace autogenerated-id with an ID that should be unique. You can generate a new policy using AWS policy generator and replace the content with the previous snippet keeping the SID field.

Usage

If you want to bootstrap a project from cache and if there is none then fallback to Carthage.

carthage_cache install || carthage bootstrap

If you want to update dependencies and update cache

carthage update && carthage_cache publish

If you want to check whether a cache exists for the current Carfile.resolved

carthage_cache exist

If you want to publish an archive that already exists

carthage_cache publish --force

If you want to delete unused libraries from build directory for all targets

carthage_cache prune

You can also prune the build directory before publishing a new archive

carthage_cache publish --prune-build-directory

Both prune and publish accept --prune-white-list to configure frameworks that don't appear in the Cartfile.resolved and should not be pruned by associating them with a framework that does appear in Cartfile.resolved. Like CocoaLumberjackSwift:

carthage_cache publish -p -w .white-list.yml
  • -p is the short version of --prune-build-directory
  • -w is the short version of --prune-white-list

where .white-list.yml is

"CocoaLumberjackSwift": "CocoaLumberjack"

For more information run the help command

carthage_cache help

OSS project

In an OSS project you wouldn't store AWS credentials anywhere since anyone can have access, even if you have a build like travis that supports for encrypted variables but these are not available in your contributors pull requests build.

In order allow your build to run in these circumstances, you can avoid defining these variables

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_PROFILE

And carthage_cache will work in read-only mode, you wont be able to publish new items but your build will still be able to fetch the cached dependencies.

The only requirement is to make the action s3:GetObject avaible for any anonymous user in your S3 Bucket

{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Sid":"AddPerm",
      "Effect":"Allow",
      "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::examplebucket/*"]
    }
  ]
}

Please know that this will make all your dependencies PUBLIC and accessible for anyone, so if you have sensitive information or proprietary code there you should avoid this configuration.

Project's root directory

The carthage_cache command assumes that the project's root directory is the current working directory and that the Cartfile.resolved file is located in the project's root directory. All carthage_cache accept an optional argument to set the project's root directory. For example

carthage_cache install

Will try to read the Cartfile.resolved file from the current working directory and will install the cache archive in ./Carthage/Build.

carthage_cache install PATH/TO/MY/PROJECT

Will try to read the PATH/TO/MY/PROJECT/Cartfile.resolved and will install the cache archive in PATH/TO/MY/PROJECT/Carthage/Build.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/guidomb/carthage_cache/issues/new.

License

The gem is available as open source under the terms of the MIT License.

More Repositories

1

react-chat-widget

Awesome chat widget for your React App
TypeScript
1,447
star
2

wolox-ci

Groovy
198
star
3

tech-guides

Guides and standards for the techs we love using at Wolox
Shell
156
star
4

express-js-bootstrap

Kickoff for ExpressJS applications.
JavaScript
77
star
5

redux-recompose

A Redux utility belt for reducers and actions. Inspired by acdlite/recompose.
JavaScript
70
star
6

wor-authentication

Gem to add authentication to your application using JWT, with expirable, renewable and customizable tokens!
Ruby
62
star
7

async-requests

Ruby
57
star
8

ReactiveArray

An array class implemented in Swift that can be observed using ReactiveCocoa's Signals
Swift
53
star
9

dictum

Create automatic documentation of your Rails API endpoints through your tests
Ruby
53
star
10

firestore-service

JavaScript
28
star
11

ios-style-guide

Wolox's iOS style guide
26
star
12

WLXBluetoothDevice

A block-based wrapper of CoreBluetooth
Objective-C
26
star
13

frontend-bootstrap

JavaScript
24
star
14

react-bootstrap

JavaScript
23
star
15

dictum.js

Create automatic documentation of your NodeJS API endpoints
JavaScript
23
star
16

wor-paginate

Ruby
22
star
17

wolmo-bootstrap-react-native

Bootstrap generator for React Native projects
JavaScript
20
star
18

wolmo-core-ios

Wolmo - Wolox Mobile SDK core library for iOS
Swift
17
star
19

wor-push-notifications-aws

Ruby
16
star
20

wor-prof

Wor-prof (Wprof) is a gem for Ruby On Rails which its only purpose is to measure a RoR app's performance through a profile with different times of response.
Ruby
15
star
21

arg-localities

Get localities by province for Argentina
Shell
13
star
22

wor-requests

Make external requests in you service objects, with easy logging and error handling!
Ruby
12
star
23

aws-deploy-script-frontend

JavaScript
12
star
24

rails-bootstrap

A Ruby on Rails base project with Wolox standard defaults
Ruby
11
star
25

frontend-cookbook

Reusable components and features design and created by Wolox
TypeScript
11
star
26

wolmo-cookbook-android

Wolmo Cookbook - Recipes for common cases done with Wolmo
Kotlin
9
star
27

fictium

A gem with the power to generate documentation from your tests
Ruby
9
star
28

WLXWebViewReloader

An extension to WKWebView that reloads the web view when the source changes.
Objective-C
8
star
29

react-native-renavigate

React native navigation made easy using redux 💫
JavaScript
8
star
30

codestats

Self-hosted open source app to control metrics of your code
Ruby
7
star
31

terraform-base-infra

HCL
7
star
32

wolmo-core-android

Wolmo Core - Wolox Mobile SDK core module for Android
Kotlin
7
star
33

express-wolox-logger

JavaScript
6
star
34

netcore-bootstrap

Kickoff for NetCore applications using EntityFramework.
C#
6
star
35

node-typescript-bootstrap

TypeScript
6
star
36

ios-base-project

A base iOS project with all the minimum dependencies already configured.
Swift
6
star
37

project-health-checker

JavaScript
5
star
38

assigner

A script to pick a random reviewer and assign it to a pull request
Ruby
5
star
39

equalizer

CSS
5
star
40

wor-batchifier

Ruby
5
star
41

angular-bootstrap

TypeScript
4
star
42

wolmo-reactive-core-ios

Swift
4
star
43

warp

WARP - Seamless mobile assets management
Python
4
star
44

eslint-config-wolox-node

JavaScript
4
star
45

eslint-config-wolox-react

JavaScript
3
star
46

cookbook-ios

Swift
3
star
47

cypress-bootstrap

TypeScript
3
star
48

eslint-config-wolox

Wolox eslint standard
JavaScript
3
star
49

wolmo-networking-android

Wolmo Networking - Wolox Mobile SDK networking module for Android
Java
3
star
50

collection-view-example

An iOS project that shows how to use UICollectionView to make re-utilizable components. It also shows how to structure an app using the MVVM pattern.
Objective-C
2
star
51

java-bootstrap

Java
2
star
52

wolmo-testing-android

Kotlin
2
star
53

elasticsearch-rails-demo

Ruby
2
star
54

automation-test-angular

TypeScript
2
star
55

aws-lambdas-bootstrap

JavaScript
2
star
56

WoloxAndroidBootstrap

Wolox's base template for new Android projects.
Kotlin
2
star
57

android-bootstrap-mvvm

Kotlin
2
star
58

wolmo-maps-android

Wolmo Maps - Wolox Mobile SDK maps module for Android
Java
2
star
59

github-organization-manager-react

CSS
2
star
60

simple-crud

Ruby
2
star
61

fastlane-mobile

Ruby
2
star
62

wdio-appium-bootstrap

JavaScript
2
star
63

node-graphql-bootstrap

JavaScript
2
star
64

localization-culture-core

This project allows localization for NetCore using .json files instead of .resx.
C#
2
star
65

silk-paper-node

JavaScript
1
star
66

jira-training-cloner-rails

Ruby
1
star
67

java-meetup-2019

Java
1
star
68

react-app-rewire-wolox

JavaScript
1
star
69

react-conduit

Ruby
1
star
70

angularjs-bootstrap

JavaScript
1
star
71

graphql-inspector-wolox-node

JavaScript
1
star
72

eslint-config-wolox-react-native

JavaScript
1
star
73

layout

SCSS
1
star
74

github-organization-manager

project to manage github repos
JavaScript
1
star
75

infrastructure-provisioning

HTML
1
star
76

angular-conduit

TypeScript
1
star
77

wolox-frontend-templates

HTML
1
star
78

github-organization-manager-node

JavaScript
1
star
79

express-wolox-schema-validator-node

JavaScript
1
star
80

python-bootstrap

1
star