Upload Test Artifacts From Travis-CI to Amazon AWS S3

Joe • August 6, 2015

laravel testing aws devops s3 testing

I've spent a lot of time the past few days trying to get test artifacts to upload to Amazon's AWS S3.

I've also spent a lot of time correcting typos from "artifcats" to "artifacts". I'm not sure what an "artifcat" is, but I know what a test artifact is.

A test artifact is some file that is created during a test. In my specific case it's the _output folder from my Codeception acceptance tests. These files are HTML output and screenshots of the failure state of the test. Useful for debugging. When using Travis-CI for automated testing you Don't have access to these files (artifacts) like you would when you run your tests on your local development environment.

So how do you access test artifacts from Travis-CI? Google (and travis-ci) will tell you quickly that you can upload them to an S3 bucket. I never took to the time to try this because until recently I had never used any AWS product and felt lost anytime I tried to do anything with it. After spending a few days building stuff in AWS for the day job I felt a lot better about it and gave it a shot.

I followed the instructions and kept running into errors. Everything from lint errors caused by my .travis.yml file to random S3 errors that were vaguely suggesting I was posting to the wrong endpoint.

I did a lot of Googling around and kept running into nothing that seemed to help. Everything I found made it appear that the docs on Travis' own site were just...wrong.

After a frustrating tweet, I ran across the first glimmer of hope: "s3_region". NOTHING in the TFM mentions REGION!

This is what that relavant part of my .travis.yml file looks like now:

addons:
  artifacts:
    debug: true
    paths:
      - ./tests/_output
    target_paths: $TRAVIS_BUILD_NUMBER
    working_dir: WORKING_DIR
    bucket: simplelance
    s3_region: us-west-1

And now the test artifacts are showing up in my S3 bucket:

Screenshot 2015-08-06 15.49.45

Thanks for reading, hopefully this will save some poor soul the torture I went through to figure this out. I'm off to view my test output now.