@@ -33,7 +33,9 @@ For Ruby projects, it's as simple as adding `cache: bundler` to your .travis.yml
33
33
34
34
## How can I use it?
35
35
36
- Using our new container-based stack only requires one additional line in your .travis.yml:
36
+ If you see this on your log ` This job is running on container-based infrastructure ` it means you are already running on our container-based stack.
37
+
38
+ Otherwise, using our container-based stack only requires one additional line in your .travis.yml:
37
39
38
40
` sudo: false `
39
41
@@ -106,17 +108,53 @@ To install something from source, you can follow similar steps. Here's an exampl
106
108
install :
107
109
- wget https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
108
110
- tar -xzvf protobuf-2.4.1.tar.gz
109
- - cd protobuf-2.4.1 && ./configure --prefix=/usr && make && sudo make install
111
+ - cd protobuf-2.4.1 && ./configure --prefix=$HOME/protobuf && make && make install
110
112
111
113
These three commands can be extracted into a shell script, let's name it `install-protobuf.sh` :
112
114
113
115
# !/bin/sh
114
116
set -ex
115
117
wget https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
116
118
tar -xzvf protobuf-2.4.1.tar.gz
117
- cd protobuf-2.4.1 && ./configure --prefix=/usr && make && sudo make install
119
+ cd protobuf-2.4.1 && ./configure --prefix=$HOME/protobuf && make && make install
118
120
119
- Once it's added to the repository, you can run it from your .travis.yml :
121
+ Once it's added to the repository, you can run it from your ` .travis.yml` :
120
122
121
123
before_install :
122
124
- ./install-protobuf.sh
125
+
126
+ We can also add a `script` command to list the contect of the protobuf folder to make sure it's been installed :
127
+
128
+ script :
129
+ - ls -R $HOME/protobuf
130
+
131
+ # # How Do I Cache Dependencies and Directories?
132
+
133
+ In the example above, to avoid having to download and compile the protobuf library each time we run a build, we can cache its directory.
134
+
135
+ We add the following to our `.travis.yml` :
136
+
137
+ cache :
138
+ directories :
139
+ - $HOME/protobuf
140
+
141
+ And then change our shell script to only compile and install if the cached directory is not empty :
142
+
143
+ # !/bin/sh
144
+ set -ex
145
+ # check to see if protobuf folder is empty
146
+ if [ ! -d "$HOME/protobuf/lib" ]; then
147
+ wget https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
148
+ tar -xzvf protobuf-2.4.1.tar.gz
149
+ cd protobuf-2.4.1 && ./configure --prefix=$HOME/protobuf && make && make install
150
+ else
151
+ echo 'Using cached directory.'
152
+ fi
153
+
154
+ See [here](https://github.com/travis-ci/container-example) for a working example of compiling, installing, and caching protobuf.
155
+
156
+ More information about using caching can be found in our [Caching Directories and Dependencies](http://docs.travis-ci.com/user/caching/) doc.
157
+
158
+ # # Need Help?
159
+
160
+ Email [support](mailto :
[email protected] ) or create a GitHub issue.
0 commit comments