Skip to content

Commit 2b54cf1

Browse files
authored
Enable running the system tests in forks (#638)
1 parent 4002c18 commit 2b54cf1

File tree

7 files changed

+76
-45
lines changed

7 files changed

+76
-45
lines changed

.github/workflows/run_testsuite_workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
rm -rf ./*
6060
rm -rf ./.??*
6161
ls -la ./
62-
- name: Check out Tutorials for them system tests (tools/tests/)
62+
- name: Check out Tutorials for the system tests (tools/tests/)
6363
uses: actions/checkout@v4
6464
with:
6565
repository: precice/tutorials

.github/workflows/system-tests-pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ jobs:
109109
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
110110
echo "### Tutorials" >> $GITHUB_STEP_SUMMARY
111111
echo "Reference (pull request): \`${{ github.event.pull_request.head.sha }}\`" >> $GITHUB_STEP_SUMMARY
112+
echo "Pull request number: [${{ github.event.number }}](https://github.com/precice/tutorials/pull/${{ github.event.number }})" >> $GITHUB_STEP_SUMMARY
112113
113114
run-system-tests:
114115
name: Trigger system tests
@@ -127,6 +128,7 @@ jobs:
127128
OPENFOAM_ADAPTER_REF:${{ needs.gather-refs.outputs.ref-openfoam-adapter }},\
128129
SU2_VERSION:7.5.1,\
129130
SU2_ADAPTER_REF:${{ needs.gather-refs.outputs.ref-su2-adapter }},\
131+
TUTORIALS_PR:${{ github.event.number }},\
130132
TUTORIALS_REF:${{ github.event.pull_request.head.sha }}"
131133
system_tests_branch: develop
132134
log_level: "INFO"

changelog-entries/638.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added support for running the system tests in forks [#638](https://github.com/precice/tutorials/pull/638)

tools/tests/components.yaml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ bare: # A default component used when the solver does not have any dependencies
22
repository: https://github.com/precice/precice
33
template: component-templates/bare.yaml
44
build_arguments: # these things mean something to the docker-service
5+
PLATFORM:
6+
description: Dockerfile platform used
7+
default: "ubuntu_2404"
58
PRECICE_REF:
69
description: Version of preCICE to use
710
default: "main"
811
PRECICE_PRESET:
912
description: CMake preset of preCICE
1013
default: "production-audit"
11-
PLATFORM:
12-
description: Dockerfile platform used
13-
default: "ubuntu_2404"
1414
TUTORIALS_REF:
1515
description: Tutorial git reference to use
1616
default: "master"
@@ -19,35 +19,35 @@ python-bindings:
1919
repository: https://github.com/precice/python-bindings
2020
template: component-templates/python-bindings.yaml
2121
build_arguments:
22+
PLATFORM:
23+
description: Dockerfile platform used
24+
default: "ubuntu_2404"
2225
PRECICE_REF:
2326
description: Version of preCICE to use
2427
default: "main"
2528
PRECICE_PRESET:
2629
description: CMake preset of preCICE
2730
default: "production-audit"
28-
PLATFORM:
29-
description: Dockerfile platform used
30-
default: "ubuntu_2404"
3131
TUTORIALS_REF:
3232
description: Tutorial git reference to use
3333
default: "master"
3434
PYTHON_BINDINGS_REF:
35-
semnantic: Git ref of the pythonbindings to use
35+
semnantic: Git ref of the Python bindings to use
3636
default: "master"
3737

3838
openfoam-adapter:
3939
repository: https://github.com/precice/openfoam-adapter
4040
template: component-templates/openfoam-adapter.yaml
4141
build_arguments:
42+
PLATFORM:
43+
description: Dockerfile platform used
44+
default: "ubuntu_2404"
4245
PRECICE_REF:
4346
description: Version of preCICE to use
4447
default: "main"
4548
PRECICE_PRESET:
4649
description: CMake preset of preCICE
4750
default: "production-audit"
48-
PLATFORM:
49-
description: Dockerfile platform used
50-
default: "ubuntu_2404"
5151
TUTORIALS_REF:
5252
description: Tutorial git reference to use
5353
default: "master"
@@ -56,28 +56,27 @@ openfoam-adapter:
5656
description: exectuable of openfoam to use
5757
default: "openfoam2306"
5858
OPENFOAM_ADAPTER_REF:
59-
description: Reference/tag of the actual OpenFOAM adapter
59+
description: Reference/tag of the OpenFOAM adapter to use
6060
default: "master"
6161

62-
6362
fenics-adapter:
6463
repository: https://github.com/precice/fenics-adapter
6564
template: component-templates/fenics-adapter.yaml
6665
build_arguments:
66+
PLATFORM:
67+
description: Dockerfile platform used
68+
default: "ubuntu_2404"
6769
PRECICE_REF:
6870
description: Version of preCICE to use
6971
default: "main"
7072
PRECICE_PRESET:
7173
description: CMake preset of preCICE
7274
default: "production-audit"
73-
PLATFORM:
74-
description: Dockerfile platform used
75-
default: "ubuntu_2404"
7675
TUTORIALS_REF:
7776
description: Tutorial git reference to use
7877
default: "master"
7978
PYTHON_BINDINGS_REF:
80-
semnantic: Git ref of the pythonbindings to use
79+
semnantic: Git ref of the Python bindings to use
8180
default: "master"
8281
FENICS_ADAPTER_REF:
8382
semnantic: Git ref of the fenics adapter to use
@@ -87,35 +86,35 @@ nutils-adapter:
8786
repository: https://github.com/precice/nutils-adapter
8887
template: component-templates/nutils-adapter.yaml
8988
build_arguments:
89+
PLATFORM:
90+
description: Dockerfile platform used
91+
default: "ubuntu_2404"
9092
PRECICE_REF:
9193
description: Version of preCICE to use
9294
default: "main"
9395
PRECICE_PRESET:
9496
description: CMake preset of preCICE
9597
default: "production-audit"
96-
PLATFORM:
97-
description: Dockerfile platform used
98-
default: "ubuntu_2404"
9998
TUTORIALS_REF:
10099
description: Tutorial git reference to use
101100
default: "master"
102101
PYTHON_BINDINGS_REF:
103-
semnantic: Git ref of the pythonbindings to use
104-
102+
semnantic: Git ref of the Python bindings to use
103+
default: "master"
105104

106105
calculix-adapter:
107106
repository: https://github.com/precice/calculix-adapter
108107
template: component-templates/calculix-adapter.yaml
109108
build_arguments:
109+
PLATFORM:
110+
description: Dockerfile platform used
111+
default: "ubuntu_2404"
110112
PRECICE_REF:
111113
description: Version of preCICE to use
112114
default: "main"
113115
PRECICE_PRESET:
114116
description: CMake preset of preCICE
115117
default: "production-audit"
116-
PLATFORM:
117-
description: Dockerfile platform used
118-
default: "ubuntu_2404"
119118
TUTORIALS_REF:
120119
description: Tutorial git reference to use
121120
default: "master"
@@ -130,15 +129,15 @@ su2-adapter:
130129
repository: https://github.com/precice/su2-adapter
131130
template: component-templates/su2-adapter.yaml
132131
build_arguments:
132+
PLATFORM:
133+
description: Dockerfile platform used
134+
default: "ubuntu_2404"
133135
PRECICE_REF:
134136
description: Version of preCICE to use
135137
default: "main"
136138
PRECICE_PRESET:
137139
description: CMake preset of preCICE
138140
default: "production-audit"
139-
PLATFORM:
140-
description: Dockerfile platform used
141-
default: "ubuntu_2404"
142141
TUTORIALS_REF:
143142
description: Tutorial git reference to use
144143
default: "master"

tools/tests/dockerfiles/ubuntu_2204/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ RUN python3 -m pip install --user --upgrade pip
4747

4848
FROM precice_dependecies AS precice
4949
# Install & build precice into /home/precice/precice
50+
ARG PRECICE_PR
5051
ARG PRECICE_REF
5152
ARG PRECICE_PRESET
5253
USER precice
5354
WORKDIR /home/precice
5455
RUN git clone https://github.com/precice/precice.git precice && \
5556
cd precice && \
57+
if [ -n "${PRECICE_PR}" ]; then git fetch origin pull/${PRECICE_PR}/head; fi && \
5658
git checkout ${PRECICE_REF} && \
5759
mkdir build && cd build &&\
5860
cmake .. --preset=${PRECICE_PRESET} -DCMAKE_INSTALL_PREFIX=/home/precice/.local/ -DPRECICE_PETScMapping=OFF -DBUILD_TESTING=OFF && \
@@ -67,12 +69,14 @@ RUN apt-get update &&\
6769
ln -s $(which ${OPENFOAM_EXECUTABLE} ) /usr/bin/openfoam
6870
USER precice
6971
COPY --from=precice /home/precice/.local/ /home/precice/.local/
72+
ARG OPENFOAM_ADAPTER_PR
7073
ARG OPENFOAM_ADAPTER_REF
7174
# Build the OpenFOAM adapter
7275
USER precice
7376
WORKDIR /home/precice
7477
RUN git clone https://github.com/precice/openfoam-adapter.git &&\
7578
cd openfoam-adapter && \
79+
if [ -n "${OPENFOAM_ADAPTER_PR}" ]; then git fetch origin pull/${OPENFOAM_ADAPTER_PR}/head; fi && \
7680
git checkout ${OPENFOAM_ADAPTER_REF} && \
7781
/usr/bin/${OPENFOAM_EXECUTABLE} ./Allwmake -j $(nproc)
7882

@@ -119,10 +123,12 @@ RUN wget http://www.dhondt.de/ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
119123
tar xvjf ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
120124
rm -fv ccx_${CALCULIX_VERSION}.src.tar.bz2
121125

126+
ARG CALCULIX_ADAPTER_PR
122127
ARG CALCULIX_ADAPTER_REF
123128
WORKDIR /home/precice
124129
RUN git clone https://github.com/precice/calculix-adapter.git && \
125130
cd calculix-adapter && \
131+
if [ -n "${CALCULIX_ADAPTER_PR}" ]; then git fetch origin pull/${CALCULIX_ADAPTER_PR}/head; fi && \
126132
git checkout ${CALCULIX_ADAPTER_REF} &&\
127133
make CXX_VERSION=${CALCULIX_VERSION} ADDITIONAL_FFLAGS="-fallow-argument-mismatch" -j $(nproc) && \
128134
ln -s /home/precice/calculix-adapter/bin/ccx_preCICE /home/precice/.local/bin/ccx_preCICE
@@ -141,6 +147,7 @@ RUN wget https://github.com/su2code/SU2/archive/refs/tags/v${SU2_VERSION}.tar.gz
141147
tar xvzf v${SU2_VERSION}.tar.gz && \
142148
rm -fv v${SU2_VERSION}.tar.gz
143149
RUN pip3 install --user mpi4py
150+
ARG SU2_ADAPTER_PR
144151
ARG SU2_ADAPTER_REF
145152
WORKDIR /home/precice
146153
ENV SU2_RUN="/home/precice/SU2_RUN"
@@ -149,6 +156,7 @@ ENV PATH="/home/precice/su2-adapter/run:$SU2_RUN:$PATH"
149156
ENV PYTHONPATH="$SU2_RUN:$PYTHONPATH"
150157
RUN git clone https://github.com/precice/su2-adapter.git && \
151158
cd su2-adapter &&\
159+
if [ -n "${SU2_ADAPTER_PR}" ]; then git fetch origin pull/${SU2_ADAPTER_PR}/head; fi && \
152160
git checkout ${SU2_ADAPTER_REF} &&\
153161
./su2AdapterInstall
154162
RUN cd "${SU2_HOME}" &&\

tools/tests/dockerfiles/ubuntu_2404/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ USER precice
4545

4646
FROM precice_dependecies AS precice
4747
# Install & build precice into /home/precice/precice
48+
ARG PRECICE_PR
4849
ARG PRECICE_REF
4950
ARG PRECICE_PRESET
5051
USER precice
5152
WORKDIR /home/precice
5253
RUN git clone https://github.com/precice/precice.git precice && \
5354
cd precice && \
55+
if [ -n "${PRECICE_PR}" ]; then git fetch origin pull/${PRECICE_PR}/head; fi && \
5456
git checkout ${PRECICE_REF} && \
5557
mkdir build && cd build &&\
5658
cmake .. --preset=${PRECICE_PRESET} -DCMAKE_INSTALL_PREFIX=/home/precice/.local/ -DPRECICE_PETScMapping=OFF -DBUILD_TESTING=OFF && \
@@ -65,12 +67,14 @@ RUN apt-get update &&\
6567
ln -s $(which ${OPENFOAM_EXECUTABLE} ) /usr/bin/openfoam
6668
USER precice
6769
COPY --from=precice /home/precice/.local/ /home/precice/.local/
70+
ARG OPENFOAM_ADAPTER_PR
6871
ARG OPENFOAM_ADAPTER_REF
6972
# Build the OpenFOAM adapter
7073
USER precice
7174
WORKDIR /home/precice
7275
RUN git clone https://github.com/precice/openfoam-adapter.git &&\
7376
cd openfoam-adapter && \
77+
if [ -n "${OPENFOAM_ADAPTER_PR}" ]; then git fetch origin pull/${OPENFOAM_ADAPTER_PR}/head; fi && \
7478
git checkout ${OPENFOAM_ADAPTER_REF} && \
7579
/usr/bin/${OPENFOAM_EXECUTABLE} ./Allwmake -j $(nproc)
7680

@@ -123,10 +127,12 @@ RUN wget http://www.dhondt.de/ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
123127
tar xvjf ccx_${CALCULIX_VERSION}.src.tar.bz2 && \
124128
rm -fv ccx_${CALCULIX_VERSION}.src.tar.bz2
125129

130+
ARG CALCULIX_ADAPTER_PR
126131
ARG CALCULIX_ADAPTER_REF
127132
WORKDIR /home/precice
128133
RUN git clone https://github.com/precice/calculix-adapter.git && \
129134
cd calculix-adapter && \
135+
if [ -n "${CALCULIX_ADAPTER_PR}" ]; then git fetch origin pull/${CALCULIX_ADAPTER_PR}/head; fi && \
130136
git checkout ${CALCULIX_ADAPTER_REF} &&\
131137
make CXX_VERSION=${CALCULIX_VERSION} ADDITIONAL_FFLAGS="-fallow-argument-mismatch" -j $(nproc) && \
132138
ln -s /home/precice/calculix-adapter/bin/ccx_preCICE /home/precice/.local/bin/ccx_preCICE
@@ -147,6 +153,7 @@ RUN wget https://github.com/su2code/SU2/archive/refs/tags/v${SU2_VERSION}.tar.gz
147153
rm -fv v${SU2_VERSION}.tar.gz
148154
RUN python3 -m venv /home/precice/venv && \
149155
. /home/precice/venv/bin/activate
156+
ARG SU2_ADAPTER_PR
150157
ARG SU2_ADAPTER_REF
151158
WORKDIR /home/precice
152159
ENV SU2_RUN="/home/precice/SU2_RUN"
@@ -155,6 +162,7 @@ ENV PATH="/home/precice/su2-adapter/run:$SU2_RUN:$PATH"
155162
ENV PYTHONPATH="$SU2_RUN:$PYTHONPATH"
156163
RUN git clone https://github.com/precice/su2-adapter.git && \
157164
cd su2-adapter &&\
165+
if [ -n "${SU2_ADAPTER_PR}" ]; then git fetch origin pull/${SU2_ADAPTER_PR}/head; fi && \
158166
git checkout ${SU2_ADAPTER_REF} &&\
159167
./su2AdapterInstall
160168
RUN cd "${SU2_HOME}" &&\

tools/tests/systemtests/Systemtest.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,30 +146,26 @@ def __post_init__(self):
146146

147147
def __init_args_to_use(self):
148148
"""
149-
Checks if all required parameters for the realisation of the cases are supplied in the cmdline arguments.
150-
If a parameter is missing and it's required, an exception is raised.
151-
Otherwise, the default value is used if available.
149+
Forwards the command-line arguments to the params_to_use dictionary, substituting any missing arguments with their defaults.
152150
153-
In the end it populates the args_to_use dict
154-
155-
Raises:
156-
Exception: If a required parameter is missing.
151+
Previously, this function was also checking if all required parameters were provided, and was raising exceptions for parameters not provided and not having a default value. This check made adding optional parameters with empty defaults (e.g., the TUTORIALS_PR) complicated, and it was removed.
157152
"""
158-
self.params_to_use = {}
153+
154+
# Forward all provided arguments to params_to_use
155+
provided_arguments = self.arguments.arguments
156+
self.params_to_use = provided_arguments
157+
158+
# Find out which parameters are needed
159159
needed_parameters = set()
160160
for case in self.case_combination.cases:
161161
needed_parameters.update(case.component.parameters)
162162

163+
# Substitute defaults for non-provided, needed arguments
163164
for needed_param in needed_parameters:
164-
if self.arguments.contains(needed_param.key):
165-
self.params_to_use[needed_param.key] = self.arguments.get(
166-
needed_param.key)
167-
else:
168-
if needed_param.required:
169-
raise Exception(
170-
f"{needed_param} is needed to be given via --params to instantiate the systemtest for {self.tutorial.name}")
171-
else:
172-
self.params_to_use[needed_param.key] = needed_param.default
165+
if not needed_param.key in provided_arguments:
166+
logging.warning(
167+
f"No argument provided for needed parameter {needed_param.key}. Substituting with {needed_param.default}")
168+
self.params_to_use[needed_param.key] = needed_param.default
173169

174170
def __get_docker_services(self) -> Dict[str, str]:
175171
"""
@@ -249,6 +245,19 @@ def _get_git_ref(self, repository: Path, abbrev_ref=False) -> Optional[str]:
249245
except Exception as e:
250246
raise RuntimeError(f"An error occurred while getting the current Git ref: {e}") from e
251247

248+
def _fetch_pr(self, repository: Path, pr: str):
249+
try:
250+
result = subprocess.run([
251+
"git",
252+
"-C", os.fspath(repository.resolve()),
253+
"fetch",
254+
"origin",
255+
"pull/" + pr + "/head"
256+
], check=True, timeout=60)
257+
258+
except Exception as e:
259+
raise RuntimeError(f"git command returned code {result.returncode}")
260+
252261
def _fetch_ref(self, repository: Path, ref: str):
253262
try:
254263
result = subprocess.run([
@@ -282,6 +291,10 @@ def __copy_tutorial_into_directory(self, run_directory: Path):
282291
"""
283292
current_time_string = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
284293
self.run_directory = run_directory
294+
pr_requested = self.params_to_use.get("TUTORIALS_PR")
295+
if pr_requested:
296+
logging.debug(f"Fetching the PR {pr_requested} HEAD reference")
297+
self._fetch_pr(PRECICE_TUTORIAL_DIR, pr_requested)
285298
current_ref = self._get_git_ref(PRECICE_TUTORIAL_DIR)
286299
ref_requested = self.params_to_use.get("TUTORIALS_REF")
287300
if ref_requested:

0 commit comments

Comments
 (0)