Our dev team is continuously working on migrating more and more of our backend code base from Java to Kotlin (it has great benefits!). In order to track our progress, we wanted to have some easy way of tracking how much Java code is left in our code base and how we are doing in our planned migration to 100% Kotlin.

Adding this to our concourse pipeline for all builds on the development branch was quick and easy. First, we figured out that we wanted to use cloc for source code counting. Cloc uses perl, so we throw the cloc perl script in our repo and run this in a concourse task executing in docker library’s official perl container. Note that we use git ls-files to ensure that we only count source code files tracked by git. This prevents counting e.g. Javascript files from node_modules folders etc.

platform: linux

  type: docker-image
    repository: perl
    tag: "5.22.4-threaded"

- name: repo

  path: sh
  dir: repo/
  - -ec
  - |
    ci/scripts/cloc.pl $(git ls-files)

Second, we added another job to our concourse pipeline to run the stats.yml task. Again, that’s just a few lines added to our pipeline.yml:

- name: "stats [develop]"
  - get: repo
    <<: *repo-develop
  - task: stats
    file: repo/ci/stats.yml
    timeout: 2m

That’s it. Thank’s to Concourse’s high degree of flexibility we were able to add source code statistics to our CI/CD pipeline in less than 15 minutes. Let’s see how we’re doing:

Counting our Java and Kotlin lines together, it looks like we’re at roughly 25% Kotlin already. Some way to go, but now that we track this number it should go up significantly in the next sprints 🙂

Leave a comment

Your email address will not be published. Required fields are marked *