Trigger repo build on other repo update?

I have 3 github repos:

  • core, a rails codebase with some unit tests
  • web, a frontend js codebase with some unit tests
  • testing, a repo containing only selenium tests.

I already have core and web building on circle - whenever a branch is pushed to one of those repos, that repo runs its unit tests on circle.

What I want to do is: whenever either core or web repos get a branch pushed to them, the testing repo gets built on circle.

Is there any simple way to do this? Off the top of my head the best I can come up with is having the core and web build configs each have, as their last step, a command to call circle’s api to trigger a build on testing. Alternately, maybe I could use github’s webhooks to trigger that build directly. Ideally, though, there’s some way in circle to say “run this repo’s build whenever these other repos build” that I just haven’t found yet.

Any ideas?

2 Likes

Your initial idea is how you’d do it, if you’re testing that repo all on its own. Otherwise you could git clone the testing repo during a build for the other two.

If you do the latter, you’ll need to setup a checkout key in order to access the testing repo (assuming it’s private).

For anyone else coming across this blog post, that’s the way I went: the last job in the workflow in both web and core trigger the testing repo’s test by api. So, the config for core looks like:

version: 2
jobs:
  local_test:
    ...
  fullstack_test:
    docker:
      - image: ubuntu
    steps:
      - run:
          name: Install curl
          command: apt-get update && apt-get install -y curl
      - run:
          name: "Trigger full-stack test"
          command: "curl -u ${CIRCLE_API_KEY}: -d build_parameters[CIRCLE_JOB]=start_workflows https://circleci.com/api/v1.1/project/github/<company>/testing/tree/master"
workflows:
  version: 2
  local_and_fullstack_tests:
    jobs:
      - local_test
      - fullstack_test:
          filters:
            branches:
              only:
                - master

(You could definitely ditch the curl install step by using one of circle’s provided base docker images)

Note that circle doesn’t currently support kicking off workflows via api. So, if you want testing to trigger a workflow, not just a job, you have to get creative. In our case we ended up creating a job in the testing repo called start_workflows that makes a fake empty commit on the testing repo to trigger the workflow. Very much looking forward to removing that bit of hackery. >,<

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.