I am currently seeking a solution to run sanity tests on my GitLab repos architecture. There are more than 20 repos in a GitLab group.

My idea is to create a "Health Check Repo" (HCR) that would do several health checks on all these repos. For example:

  • verify that for all the branches whose names respect "branch_v[num_v_maj].[num_v_min].X", the last commit on this branch is associated to a tag with a name respecting "v[num_v_maj].[num_v_min].[num_v_patch]"
  • verify all the tags follow a proper format.
  • ...

The list will grow to include checks less "git-oriented": check the presence of a README.md, check if users have correct rights, ...

By running these checks, the idea is to avoid the repos to get dirty over time.

For now, I can think of 2 different ways to do this:

  1. Deploy HCR on a server and for each check, run a script via a cron.
  2. Use the CI we use in my company (GitLab CI) inside the HCR program and run the CI on a regular basis. This CI would retrieve the code from other repos from its group and run the scripts on them. The CI would be scheduled to run every X.

What is the best way to do this? Is there a better way I have not mentioned?

There are hooks to avoid pushing wrong tags etc., but not everything can be checked with hooks.

I could also create a CI per repo (ie >20 CIs), but on every change, it would quite painful to update. We already have a CI per repo, running unit tests, documentation builds, but these don't change that often.

  • 1
    Why would the CI need to be scheduled to run every X? Can you not just run these checks on one commit at a time, triggered by any push to each repository?
    – bdsl
    Commented Dec 21, 2022 at 15:48
  • Sure, it could. I would have to check that the problems are solved very quickly otherwise, I would have a LOT of error emails from GitLab (one for every commit on any repo as long as the problem making the script fail is not solved). My question is more about the location of the "run of the script". Is it better practice to have it run on a server independently of GitLab CI or is it OK to make a CI run these scripts. I am thinking that CIs are generally made to check the repo they run in, not an entire group of repo (?).
    – vvvvv
    Commented Dec 21, 2022 at 15:53
  • 1
    I mean only have the script run once each time a commit is pushed to the repo. Standard sort of build server config. That should only send you emails when people are actively working and either breaking stuff or changing broken stuff without fixing it.
    – bdsl
    Commented Dec 21, 2022 at 15:57
  • Thank you for your comment ^^. It made me realize I was not clear enough I think. I updated the question. I have a fleet of more than 20 repos, each with their own CI. But I don't want to modify the CI every time I want to add a "trivial" change. I am thinking of creating a new repo (HCR in the question) that would parse all the repos for a list of checks. Should I run the checks inside the CI of HCR or deployed on a server. Or should I really just stick to updating >20 CIs when a new check has to be made on the fleet of repos?
    – vvvvv
    Commented Dec 21, 2022 at 16:08
  • This sounds like storing release version information in git, which I would strongly recommend avoiding (i.e. don't use branches or commits to represent or store version numbers). Instead consider using an artefact registry and publishing version numbers as part of a separate release process much later down the line. At best all you should ever need is a git tag to link a published release version. This way there shouldn't be any need for such checks. Commented Dec 23, 2022 at 8:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.