Storage is neither free or unlimited, and it’s likely artifacts from pull request builds are not automatically uploaded to some external location accessible to developers or users. In fact, when using Travis-CI to build pull requests it’s no longer feasible to upload anything to anywhere that requires authentication. Yet, since REX-Ray v0.10.0 anyone can access the same binaries created by Travis-CI, even those created during a pull request build.

Read ahead and learn how to reproduce REX-Ray.

Sprinkled throughout REX-Ray’s .travis.yml file are small sections resembling the following:

 - make create-gist
 - make create-gist

The above configuration snippet instructs Travis-CI to run the command make create-gist where a build job succeeds or fails. The Make target create-gist is a little long, but the gist of it is that specific information about a build’s results is uploaded to a GitHub Gist — a shared URL that can contain one or more text files. The create-gist target uploads the following information:

  • The result of the command uname -a, ex:
    $ uname -a
    red 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • The result of the command ls -al. This produces a list of all of the files at the root of the project directory, including the names and sizes of the REX-Ray binary.
  • Copies of the descriptor files used to upload the REX-Ray binary and its compressed versions — tgz, rpm, deb — to Bintray.
  • The MD5 checksum of the REX-Ray binary.
  • A file describing the nature of the build, including how to reproduce the REX-Ray binary locally.

That’s right, using Docker, it’s possible to create the exact same REX-Ray binary locally as the one built for a PR by a CI platform. And the word “exact” isn’t used being used hyperbolically. Exact means the binary produced locally will have the same MD5 checksum as the one created during the CI PR build.

The URL of the Gist is printed to STDOUT at the end of the create-gist target. The CI build for REX-Ray’s v0.10.1 release printed the following URL:

Opening that URL in a browser reveals a with the command that can be used to reproduce the REX-Ray binary created by the Travis-CI build:

$ docker run -it \
  -v "$(pwd)":"/tmp/rexray" \
  golang:1.8.3 \
  bash -c "git clone \
      \"/go/src/\" &&
    cd \"/go/src/\" && 
    git fetch --tags origin &&
    git checkout -b 6e8043a 6e8043ac569707b0fb3e776309769742ca09e174 &&
    XGOOS=linux XGOARCH=amd64 GOOS= GOARCH= go generate &&
    GOOS=linux GOARCH=amd64 go build -o \"rexray\" &&
    cp -f \"rexray\" \"/tmp/rexray\"" && \
  md5sum "rexray" && \
  ls -al "rexray"

Pasting the above command into the shell on a Linux host produced the following output:

Cloning into '/go/src/'...
remote: Counting objects: 28737, done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 28737 (delta 24), reused 55 (delta 17), pack-reused 28649
Receiving objects: 100% (28737/28737), 45.27 MiB | 10.58 MiB/s, done.
Resolving deltas: 100% (12352/12352), done.
Checking connectivity... done.
Switched to a new branch '6e8043a'
93d15b3f5b1f596ee1e756c46ac5bf77  rexray
-rwxr-xr-x. 1 root 96M Sep 12 11:58 rexray*

Please note the checksum in the above output: 93d15b3f5b1f596ee1e756c46ac5bf77.

Now take a look at the checksum recorded in the Gist: they’re the same value! This means that the binary produced just now, locally, is the exact. same. file produced by the CI build!

Even if wary of the value recorded in the Gist, the MD5 checksum is also emitted in the output of the CI build, and those match as well.

In conclusion, while it may not be easy to obtain the build artifacts created by PR builds, it does not mean the same file cannot be built locally. The article above shows just how simple it is — to reproduce REX-Ray.