Two repositories are required - how do I tell Travis?

For unit testing, I have two repositories:

  • mulib-support contains the unit test files
  • mulib contains the core source files, and is its own repo inside a subdirectory of mulib-support

When I’m manually running the unit tests, I do something along these lines:

% cd mulib-support
% git fetch && git pull
% cd mulib
% git fetch && git pull
% cd ..
% make test

How do I tell travis that it needs to fetch and pull mulib before running the tests?

addenda

I tried writing my .travis.yml as follows:

language: c
script: (cd mulib && git fetch && git pull) && (cd mulib-test/tools && make test)

but that (somewhat predictably) failed with:

$ (cd mulib && git fetch && git pull) && (cd mulib-test/tools && make test)
/home/travis/.travis/functions: line 109: cd: mulib: No such file or directory
The command "(cd mulib && git fetch && git pull) && (cd mulib-test/tools && make test)" exited with 1.

@native-api: Thanks for the link. It appears that I’ll need to get comfortable with submodules.

But you can help me with one question before I go charging down the wrong path: To facilitate usage, mulib library is minimal by design and does not contain the unit tests. Rather, I chose to do it the other way around: mulib-support contains the unit tests, and conceptually owns mulib as a submodule (although at present it’s just a subdirectory, not a submodule).

Given that: can I assume that all the instructions you gave in How to trigger a build in the test project upon a commit to dev project with Travis CI API - #2 by native-api still apply as long as I flip the meanings of test repo and dev repo?

Builds are triggered upon a commit. So to keep things simple, you want the repo whose commits you want to trigger builds to be the main repo.

Here’s how I ended up solving this (and I’m open to suggestions if it’s not stylistically appropriate):

#file: .travis.yml

language: c
script:
- git clone --depth=50 --branch=main https://github.com/you_can_guess/mulib.git mulib
- (cd mulib-test/tools && make test)

It seems to do all the right things: it grabs the latest mulib (which is very small and quick to clone) before building and running the test suite. Best of all, it finally passes! :slight_smile:

1 Like
Imprint