Skip to content

ci: add a unit test for the trace command

Administrator requested to merge devx/test-trace-command into main

Created by: jhchabran

Having recently broken the trace command script that wraps every test command in the pipeline generator, the necessity to make sure this script is working has become very obvious.

This PR adds:

  • a very basic test runner for such scripts
    • I have considered looking at https://github.com/sstephenson/bats but it's not maintained anymore and incorporating it properly in our repository felt a bit heavy-handed for now.
  • a testing step for those scripts that will list every .sh in ./enterprise/dev/ci/scripts/ and will run them on every PR.
    • Due to the nature of those scripts and how they impact every command we're running, as well as their very low duration, it seems logical to have them being run on every change.
  • a fake buildevents replacement to solely test the script itself and not have any side effects.

Example outputs:

Failed pipeline generation if we can't list those tests:

~/work/sourcegraph US devx/test-trace-command $ go run ./enterprise/dev/ci/gen-pipeline.go
2022/01/25 11:24:22 Failed to list CI scripts tests scripts: open ./enterprise/dev/ci/scripts/testsf: no such file or directory
exit status 1

Failed test:

image

Merge request reports

Loading