Run CI/CD jobs locally

It can be very annoying to push your code only to learn that you broke the CI pipeline. This can be circumvented if you run the respective jobs locally before pushing. With the node package gitlab-ci-local you can run gitlab pipelines locally as shell executor or docker executor. There are installation instructions available for Linux (debian), NPM, MacOS and Windows.

To view all available jobs use the gitlab-ci-local –list command:

 gitlab-ci-local --list
parsing and downloads finished in 311 ms.
json schema validated in 77 ms
name                                  description  stage               when        allow_failure  needs
detect-version                                     management_prepare  on_success  false          []
pmd-apex-sast                                      test                on_success  true
check-cross-operator-imports                       test                on_success  false          []
lint-python                                        test                on_success  false          []
lint-text                                          test                on_success  false          []
lint-yaml-jinja                                    test                on_success  false          []
lint-cue                                           test                on_success  false          []
typecheck-python                                   test                on_success  false          []
unittest                                           test                on_success  false          []
check-structure                                    test                on_success  true           []
build-operator-image: [amd64]                      build               on_success  false          [check-cross-operator-imports,lint-python,lint-text,detect-version]
build-operator-image: [arm64]                      build               on_success  false          [check-cross-operator-imports,lint-python,lint-text,detect-version]
build-helm-charts                                  build               on_success  false          [detect-version]
build-docs-check                                   build               on_success  false          []
manifest                                           manifest            on_success  false
integrationtest-zed                                integrationtest     on_success  false
publish-docker-image                               management          on_success  false
publish-helm-charts                                management          on_success  false
tag-release                                        management          on_success  false

To run the build-docs-check job execute gitlab-ci-local --job build-docs-check. This will build the docs and mount the artifact to your current working directory. See the docs for more info. You might see an error message like this:

 gitlab-ci-local --job build-docs-check
parsing and downloads finished in 657 ms.
json schema validated in 79 ms
build-docs-check starting gitlab.com:443/yaook/dependency_proxy/containers/python:3.11 (build)
Please authenticate to the Dependency Proxy (gitlab.com:443) https://docs.gitlab.com/ee/user/packages/dependency_proxy/#authenticate-with-the-dependency-proxy

You have to authenticate against Gitlab (see also GitLab Docs in order to pull images from the dependency proxy. Please consider, that you have to be in the Yaook group with at least role Guest.

echo "<PERSONAL-ACCESS-TOKEN>" | docker login gitlab.com:443 -u <username> --password-stdin

Useful command

# run all jobs of stage 'test'
gitlab-ci-local --stage test

# run single job 'build-docs-check'
gitlab-ci-local --job build-docs-check

# list jobs
gitlab-ci-local --list