Skip to content

Commit 74c43fc

Browse files
committed
Update documentation and CI/CD configurations
- Revised the Contributor Code of Conduct for clarity and inclusivity. - Added new episodes (06-catservices.md, 07-final-run.md) to the curriculum, detailing CAT services and final run integration. - Updated existing episodes (03-gitlabci-setenv.md, 04-gitlabci-run-analysis.md, 05-gitlabci-vomsproxy.md) with improved instructions and examples. - Removed the outdated episode (07-building-image.md) related to container image building. - Enhanced links.md with additional references for CMS analysis and GitLab CI/CD. - Adjusted config.yaml to include new episodes in the lesson structure.
1 parent 3812f0c commit 74c43fc

9 files changed

Lines changed: 543 additions & 216 deletions

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We follow the [CERN Code of Conduct](https://hr-dep.web.cern.ch/content/code-of-
1010

1111
We commit to helping our community adhere to this code of conduct and speak up when we see possible violations of it. We strive to treat those outside of CMS as we would members of our own community. In the event that the letter or the spirit of this code has been violated, appropriate action will be taken, up to and including procedures specified in Annex A3.2 of the CMS Constitution.
1212

13-
If you want to know more about the *CMS Diversity & Inclusion Office* follow the [link](https://twiki.cern.ch/twiki/bin/view/CMSPublic/CMSDiversityOffice) and check out the [booklet](https://heyzine.com/flip-book/00f6546b1c.html).
13+
You can also learn more about the [CMS Diversity & Inclusion Office](https://twiki.cern.ch/twiki/bin/view/CMSPublic/CMSDiversityOffice) and its activities. Dont forget to [check out the booklet](https://heyzine.com/flip-book/00f6546b1c.html).
1414

1515
---
1616

config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ episodes:
7070
- 03-gitlabci-setenv.md
7171
- 04-gitlabci-run-analysis.md
7272
- 05-gitlabci-vomsproxy.md
73+
- 06-catservices.md
74+
- 07-final-run.md
75+
# - A-extra-building-image.md
7376

7477
# Information for Learners
7578
learners:

episodes/03-gitlabci-setenv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If you skipped the previous lessons, ensure you have:
2626

2727
- A GitLab repository at CERN GitLab (named `cmsdas-gitlab-cms`).
2828
- The repository cloned to your local machine with an empty `.gitlab-ci.yml` file.
29-
- The example [analysis code](../files/ZPeakAnalysis.zip) downloaded and added to your repository.
29+
- The example [analysis code](files/ZPeakAnalysis.zip) downloaded and added to your repository.
3030

3131
:::::
3232

episodes/04-gitlabci-run-analysis.md

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exercises: 10
1515
:::::::: objectives
1616

1717
- Run a CMSSW analysis job in GitLab CI using a CVMFS-enabled runner.
18-
- Configure `.gitlab-ci.yml` to reuse a built CMSSW release via artifacts instead of rebuilding each time.
18+
- Configure `.gitlab-ci.yml` to reuse a built CMSSW release via artifacts instead of rebuilding each time, and handle write-protection in downstream jobs.
1919
- Validate the analysis output (ROOT file and event counts) within the CI pipeline.
2020

2121
::::::::
@@ -135,8 +135,13 @@ cmssw_run:
135135
script:
136136
- set +u && source ${CMS_PATH}/cmsset_default.sh; set -u
137137
- export SCRAM_ARCH=${SCRAM_ARCH}
138-
- cd ${CMSSW_RELEASE}/src
138+
- mkdir -p run
139+
- cp -r ${CMSSW_RELEASE} run/
140+
- chmod -R +w run/${CMSSW_RELEASE}/
141+
- cd run/${CMSSW_RELEASE}/src
139142
- cmsenv
143+
- mkdir -p AnalysisCode
144+
- cp -r $CI_PROJECT_DIR/ZPeakAnalysis AnalysisCode/
140145
- cd AnalysisCode/ZPeakAnalysis/
141146
- cmsRun test/MyZPeak_cfg.py
142147
- ls -l myZPeak.root
@@ -161,14 +166,81 @@ check_events:
161166
script:
162167
- set +u && source ${CMS_PATH}/cmsset_default.sh; set -u
163168
- export SCRAM_ARCH=${SCRAM_ARCH}
164-
- cd ${CMSSW_RELEASE}/src
169+
- mkdir -p run
170+
- cp -r ${CMSSW_RELEASE} run/
171+
- chmod -R +w run/${CMSSW_RELEASE}/
172+
- cd run/${CMSSW_RELEASE}/src
165173
- cmsenv
174+
- mkdir -p AnalysisCode
175+
- cp -r $CI_PROJECT_DIR/ZPeakAnalysis AnalysisCode/
166176
- cd AnalysisCode/ZPeakAnalysis/
167177
- python3 test/check_number_events.py --input ${CMSSW_RELEASE}/src/AnalysisCode/ZPeakAnalysis/myZPeak.root
168178
- python3 test/check_cutflows.py number_of_events.txt test/number_of_expected_events.txt
169179
```
170180
171-
If you are satisfied with your pipeline, commit and push the changes. Check the pipeline logs for errors and verify that output files are produced as expected.
181+
For the compiled code to be available in subsequent steps, the artifacts must be explicitly defined. In the `cmssw_compile` job, we specify:
182+
183+
```yaml
184+
artifacts:
185+
untracked: true
186+
expire_in: 1 hour
187+
paths:
188+
- ${CMSSW_RELEASE}
189+
```
190+
191+
**Key options:**
192+
193+
- **`untracked: true`:** Includes files not tracked by git (ignores `.gitignore`), ensuring the full CMSSW build area is captured.
194+
- **`expire_in`:** Specifies how long artifacts are kept before automatic deletion. Use `1 hour` for testing or `1 week` for longer workflows.
195+
- **`paths`:** Lists directories/files to preserve. Here, `${CMSSW_RELEASE}` captures the entire CMSSW work area.
196+
197+
:::::::: callout
198+
199+
### Artifacts Are Write-Protected
200+
201+
Artifacts are write-protected by default. You cannot modify files directly in the artifact directory in downstream jobs.
202+
203+
::::::::
204+
205+
To work around this, copy the artifact to a new directory and add write permissions:
206+
207+
```yaml
208+
script:
209+
- set +u && source ${CMS_PATH}/cmsset_default.sh; set -u
210+
- export SCRAM_ARCH=${SCRAM_ARCH}
211+
- mkdir -p run
212+
- cp -r ${CMSSW_RELEASE} run/
213+
- chmod -R +w run/${CMSSW_RELEASE}/
214+
- cd run/${CMSSW_RELEASE}/src
215+
- cmsenv
216+
- mkdir -p AnalysisCode
217+
- cp -r $CI_PROJECT_DIR/ZPeakAnalysis AnalysisCode/
218+
- cd AnalysisCode/ZPeakAnalysis/
219+
- cmsRun test/MyZPeak_cfg.py
220+
```
221+
222+
This ensures `cmssw_run` and `check_events` can reuse the built CMSSW area without rebuilding, while still being able to write output files.
223+
224+
### Using `needs` vs `dependencies`
225+
226+
In the pipeline above, we use the `needs` keyword to define job dependencies:
227+
228+
```yaml
229+
cmssw_run:
230+
needs:
231+
- cmssw_compile
232+
stage: run
233+
# ...
234+
```
235+
236+
**Differences between `needs` and `dependencies`:**
237+
238+
| Keyword | Behavior |
239+
|---------|----------|
240+
| [`needs`][gitlab-need] | Job starts **immediately** when the needed job completes, regardless of stage. Enables parallelism. |
241+
| [`dependencies`][gitlab-dependencies] | Job starts only when **all jobs in the prior stage** complete. Strictly follows stage order. |
242+
243+
**Best practice:** Use `needs` for faster pipelines—it allows jobs to start as soon as their dependencies are met, rather than waiting for an entire stage to finish.
172244

173245
::::::: discussion
174246
#### How does this updated pipeline improve efficiency?
@@ -210,7 +282,11 @@ If yes, you dont need the rest of the lessons. If they are failing, continue wit
210282
:::::: keypoints
211283

212284
- GitLab CI runs on remote runners; every dependency and setup step must be in `.gitlab-ci.yml`.
285+
- Use CVMFS-enabled Kubernetes runners (`k8s-cvmfs`); the `image:` keyword is honored only there.
213286
- Split the pipeline into stages and pass the built CMSSW area via artifacts to avoid rebuilding in each job.
214287
- Validate outputs in CI (e.g., `myZPeak.root`, event counts) to catch issues early; inspect job logs for failures.
288+
- Artifacts are write-protected by default; downstream jobs must copy them to a writable directory using `mkdir`, `cp -r`, and `chmod -R +w`.
289+
- Define artifacts with `untracked: true` to capture build outputs, and set `expire_in` to control automatic cleanup (e.g., `1 hour` for testing, `1 week` for production).
290+
- Use the `needs` keyword for faster pipelines—jobs start immediately when dependencies complete, rather than waiting for entire stages to finish. `dependencies` is an alternative that strictly respects stage order.
215291

216292
::::::

episodes/05-gitlabci-vomsproxy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ For each variable:
198198

199199
The **Settings > CI/CD > Variables** section should look like this:
200200

201-
![CI/CD Variables section with grid secrets added](fig/variables_gitlab.png)
201+
![CI/CD Variables section with grid secrets added](fig/variables_gitlab.png){alt='CI/CD Variables section with grid secrets added'}
202202

203203
### Protect Your Main Branch
204204

205205
To reduce the risk of leaking passwords and certificates to others, go to **Settings > Repository > Protected Branches** and protect your `master` or `main` branch. This prevents collaborators from pushing directly and accidentally exposing secrets in job logs.
206206

207-
![Protecting branches to prevent password leaks](fig/protected_branches.png)
207+
![Protecting branches to prevent password leaks](fig/protected_branches.png){alt='Protecting branches to prevent password leaks'}
208208

209209
With the **Protected** option enabled for variables, they are only available to those protected branches (though Maintainers can still push to them).
210210

0 commit comments

Comments
 (0)