Skip to content

Commit 37bd140

Browse files
committed
[ci] build matrix
1 parent 5d39ca7 commit 37bd140

File tree

5 files changed

+165
-40
lines changed

5 files changed

+165
-40
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- ci
910
- 'bugfix*'
1011
- 'releases/**'
1112
pull_request:
@@ -20,11 +21,19 @@ on:
2021

2122
jobs:
2223
build:
24+
strategy:
25+
matrix:
26+
openfoam_version: ['2312', '2212', '2112']
27+
smartsim_version: ['0.7.0', '0.6.2']
28+
database_backend: ['redis']
29+
ubuntu_version: ['22.04', '20.04'] ## SmartSim not available yet for Python 3.12 on Ubuntu 24
30+
exclude:
31+
- ubuntu_version: '20.04' ## SmartSim 0.7.0 not released on ubuntu 20.04
32+
smartsim_version: '0.7.0'
2333
runs-on: ubuntu-22.04
2434

2535
container:
26-
image: ghcr.io/foamscience/openfoam-smartsim:cpu-2312
27-
options: --user openfoam
36+
image: ghcr.io/foamscience/openfoam-smartsim:of-${{ matrix.openfoam_version }}-smart-${{ matrix.smartsim_version }}-${{ matrix.database_backend }}-ubuntu-${{ matrix.ubuntu_version }}
2837
env:
2938
CATCH_TIMEOUT: 20
3039
FOAM_FOAMUT: "/tmp/foamUT"
@@ -46,13 +55,13 @@ jobs:
4655

4756
- name: Compile
4857
run: |
49-
source /usr/lib/openfoam/openfoam2312/etc/bashrc
58+
source /usr/lib/openfoam/openfoam${{ matrix.openfoam_version }}/etc/bashrc
5059
mkdir -p $FOAM_USER_LIBBIN
5160
./Allwmake
5261
5362
- name: Compile Tests and Run
5463
run: |
55-
source /usr/lib/openfoam/openfoam2312/etc/bashrc
64+
source /usr/lib/openfoam/openfoam${{ matrix.openfoam_version }}/etc/bashrc
5665
./Allwmake
5766
export SSDB="redis:6379"
5867
git clone https://github.com/FoamScience/foamUT $FOAM_FOAMUT

.github/workflows/todos.yaml

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

docker/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG UBUNTU_VERSION # Eg. 22.04
2+
FROM ubuntu:${UBUNTU_VERSION}
3+
# To build this image from this folder with OpenFOAM v2206:
4+
# docker build --build-arg OPENFOAM_VERSION=2206 --build-tag SMARTSIM_VERSION=0.7.0 -t openfoam-smartsim:latest .
5+
6+
ARG SMARTSIM_VERSION # Eg. 0.6.2
7+
ARG OPENFOAM_VERSION # Eg. 2206
8+
ARG DATABASE_BACKEND=redis # redis or keydb
9+
LABEL maintainer="Mohammed Elwardi Fadeli <[email protected]>"
10+
LABEL source="https://github.com/OFDataCommittee/openfoam-smartsim"
11+
12+
# Install and setup
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
ENV SHELL=/usr/bin/bash
15+
RUN apt update -y && \
16+
apt install -y --no-install-recommends git-lfs libpython3-dev pip cmake \
17+
sudo apt-utils vim curl wget software-properties-common \
18+
git-core cmake openssh-server gcc g++ \
19+
binutils libopenmpi-dev openmpi-bin openmpi-common openmpi-doc
20+
21+
# Set up OpenFOAM repositories
22+
RUN sh -c "curl https://dl.openfoam.com/add-debian-repo.sh | bash"
23+
RUN apt update -y && \
24+
apt install -y --no-install-recommends openfoam${OPENFOAM_VERSION}-default
25+
RUN apt clean && apt purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
26+
# Set up smartsim
27+
RUN pip install smartsim==${SMARTSIM_VERSION} && \
28+
if [ "${DATABASE_BACKEND}" = "keydb" ]; then smart build --device cpu --no_tf --no_pt; else smart build --device cpu --no_tf --no_pt --keydb; fi
29+
ENV USER openfoam
30+
ENV HOME=/home/${USER}
31+
RUN adduser --disabled-password --gecos "" ${USER} -u 1001 && \
32+
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
33+
USER openfoam
34+
RUN echo "source /usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" >> ${HOME}/.bashrc
35+
RUN . "/usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" && mkdir -p $FOAM_USER_LIBBIN && mkdir -p $FOAM_USER_APPBIN
36+
37+
38+
#COPY bin/uid_entrypoint /usr/local/bin/uid_entrypoint
39+
#ENTRYPOINT ["uid_entrypoint"]

