
Phoenix CI Toolkit CPP
Phoenix CI toolkit CPP is a gitlab's CI/CD component catalog implementing CI and CD operations shared by most phoenix2 repositories implemented in C++, while managing their environments with pixi
The catalog includes CI components to - run tests, generating test reports in junit format - run test with coverage, generating coverage reports - full pipeline component combining the above, plus components from PhoenixCIToolkit in a standard pipeline for phoenix2 C++ projects.
The catalog's components can usually be configured to run in specific docker images. The workflow component however imposes the docker images to come from the phoenixcontainer registry
Table of content:
[[TOC]]
Repository content
The components are tested in the CI pipeline of this repository, which is therefore structured as a standard c++ phoenix project. The project rely on pixi to manage environments and dependencies, and on pixi tasks to standardize usual development operations.
🏛️ Repository structure:
📁 doc
|─── 📁 doxygen ──► Doxygen sources and CMakeLists.txt for code documentation
|─── 📁 mkdocs ──► mkdocs configuration and sources for user documentation
📁 src
|─── 📄 CMakeLists.txt ──► Define src targets
|─── 📄 main.cpp ──► Dummy hello world source used for testing buildcomponents
📁 TESTS
|─── 📄 CMakeLists.txt ──► Define test targets
|─── 📄 test_hello.cpp ──► Dummy test used for testing the test components
📁 templates
|─── 📄 phoenix-workflow-cpp.yml ──► "Meta" component that combines all others in a complete pipeline suited to most phoenix2 projects
|─── 📄 pixi-coverage-cpp.yml ──► Component to generate tests coverage report
|─── 📄 pixi-test-cpp.yml ──► Component to run tests
📄 .gitlab-ci.yml ──► CI/CD testing the components
📄 CMakeLists.txt ──► CMakeLists of this "project", used for testing the components
📄 LICENSE ──► CeCILL-C license
📄 pixi.lock ──► Lock file of the dependencies
📄 pixi.toml ──► Contains the information about pixi's environment, tasks and dependencies
📄 README.md ──► This README
Components
Component pixi-coverage-cpp
The pixi-coverage-cpp component calls pixi run --frozen $[[ inputs.pixi-task ]], calling a "coverage" task defined in the pixi manifest. The task is passed arguments to define the output reports: "coverage_dir", "html_report", "cobertura_report", "sonarqube_report", "txt_report".
Example
- component: $CI_SERVER_FQDN/CTA-LAPP/PHOENIX_LIBS2/citoolkit/phoenixcitoolkitcpp/pixi-coverage-cpp@0.1.0
inputs:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE != "merge_request_event"
needs:
- job: ReplacePkgVersion
cobertura-report: cobertura_report.xml
html-report: coverage_report.html
coverage-dir: $COVERAGE_DIR
job-name-prefix: myproject
job-image: gitlab-registry.in2p3.fr/cta-lapp/phoenix_libs2/citoolkit/phoenixcontainer/pixi:0.3.0
pixi-task: coverage
sonarqube-report: coverage_sonarqube_report.xml
txt-report: test_report.txt
tags: ["runner_tag"]
Inputs
| Name | Type | Default Value | Description |
|---|---|---|---|
| artifacts-expire-in | string | "8d" | Expiration time for the coverage artifacts |
| cobertura-report | string | Filename, relative to coverage-dir, to use to write the coverage report in cobertura (xml) format. | |
| coverage-dir | string | Directory where the coverage report is located | |
| html-report | string | Filename, relative to coverage-dir, to use to write the coverage report in html format | |
| job-image | string | Gitlab "image" section of a CI/CD job definition, defining the image the job will run in | |
| job-name-prefix | string | Job Name prefix, can be used to differentiate several inclusion of this component in a pipeline. Final job name will be job-name-prefix-coverage | |
| needs | array | [] | Gitlab needs array with the jobs that must run before the buildkit job (also controls artifacts available in buildkit job) |
| pixi-task | string | Name of the pixi task running the coverage. Will be used as pixi run --frozen $[[ inputs.pixi-task ]] args | |
| rules | array | Gitlab rules to trigger the buildkit job | |
| sonarqube-report | string | Filename, relative to coverage-dir, to use to write the coverage report in sonarqube (xml) format | |
| tags | array | [] | Tag list for the buildkit job (to control which runner is used) |
| txt-report | string | Filename, relative to coverage-dir, to use to write the coverage report in text format |
Component pixi-test-cpp
The pixi-test-cpp component calls pixi run --frozen $[[ inputs.pixi-task ]]$, calling the "test" task defined in the pixi manifest.
Example
- component: $CI_SERVER_FQDN/CTA-LAPP/PHOENIX_LIBS2/citoolkit/phoenixcitoolkitcpp/pixi-test-cpp@0.1.0
inputs:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE != "merge_request_event"
job-image: gitlab-registry.in2p3.fr/cta-lapp/phoenix_libs2/citoolkit/phoenixcontainer/pixi:0.3.0
job-name-prefix: myproject
junit-report: test_report.xml
pixi-task: test
tags: ["runner_tag"]
Inputs
| Name | Type | Default Value | Description |
|---|---|---|---|
| artifacts-expire-in | string | "8d" | Expiration time for the coverage artifacts |
| job-image | string | Gitlab "image" section of a CI/CD job definition, defining the image the job will run in. | |
| job-name-prefix | string | Job Name prefix, can be used to differentiate several inclusion of this component in a pipeline. Final job name will be job-name-prefix-test | |
| junit-report | string | Filename to write the test report in junit format, relative to the current directory | |
| needs | array | [] | Gitlab needs array with the jobs that must run before the buildkit job (also controls artifacts available in buildkit job) |
| pixi-task | string | Name of the pixi task running the tests. Will be used as "pixi run --frozen $[[ inputs.pixi-task ]]" | |
| rules | array | Gitlab rules to trigger the buildkit job | |
| tags | array | [] | Tag list for the buildkit job (to control which runner is used) |
Component phoenix-workflow-cpp
The phoenix-workflow-cpp component implements a complete pipeline for standard phoenix2 library c++ projects, by using the other components defined in this repository. The pipeline will:
- determine the version of the package to produce - either the branch's name if on a branch, or the tag value if on a tag - and replace it in the relevant files
- build the project package
- run the test
- run the test with coverage
- generate the documentation
- upload the package to a conda channel
- publish the documentation
- publish a release if there are relevant changes
Example
- component: $CI_SERVER_FQDN/CTA-LAPP/PHOENIX_LIBS2/citoolkit/phoenixcitoolkitcpp/phoenix-workflow-cpp@$0.1.0
inputs:
pixi-task-coverage: coverage
pixi-task-documentation: doc
pixi-task-test: test
package-name: mypackage
tags: ["runner_tag"]
upload-channel-dev: phoenix-dev
upload-channel-stable: phoenix
Inputs
| Name | Type | Default Value | Description |
|---|---|---|---|
| pixi-task-coverage | string | Pixi tasks that run test coverage and creates reports. Forwarded to the "pixi-run-coverage" component | |
| pixi-task-documentation | string | Pixi task that generates the documentation. Forwarded to the "pixi-run-doc" component | |
| pixi-task-test | string | Pixi task that runs the test and generates junit test report. Forwarded to the "pixi-test-cpp" component | |
| package-name | string | Name of the project package, as written in the pixi.toml | |
| tags | array | [] | Tag list of the job (to select runner) |
| upload-channel-dev | string | phoenix-dev | Channel at the Host where the "dev" package will be uploaded, for instance "phoenix-dev". Dev packages are the packages build for commits that do not correspond to a tag or release. |
| upload-channel-stable | string | phoenix | Channel at the Host where the "stable" package will be uploaded, for instance "phoenix". Stable packages are the packages build for tags or release. |