Skip to content

Commit f20c2e9

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2102 from rsarm/tutorials-docker
[ci] Test run Spack and EasyBuild tutorial examples in a container
2 parents 79bedf8 + df08a4b commit f20c2e9

File tree

6 files changed

+83
-42
lines changed

6 files changed

+83
-42
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ jobs:
4747
run: |
4848
docker run reframe:${{ matrix.modules-version }}
4949
50+
tutorialtest:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v2
54+
- name: Build Image for Tutorial Tests
55+
run: |
56+
docker build -f ci-scripts/dockerfiles/tutorials.dockerfile -t reframe:tutorials .
57+
- name: Run Tutorial Tests
58+
run: |
59+
docker run reframe:tutorials
60+
5061
unusedimports:
5162
runs-on: ubuntu-latest
5263
steps:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Execute this from the top-level ReFrame source directory
3+
#
4+
5+
6+
FROM reframehpc/rfm-ci-base:lmod
7+
8+
ENV _SPACK_VER=0.16
9+
ENV _EB_VER=4.4.1
10+
11+
# Required utilities
12+
RUN apt-get -y update && \
13+
apt-get -y install curl
14+
15+
# ReFrame user
16+
RUN useradd -ms /bin/bash rfmuser
17+
18+
USER rfmuser
19+
20+
# Install Spack
21+
RUN git clone https://github.com/spack/spack ~/spack && \
22+
cd ~/spack && \
23+
git checkout releases/v${_SPACK_VER}
24+
25+
RUN pip3 install easybuild==${_EB_VER}
26+
27+
ENV PATH="/home/rfmuser/.local/bin:${PATH}"
28+
29+
# Install ReFrame from the current directory
30+
COPY --chown=rfmuser . /home/rfmuser/reframe/
31+
32+
WORKDIR /home/rfmuser/reframe
33+
34+
RUN ./bootstrap.sh
35+
36+
RUN echo '. /usr/local/lmod/lmod/init/profile && . /home/rfmuser/spack/share/spack/setup-env.sh' > /home/rfmuser/setup.sh
37+
38+
ENV BASH_ENV /home/rfmuser/setup.sh
39+
40+
CMD ["/bin/bash", "-c", "./bin/reframe -r -C tutorials/config/settings.py -R -c tutorials/build_systems --system tutorials-docker"]

docs/tutorial_build_automation.rst

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -109,53 +109,36 @@ Here is the test's code:
109109

110110

111111
When :attr:`~reframe.core.pipeline.RegressionTest.build_system` is set to ``'Spack'``, ReFrame will leverage Spack environments in order to build the test code.
112-
If the environment is not specified by the user, ReFrame will automatically create one inside the stage directory.
113-
ReFrame treats Spack environments specified by the user as *test resources* so it expects to find them under the test's :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir`, which defaults to ``'src'``.
114-
Here is the directory structure for the test in this particular example that we show here:
115-
116-
.. code:: console
117-
118-
tutorials/build_systems/spack/
119-
├── spack_test.py
120-
└── src
121-
└── myenv
122-
└── spack.yaml
123-
124-
125-
We could have placed ``spack.yaml`` directly under the ``src/`` directory, in which case we would need to specify ``'.'`` as an environment.
126-
For reference, here are the contents of ``spack.yaml``:
127-
128-
.. literalinclude:: ../tutorials/build_systems/spack/src/myenv/spack.yaml
129-
112+
By default, ReFrame will create a new Spack environment in the test's stage directory and add the requested :attr:`~reframe.core.buildsystems.Spack.specs` to it.
113+
Users may also specify an existing Spack environment by setting the :attr:`~reframe.core.buildsystems.Spack.environment` attribute.
114+
In this case, ReFrame treats the environment as a *test resource* so it expects to find it under the test's :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir`, which defaults to ``'src'``.
130115

131116
As with every other test, ReFrame will copy the test's resources to its stage directory before building it.
132-
ReFrame will then activate the environment and install the associated specs as in this case.
133-
Optionally, we can add more specs to the environment by setting the :attr:`~reframe.core.buildsystems.Spack.specs` attribute of the build system.
134-
Here is what ReFrame generates as a build script in this example:
117+
ReFrame will then activate the generated environment (either the one provided by the user or the one generated by ReFrame), add the given specs using the ``spack add`` command and, finally, install the packages in the environment.
118+
Here is what ReFrame generates as a build script for this example:
135119

136120
.. code:: bash
137121
138122
. "$(spack location --spack-root)/share/spack/setup-env.sh"
139-
spack env activate -V -d myenv
123+
spack env create -d rfm_spack_env
124+
spack env activate -V -d rfm_spack_env
125+
spack config add "config:install_tree:root:opt/spack"
126+
140127
spack install
141128
142-
Any additional specs specified inside the ReFrame test will be added using the ``spack add`` command.
143129
As you might have noticed ReFrame expects that Spack is already installed on the system.
144130
The packages specified in the environment and the tests will be installed in the test's stage directory, where the environment is copied before building.
145131
Here is the stage directory structure:
146132

147133
.. code:: console
148134
149135
stage/generic/default/builtin/BZip2SpackCheck/
150-
├── myenv
136+
├── rfm_spack_env
151137
│   ├── spack
152-
│   │   ├── opt
153-
│   │   │   └── spack
154-
│   │   │   ├── bin
155-
│   │   │   └── darwin-catalina-skylake
156-
│   │   └── share
157-
│   │   └── spack
158-
│   │   └── modules
138+
│   │   └── opt
139+
│   │      └── spack
140+
│   │      ├── bin
141+
│   │      └── darwin-catalina-skylake
159142
│   ├── spack.lock
160143
│   └── spack.yaml
161144
├── rfm_BZip2SpackCheck_build.err
@@ -172,7 +155,9 @@ Finally, here is the generated run script that ReFrame uses to run the test, onc
172155
173156
#!/bin/bash
174157
. "$(spack location --spack-root)/share/spack/setup-env.sh"
175-
spack env activate -V -d myenv
158+
spack env create -d rfm_spack_env
159+
spack env activate -V -d rfm_spack_env
160+
spack load [email protected]
176161
bzip2 --help
177162
178163
From this point on, sanity and performance checking are exactly identical to any other ReFrame test.

tutorials/build_systems/spack/spack_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BZip2SpackCheck(rfm.RegressionTest):
1818

1919
@run_before('compile')
2020
def setup_build_system(self):
21-
self.build_system.environment = 'myenv'
21+
self.build_system.specs = ['[email protected]']
2222

2323
@sanity_function
2424
def assert_version(self):

tutorials/build_systems/spack/src/myenv/spack.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tutorials/config/settings.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
}
2424
]
2525
},
26+
{
27+
'name': 'tutorials-docker',
28+
'descr': 'Container for running the build system tutorials',
29+
'hostnames': ['docker'],
30+
'modules_system': 'lmod',
31+
'partitions': [
32+
{
33+
'name': 'default',
34+
'scheduler': 'local',
35+
'launcher': 'local',
36+
'environs': ['builtin'],
37+
}
38+
]
39+
},
2640
{
2741
'name': 'daint',
2842
'descr': 'Piz Daint Supercomputer',

0 commit comments

Comments
 (0)