Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure Travis-CI to use the correct time zone for a rails app?

In my application.rb, I have

config.time_zone = "Pacific Time (US & Canada)"

And this works correctly in development/test, and production servers. However when I push to Travis-CI, it appears to be localized to UTC for example the output of I18n.l Time.now.

Is there something different about the Travis-CI ruby/rails environment?

like image 967
aceofspades Avatar asked Apr 29 '14 17:04

aceofspades


People also ask

Which of the following file is used to configure the Travis CI?

Configuration. Travis CI is configured by adding a file named . travis. yml , which is a YAML format text file, to the root directory of the repository.

Which of the following networking tools are supported by Travis CI?

JVM (Clojure, Groovy, Java, Scala) VM images #


2 Answers

This worked for me:

before_install:
- export TZ=Australia/Canberra

to check that is correct you can output the date with this:

- date
like image 143
aruizca Avatar answered Nov 01 '22 23:11

aruizca


The way I accomplish setting the timezone is in the before_script section of the travis.yml

They give you root access to the VM running your project, so you can simply set the OS timezone that ruby uses:

    before_script:
      - echo 'Canada/Pacific' | sudo tee /etc/timezone
      - sudo dpkg-reconfigure --frontend noninteractive tzdata

If you wish, you can also force an update by adding this below:

      - sudo ntpdate ntp.ubuntu.com
like image 26
comjf Avatar answered Nov 01 '22 23:11

comjf