Search code examples
runit-testingyamlgitlab-citestthat

How do define certain tests on certain branches?


I am new to gitlab ci/cd. i like how it works. I would like to run certain tests in certain branches. how can i define the same in yml file?

I am using gitlab ci/cd for R package development and using testthat package for unit-testing.


Solution

  • You need to think how to structure your test suites in your branches.

    For example, you can name test-suite like /tests/branch_1/ and your branch has name branch_1, then

    test_job:
      script:
        -  test_dir("inst/tests/${CI_COMMIT_REF_NAME}"
    

    where $CI_COMMIT_REF_NAME is your branch or tag name, according to gitlab predefined variables doc, will execute the test-suite with the same name your branch name is.