How to make package and set up Travis for Julia 1.0

How to make package and set up Travis for Julia 1.0

Cover


Travis-CI provides free build check for public project, it’s perfect for individual to put a little nice build badge on README.md inside the repository. It also has a paid plan for larger collaboration that needs to run build check for every pull requests and different branches where they will run several builds in parallel. (Also this is because larger project such as Julialang itself, can also take more than 4 hours to even build once).

But smaller, personal projects usually take less than an hour to build thus takes no cost.
How to make package and set up Travis for Julia 1.0

A very basic Julia package should have the following structure:

.
├── LICENSE
├── Manifest.toml
├── Project.toml
├── README.md
├── REQUIRE
├── src
│   └── scryfall.jl
└── test
    └── runtests.jl

Source code in src directory should have something structure as:

module <pkg_name>
using <dependent_pkg>

export foo

function foo
#do something
end

end #end of module

Where the Manifest.toml and Project.toml should be auto generated by

(v1.0) Pkg> generate <pakcage_name>

Afterwards, cd into the directory, and then issue

(v1.0) Pkg> activate .

to activate the package. After this, anything you add as a dependent with add <pkg_name> will be automatically updated into Project.toml.


Once you’be done making the package, it’s time to deploy Travis-CI, for the purpose julia, you will need a .travis.toml file in the base directory of github repo that looks like this:

language: julia
os:
  - linux
julia:
  - nightly
  - 1.0

Then, in order for Travis-CI to catch tests, you will want a test folder with a runtest.jl inside, where Travis-CI will examine the results after building your packages. (Don’t forget to include Test as a julia dependent in Project.toml). In the runtests.jl , you will want to issue using <your_package> and using Test then use @test macro to test some true-false statement, if all goes well, you Travis-CI will spit out a success result.

How to make package and set up Travis for Julia 1.0