Last Updated: February 25, 2016
·
788
· excaliburzero

Automatically testing a Ren'Py game using Travis CI

If you have a Ren'Py game that you want to test with the Lint script given in the Ren'Py launcher and test building it but don't want to have to do so manually then you may want to read this tip.

Note that the following implementation of this system works with the game's source code being hosted on Github and using Travis CI, but you may be able to find other ways to implement this system.

First you are going to want to enable Travis CI for the repository of the game. This can be done by going to Travis CI and logging in with your Github account, then going to your profile page and selecting the grey box next to the repository for the game so that it becomes green with a check-mark in it.

Next you are going to want to make a ".travis.yml" file for the repository. The one I used for a game I was working on (Ganbatte) is below:

language: python
python:
  - "2.7"
# command to install dependencies
install:
  - cd ..
  - wget http://www.renpy.org/dl/6.99.1/renpy-6.99.1-sdk.tar.bz2
  - tar xf renpy-6.99.1-sdk.tar.bz2
  - rm renpy-6.99.1-sdk.tar.bz2
  - mv renpy-6.99.1-sdk renpy
  - cd renpy
# command to run tests
script: ./renpy.sh "../ganbatte/" lint && ./renpy.sh launcher distribute "../ganbatte/"

The script that I used should be able to be easily adapted for your game. But you should replace all instances of "ganbatte" with the name of your repository. For instance if your repository was "user123/funvisualnovel", then you would change all instances of "ganbatte" to "funvisualnovel".

I will now go over what the different parts of the script do.

language: python
python:
  - "2.7"

This section of the script lets Travis CI know to use Python 2.7 when testing code fo the game. This section is not necessarily needed, but may come in handy if you want to run anything related to Ren'Py using Python.

Note that if you do not include a language declaration like this one, Travis CI will default to Ruby as the language it loads by default.

install:
  - cd ..
  - wget http://www.renpy.org/dl/6.99.1/renpy-6.99.1-sdk.tar.bz2
  - tar xf renpy-6.99.1-sdk.tar.bz2
  - rm renpy-6.99.1-sdk.tar.bz2
  - mv renpy-6.99.1-sdk renpy
  - cd renpy

This section of the code tells Travis CI to install Ren'Py. This specific implementation of the script has Travis CI install Ren'Py 6.99.1 . You can change the version of Ren'Py that it installs by changing the download link in the "wget" statement and the names of the "renpy-6.99.1-sdk" and "renpy-6.99.1-sdk.tar.bz2" folders to match the appropriate names of the corresponding folders in the version of Ren'Py that you want to use.

script: ./renpy.sh "../ganbatte/" lint && ./renpy.sh launcher distribute "../ganbatte/"

This section of the code is what actually tests the game. First it runs the game through Lint via the Ren'Py Launcher "./renpy.sh". Then if it passes through the Lint script it attempts to build the game.

Note that it is in this section of the code that you will need to change all instances of "ganbatte" to the name fo the game you are testing.

Once you have the ".travis.yml" file setup, and Travis CI enabled for the game's repository the system should now be working. Now whenever you push changes to your Github repository, or when someone makes a pull request, the repository or pull request respectively will be run through the Lint script and will be test built by Travis CI.

For more information on working with Ren'Py in a setting similar to this, you may want to check out Tumblr user dlksk's guide on getting Ren'Py to run on the Raspberry PI. Even if you aren't working with Raspberry PI it is a helpful guide. I used it to help put together the ".travis.yml" file above.

If you need to find more information on using Travis CI, then you may want to check out the Travis CI Documentation.