docker/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Continuous Integration
2+
3+
## Overview
4+
5+
We continuously test against recent versions of the following software pieces:
6+
- Ubuntu
7+
- OpenFOAM
8+
- SmartSim
9+
- Database backend (redis, or keydb)
10+
11+
In particular, by testing on multiple versions of Ubuntu distribution, we make sure
12+
things work on the default toolchain versions (Compilers, system OpenMPI, ..., etc)
13+
14+
We use [Github Container Registry](https://ghcr.io/) to store the Docker images necessary for
15+
CI workflows.
16+
17+
## Instructions
18+
19+
> [!NOTE]
20+
> You will want to install ansible (locally) to build the images easily: `pip install ansible`.
21+
> Each image is a little than 2GB so make sure you have enough disk space.
22+
23+
1. In [docker/build.yml](docker/build.yml) file, add the new version in the relevant fact task.
24+
- For example, to add a new version of OpenFOAM, add the version to `openfoam_versions`
25+
- Then run `ansible-playbook build.yml --extra-vars "username=github_user token=$GITHUB_TOKEN`
26+
to build the corresponding image and push it.
27+
- When building the images locally, you can speed the process by removing other software versions
28+
and keeping only the new one
29+
2. In [.github/workflows/ci.yaml](.github/workflows/ci.yaml) file, add the new version in the relevant
30+
`strategy` section.
31+
- For example, to add a new version of OpenFOAM, add the version to `jobs.build.strategy.matrix.openfoam_version`
32+
- Then commit the changes to the repository.

docker/build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# ansible-playbook build.yml --extra-vars "username=user token=token"
2+
---
3+
- name: Build openfoam-smartsim CI infrastructure
4+
hosts: localhost
5+
gather_facts: false
6+
vars:
7+
ansible_python_interpreter: /usr/bin/python3
8+
9+
tasks:
10+
- name: Install docker python support for ansible
11+
pip:
12+
name: docker
13+
state: present
14+
15+
- name: Define list of OpenFOAM versions
16+
set_fact:
17+
openfoam_versions:
18+
- "2312"
19+
- "2212"
20+
- "2112"
21+
22+
- name: Define list of SmartSim versions
23+
set_fact:
24+
smartsim_versions:
25+
- "0.7.0"
26+
- "0.6.2"
27+
28+
- name: Define list of DB backends
29+
set_fact:
30+
database_backends:
31+
- "redis"
32+
33+
- name: Define list of Ubuntu versions
34+
set_fact:
35+
ubuntu_versions:
36+
#- "24.04" ## SmartSim not available for Python 3.12
37+
- "22.04"
38+
- "20.04"
39+
40+
- name: Login to GitHub Container Registry
41+
docker_login:
42+
username: "{{ username }}"
43+
password: "{{ token }}"
44+
registry_url: "https://ghcr.io"
45+
46+
- name: Build Docker images
47+
docker_image:
48+
name: "ghcr.io/{{ username }}/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}"
49+
source: "build"
50+
build:
51+
path: "."
52+
dockerfile: "Dockerfile"
53+
pull: yes
54+
args:
55+
OPENFOAM_VERSION: "{{ item.0 }}"
56+
SMARTSIM_VERSION: "{{ item.1 }}"
57+
DATABASE_BACKEND: "{{ item.2 }}"
58+
UBUNTU_VERSION: "{{ item.3 }}"
59+
loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}"
60+
when: "not (item.1 == '0.7.0' and item.3 == '20.04')"
61+
async: 1200
62+
poll: 0
63+
register: async_result
64+
65+
- name: Wait for all build tasks to complete
66+
async_status:
67+
jid: "{{ item.ansible_job_id }}"
68+
loop: "{{ async_result.results }}"
69+
when: item.changed
70+
register: async_status_result
71+
until: async_status_result.finished
72+
retries: 20
73+
delay: 60
74+
75+
- name: Push Docker images to GitHub Container Registry
76+
docker_image:
77+
name: "ghcr.io/{{ username }}/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}"
78+
source: local
79+
push: yes
80+
loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}"
81+
when: "not (item.1 == '0.7.0' and item.3 == '20.04')"

0 commit comments

Comments
 (0)