Skip to content

Commit 3b91773

Browse files
committed
Finalise CI episode
1 parent 1c3fccb commit 3b91773

3 files changed

Lines changed: 91 additions & 0 deletions

File tree

docs/eessi-in-ci.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,53 @@ button a new box pops up that indicates that 4 different CI runs are executing.
260260
architecture. If we click on `Details` for one of the runs, we get taken to where the workflow is actually running,
261261
and the output it is generating.
262262

263+
The run is broken down into `steps`, each of which has a name. The one we are interested in is
264+
`Build and test our package`, which is where we defined our build processs. While the build is running we can read the
265+
output, or we can view it after the run completes. Regardless, we note that the output is almost identical to that
266+
which we had when we ran the workflow ourselves. This is no more than we expect in reality, since this is what EESSI
267+
is supposed to deliver for us.
268+
269+
If we wait a little we should see that our CI will succeed! :rocket: When it does the brown button in our Pull Request
270+
will become a green tick which indicates that our CI for the commit has passed.
271+
272+
??? note "What would have our CI looked like in GitLab?"
273+
274+
There are not so many differences with how our specific CI would have looked like in CI/CD. One major difference is
275+
where the CI file is stored. In the case of GitLab CI/CD, the workflow must be stored in a file called
276+
`.gitlab-ci.yml` in the base directory of the repository. The documentation of EESSI GitLab compenent
277+
again provides a starting point from which we can construct a final CI file:
278+
```yaml title=".gitlab-ci.yml"
279+
--8<-- "scripts/.gitlab-ci.yml"
280+
```
263281

264282
### What happens when CI fails?
265283

284+
What does a failure look like in CI? We know that if we do not load the `buildenv` module, our tests should fail. Let's
285+
construct that scenario, by commenting out the line that loads that module:
286+
```yaml title="ci.yml"
287+
--8<-- "scripts/ci-broken.yml"
288+
```
289+
290+
We can now push the change to our Pull Request to rerun the CI.
291+
``` { .bash .copy }
292+
git add .github/workflows/ci.yml
293+
git commit -m "Don't load buildenv, which should break our CI"
294+
git push origin add_ci_to_project
295+
```
296+
297+
Eventually, as expected, our CI will fail and we will get a red X beside our commit. We should also receive an email
298+
notification that our CI has failed. Such notifications are a critical part of CI, the value of CI is not just that
299+
the tests run silently, but that we are made aware immediately when things go wrong.
300+
266301
## Benefits of CI
302+
303+
By automatically building and validating software whenever changes are made,
304+
CI helps developers identify issues early, reduce integration problems, and maintain confidence in the stability of
305+
their code.
306+
307+
Combined with EESSI’s reproducible software environment, CI ensures that applications are tested under the
308+
same conditions regardless of where they are executed, improving reliability, collaboration, and overall software
309+
quality throughout the development process.
310+
311+
It also means that when things go wrong, it is straightforward for us to drop into the environment where the tests
312+
fail, and interactively explore the problem.

scripts/.gitlab-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include:
2+
- component: $CI_SERVER_FQDN/eessi/gitlab-eessi/eessi@1.0.12
3+
4+
build:
5+
stage: build
6+
script: |
7+
module load CMake/4.0.3-GCCcore-14.3.0
8+
module load HDF5/1.14.6-gompi-2025b
9+
module load buildenv/default-foss-2025b
10+
mkdir build
11+
cd build
12+
cmake ..
13+
make -j
14+
ctest --output-on-failure --verbose

scripts/ci-broken.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
ubuntu-minimal:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os:
13+
- ubuntu-24.04-arm
14+
- ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: eessi/github-action-eessi@v3
18+
with:
19+
eessi_stack_version: '2025.06'
20+
- name: Build and test our package
21+
run: |
22+
module load CMake/4.0.3-GCCcore-14.3.0
23+
module load HDF5/1.14.6-gompi-2025b
24+
# We deliberately break our CI by not loading buildenv
25+
# module load buildenv/default-foss-2025b
26+
mkdir build
27+
cd build
28+
cmake ..
29+
make -j
30+
ctest --output-on-failure --verbose
31+
shell: bash

0 commit comments

Comments
 (0)