Mentions légales du service

Skip to content
Snippets Groups Projects

Enh coverage

Merged Gözükan Hande requested to merge hgozukan/gitlabciworkshop:ENH_coverage into main
4 files
+ 86
26
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -2,7 +2,7 @@
@@ -2,7 +2,7 @@
## 1st version - Projection installation
## 1st version - Projection installation
Add the following `.gitlab-ci.yml` file at the git repository root in order to
- Add the following `.gitlab-ci.yml` file at the git repository root in order to
[install the projection module](../README.md#install-projection-with-pip):
[install the projection module](../README.md#install-projection-with-pip):
```yml
```yml
@@ -18,7 +18,7 @@ tests:
@@ -18,7 +18,7 @@ tests:
- echo "Projection is installed"
- echo "Projection is installed"
```
```
Add the `.gitlab-ci.yml` file, commit and push your modifications:
- Add the `.gitlab-ci.yml` file, commit and push your modifications:
```bash
```bash
git add .gitlab-ci.yml
git add .gitlab-ci.yml
@@ -26,24 +26,26 @@ git commit -m "First version - Projection installation in CI"
@@ -26,24 +26,26 @@ git commit -m "First version - Projection installation in CI"
git push
git push
```
```
Verify the CI is launched and successful:
- Verify the CI is launched and successful:
- On the left sidebar in the Gitlab interface, go to **Build****Jobs**.
- On the left sidebar in the Gitlab interface, go to **Build****Jobs**.
- Check the job is passed.
- Check the job is running.
- Click on the **Passed** icon and verify the logs.
- Click on the **Running** icon and verify the logs.
 
- See the job is passed.
## 2nd version - Projection tests
## 2nd version - Projection tests
Add the required steps in the `script` section of the `.gitlab-ci.yml` file to [run the tests](../README.md#run-the-tests).
- Add the required steps in the `script` section of the `.gitlab-ci.yml` file to [run the tests](../README.md#run-the-tests).
Add the `.gitlab-ci.yml` file, commit and push your modifications.
- Add the `.gitlab-ci.yml` file, commit and push your modifications.
Verify the CI is launched and successful.
- Verify the CI is launched and successful.
## 3rd version - Projection tests coverage report
## 3rd version - Projection tests coverage report
Modify how [the tests are run](../README.md#run-the-tests) to produce the coverage report.
- Modify how [the tests are run](../README.md#run-the-tests) to produce the
 
coverage report in `html` format.
Provide the coverage report as an artifact by adding in the `.gitlab-ci.yml` file:
- Provide the coverage report as an artifact by adding in the `.gitlab-ci.yml` file:
```yml
```yml
script:
script:
- pip install -e .
- pip install -e .
@@ -54,11 +56,11 @@ Provide the coverage report as an artifact by adding in the `.gitlab-ci.yml` fil
@@ -54,11 +56,11 @@ Provide the coverage report as an artifact by adding in the `.gitlab-ci.yml` fil
- htmlcov
- htmlcov
```
```
Verify the CI is launched and successful:
- Verify the CI is launched and successful:
- On the left sidebar in the Gitlab interface, go to **Build****Jobs**.
- On the left sidebar in the Gitlab interface, go to **Build****Jobs**.
- Check the job is passed.
- Check the job is passed.
- Click on the **Passed** icon and verify the logs.
- Click on the **Passed** icon and verify the logs.
- On the right sidebar in the Gitlab interface, browse the job artifact.
- On the right sidebar in the Gitlab interface, browse the job artifact.
## 4th version (OPTIONAL)
## 4th version (OPTIONAL)
@@ -83,6 +85,34 @@ To do so on this project:
@@ -83,6 +85,34 @@ To do so on this project:
- Badge Image URL: `https://gitlab.inria.fr/%{project_path}/badges/%{default_branch}/coverage.svg`
- Badge Image URL: `https://gitlab.inria.fr/%{project_path}/badges/%{default_branch}/coverage.svg`
- Click on the **Add badge** button.
- Click on the **Add badge** button.
 
- Modify `script` section to generate coverage report both in `html` and `xml` formats.
 
 
- Add [coverage](https://docs.gitlab.com/16.7/ee/ci/yaml/index.html#coverage)
 
section to project’s `.gitlab-ci.yml` file to provide test coverage results to
 
a merge request. Provided regex is used to find the coverage in the tool’s
 
output.
 
 
- Add [reports](https://docs.gitlab.com/ee/ci/yaml/index.html#artifactsreports)
 
section to `artifacts` and specify `coverage.xml` for coverage analysis to
 
work.
 
 
> Here we still keep `artifacts:paths` part as `reports` artifacts are not
 
downloadable from the job details page.
 
 
```yml
 
script:
 
- (...)
 
coverage: '/^TOTAL.+?(\d+\%)$/'
 
artifacts:
 
reports:
 
coverage_report:
 
coverage_format: cobertura
 
path: coverage.xml
 
paths:
 
- htmlcov
 
- coverage.xml
 
```
 
## 5th version
## 5th version
Let's introduce another useful feature of GitLab-CI: [the pipelines](https://docs.gitlab.com/ee/ci/pipelines/).
Let's introduce another useful feature of GitLab-CI: [the pipelines](https://docs.gitlab.com/ee/ci/pipelines/).
Loading