-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from FoamScience/ci
[ci] build matrix on ubuntu, openfoam, database, and smartsim versions
- Loading branch information
Showing
5 changed files
with
184 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ARG UBUNTU_VERSION # Eg. 22.04 | ||
FROM ubuntu:${UBUNTU_VERSION} | ||
# To build this image from this folder with OpenFOAM v2206: | ||
# docker build --build-arg OPENFOAM_VERSION=2206 --build-tag SMARTSIM_VERSION=0.7.0 -t openfoam-smartsim:latest . | ||
|
||
ARG SMARTSIM_VERSION # Eg. 0.6.2 | ||
ARG OPENFOAM_VERSION # Eg. 2206 | ||
ARG DATABASE_BACKEND=redis # redis or keydb | ||
LABEL maintainer="Mohammed Elwardi Fadeli <[email protected]>" | ||
LABEL source="https://github.com/OFDataCommittee/openfoam-smartsim" | ||
|
||
# Install and setup | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV SHELL=/usr/bin/bash | ||
RUN apt update -y && \ | ||
apt install -y --no-install-recommends git-lfs libpython3-dev pip cmake \ | ||
sudo apt-utils vim curl wget software-properties-common \ | ||
git-core cmake openssh-server gcc g++ \ | ||
binutils libopenmpi-dev openmpi-bin openmpi-common openmpi-doc | ||
|
||
# Set up OpenFOAM repositories | ||
RUN sh -c "curl https://dl.openfoam.com/add-debian-repo.sh | bash" | ||
RUN apt update -y && \ | ||
apt install -y --no-install-recommends openfoam${OPENFOAM_VERSION}-default | ||
RUN apt clean && apt purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
# Set up smartsim | ||
RUN pip install smartsim==${SMARTSIM_VERSION} && \ | ||
if [ "${DATABASE_BACKEND}" = "keydb" ]; then smart build --device cpu --no_tf --no_pt; else smart build --device cpu --no_tf --no_pt --keydb; fi | ||
ENV USER openfoam | ||
ENV HOME=/home/${USER} | ||
RUN adduser --disabled-password --gecos "" ${USER} -u 1001 && \ | ||
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
USER openfoam | ||
RUN echo "source /usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" >> ${HOME}/.bashrc | ||
RUN . "/usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" && mkdir -p $FOAM_USER_LIBBIN && mkdir -p $FOAM_USER_APPBIN | ||
|
||
|
||
#COPY bin/uid_entrypoint /usr/local/bin/uid_entrypoint | ||
#ENTRYPOINT ["uid_entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Continuous Integration | ||
|
||
## Overview | ||
|
||
We continuously test against recent versions of the following software pieces: | ||
- Ubuntu | ||
- OpenFOAM | ||
- SmartSim | ||
- Database backend (redis, or keydb) | ||
|
||
In particular, by testing on multiple versions of Ubuntu distribution, we make sure | ||
things work on the default toolchain versions (Compilers, system OpenMPI, ..., etc) | ||
|
||
We use [Github Container Registry](https://ghcr.io/) to store the Docker images necessary for | ||
CI workflows. | ||
|
||
## Instructions for automated image builds | ||
|
||
> [!NOTE] | ||
> You will want to install ansible (locally) to build the images easily: `pip install ansible`. | ||
> Each image is a little than 2GB so make sure you have enough disk space. | ||
1. In [docker/build.yml](docker/build.yml) file, add the new version in the relevant fact task. | ||
- For example, to add a new version of OpenFOAM, add the version to `openfoam_versions` | ||
- Then run `ansible-playbook build.yml --extra-vars "username=github_user token=$GITHUB_TOKEN` | ||
to build the corresponding image and push it. | ||
- When building the images locally, you can speed the process by removing other software versions | ||
and keeping only the new one | ||
2. In [.github/workflows/ci.yaml](.github/workflows/ci.yaml) file, add the new version in the relevant | ||
`strategy` section. | ||
- For example, to add a new version of OpenFOAM, add the version to `jobs.build.strategy.matrix.openfoam_version` | ||
- Then commit the changes to the repository. | ||
|
||
## Instructions for manual image builds | ||
|
||
```sh | ||
cd docker | ||
docker build \ | ||
--build-arg OPENFOAM_VERSION=2312 \ | ||
--build-arg UBUNTU_VERSION=22.04 \ | ||
--build-arg DATABASE_BACKEND=redis \ | ||
--build-arg SMARTSIM_VERSION=0.7.0 \ | ||
-t ghcr.io/<github_user>/openfoam-smartsim:of-2312-smartsim-0.7.0-redis-ubuntu-22.04 . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ansible-playbook build.yml --extra-vars "username=user token=token" | ||
--- | ||
- name: Build openfoam-smartsim CI infrastructure | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
ansible_python_interpreter: /usr/bin/python3 | ||
|
||
tasks: | ||
- name: Install docker python support for ansible | ||
pip: | ||
name: docker | ||
state: present | ||
|
||
- name: Define list of OpenFOAM versions | ||
set_fact: | ||
openfoam_versions: | ||
- "2312" | ||
- "2212" | ||
|
||
- name: Define list of SmartSim versions | ||
set_fact: | ||
smartsim_versions: | ||
- "0.7.0" | ||
- "0.6.2" | ||
|
||
- name: Define list of DB backends | ||
set_fact: | ||
database_backends: | ||
- "redis" | ||
|
||
- name: Define list of Ubuntu versions | ||
set_fact: | ||
ubuntu_versions: | ||
#- "24.04" ## SmartSim not available for Python 3.12 | ||
- "22.04" | ||
- "20.04" | ||
|
||
- name: Login to GitHub Container Registry | ||
docker_login: | ||
username: "{{ username }}" | ||
password: "{{ token }}" | ||
registry_url: "https://ghcr.io" | ||
|
||
- name: Build Docker images | ||
docker_image: | ||
name: "ghcr.io/{{ username }}/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}" | ||
source: "build" | ||
build: | ||
path: "." | ||
dockerfile: "Dockerfile" | ||
pull: yes | ||
args: | ||
OPENFOAM_VERSION: "{{ item.0 }}" | ||
SMARTSIM_VERSION: "{{ item.1 }}" | ||
DATABASE_BACKEND: "{{ item.2 }}" | ||
UBUNTU_VERSION: "{{ item.3 }}" | ||
loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}" | ||
when: "not (item.1 == '0.7.0' and item.3 == '20.04')" | ||
async: 1200 | ||
poll: 0 | ||
register: async_result | ||
|
||
- name: Wait for all build tasks to complete | ||
async_status: | ||
jid: "{{ item.ansible_job_id }}" | ||
loop: "{{ async_result.results }}" | ||
when: item.changed | ||
register: async_status_result | ||
until: async_status_result.finished | ||
retries: 20 | ||
delay: 60 | ||
|
||
- name: Push Docker images to GitHub Container Registry | ||
docker_image: | ||
name: "ghcr.io/ofdatacommittee/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}" | ||
source: local | ||
push: yes | ||
loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}" | ||
when: "not (item.1 == '0.7.0' and item.3 == '20.04')" |