# EESSI CI/CD Cheatsheet
Walk through starting from https://github.com/EESSI/cicd-demo
## Building with EESSI
Follow https://www.eessi.io/docs/using_eessi/building_on_eessi/#manually-building-software-on-top-of-eessi-without-easybuild .
```
module load CMake HDF5
mkdir build
cd build/
cmake ..
make -j
ctest --output-on-failure --verbose
```
There are failing tests due to unfound libraries which we can explore with `ldd` on the executable. These happen because we haven't told the _dynamic linker_ how to find the needed libraries:

We can fix the errors by making sure the loader knows where the libraries are using our `buildenv` environment module
```
module load buildenv
rm -r ./*
cmake ..
make -j
ctest --output-on-failure --verbose
```
## Building with EESSI in CI (GitHub Actions)
Check out https://github.com/marketplace/actions/eessi
Build with both Arm and x86 support
```yaml
jobs:
ubuntu-minimal:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-24.04-arm
- ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: eessi/github-action-eessi@v3
- name: Test building with EESSI
run: |
module load HDF5 CMake buildenv
mkdir build
cd build/
cmake ..
make -j
ctest --output-on-failure --verbose
shell: bash
```
This will fail as I didn't give a trigger
```yaml
name: Build with EESSI
on: [push, pull_request]
```
## Building with EESSI-extend
Do things locally first.
Some decent hints and tips at https://www.eessi.io/docs/adding_software/adding_development_software/#installation-details
Need to find decent examples for our use case. First target an easyblock
```bash
eb --list-easyblocks | grep -i cmake
```
then check out the options of that for testing
```bash
eb --avail-easyconfig-params --easyblock CMakeMake | grep -i test
```
Go searching in [GitHub easyconfig repo](https://github.com/easybuilders/easybuild-easyconfigs) to find a decent/recent match (with terms `cmakemake runtest`).
Use the example as a base, but the docs above are already pretty decent.
Final product should look similar to
```python=
easyblock = 'CMakeMake'
name = 'cicd-demo'
version = 'devel'
versionsuffix = '-%(software_commit)s'
homepage = 'none'
description = """
Simple project that writes in parallel via HDF5
"""
toolchain = {'name': 'gompi', 'version': '2023b'}
github_account = 'EESSI'
source_urls = ['https://github.com/%(github_account)s/%(name)s/archive/']
sources = ['%(software_commit)s.tar.gz']
builddependencies = [
('CMake', '3.27.6'),
]
dependencies = [
('HDF5', '1.14.3'),
]
runtest = True
sanity_check_paths = {
'files': ['bin/hello_mpi_hdf5'],
'dirs': [],
}
moduleclass = 'devel'
```
Easyconfig can't know whether or not there are tests, you need to tell it. How would I have noticed the tests were _not_ being run? `eb --extended-dry-run`
Also, note that EasyBuild is _downloading_ the sources, not taking the local ones.
At this point you should be able to do a local build with only `EESSI-extend` loaded:
```bash
eb --software-commit 162535aba7e866306adc423560eb394d60456b4b easybuild/cicd-demo.eb
```
Note that the commit **must** be available in the source repo.
## Building with EESSI-extend in CI (GitHub Actions)
Basically can reuse what we have and make a new workflow, just instead running the commands
```yml
- name: Test via EESSI-extend
run: |
module load EESSI-extend
unset EASYBUILD_DEBUG
eb --logtostdout --software-commit=$GITHUB_SHA easybuild/cicd-demo.eb
shell: bash
```
LLM or a search engine could have told us how we access the SHA.
## Building with EESSI-extend in CI (GitLab CI/CD)
Example given in https://gitlab.com/explore/catalog/eessi/gitlab-eessi#instructions . Trivial to adapt for our use case (`.gitlab-ci.yml`):
```yml
include:
- component: $CI_SERVER_FQDN/eessi/gitlab-eessi/eessi@1.0.12
build:
stage: build
script:
- module load EESSI-extend
- unset EASYBUILD_DEBUG
# Build and test
- eb --logtostdout --software-commit $CI_COMMIT_SHA easybuild/cicd-demo.eb
```
Again, use LLM or search to find out how to reference SHA