From b4202a41834838feb96daa3f50e7ba80e7cd71eb Mon Sep 17 00:00:00 2001 From: AdityaGupta716 Date: Tue, 24 Feb 2026 21:26:01 +0530 Subject: [PATCH] feat: add Docker image for CI to replace manual setup --- .github/workflows/build-docker.yml | 31 ++++++++ .github/workflows/run-adaptivity-parallel.yml | 75 +++++++++++++++++++ .github/workflows/run-adaptivity-serial.yml | 51 +++++++++++++ .../run-domain-decomposition-tests.yml | 10 +-- .github/workflows/run-dummy.yml | 70 +++++++++++++++++ .github/workflows/run-unit-tests.yml | 42 +---------- Dockerfile | 16 ++++ 7 files changed, 247 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/build-docker.yml create mode 100644 .github/workflows/run-adaptivity-parallel.yml create mode 100644 .github/workflows/run-adaptivity-serial.yml create mode 100644 .github/workflows/run-dummy.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 00000000..5c5ba676 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,31 @@ +name: Build and push CI Docker image + +on: + push: + branches: + - develop + paths: + - "Dockerfile" + - "pyproject.toml" + workflow_dispatch: + +jobs: + build-and-push: + name: Build and push Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: precice/micro-manager-ci:latest diff --git a/.github/workflows/run-adaptivity-parallel.yml b/.github/workflows/run-adaptivity-parallel.yml new file mode 100644 index 00000000..9736b128 --- /dev/null +++ b/.github/workflows/run-adaptivity-parallel.yml @@ -0,0 +1,75 @@ +name: Test adaptivity functionality in parallel +on: + push: + branches: + - main + - develop + pull_request: + branches: + - "*" +jobs: + integration_tests: + name: Integration tests + runs-on: ubuntu-latest + container: precice/micro-manager-ci:latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: micro-manager + + - name: Create a virtual environment and install Micro Manager in it + working-directory: micro-manager + run: | + python3 -m venv .venv + . .venv/bin/activate + pip install . + + - name: Run integration test with global adaptivity in parallel + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/integration/test_unit_cube/ + mpiexec -n 2 --allow-run-as-root micro-manager-precice micro-manager-config-global-adaptivity-parallel.json & + python3 unit_cube.py 2 + + unit_tests: + name: Unit tests + runs-on: ubuntu-latest + container: precice/micro-manager-ci:latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + path: micro-manager + + - name: Create a virtual environment and install Micro Manager in it + working-directory: micro-manager + run: | + python3 -m venv .venv + . .venv/bin/activate + pip install . + + - name: Run unit tests + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/unit + mpiexec -n 2 --allow-run-as-root python3 -m unittest test_adaptivity_parallel.py + + - name: Run load balancing unit tests with 2 ranks + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/unit + mpiexec -n 2 --allow-run-as-root python3 -m unittest test_global_adaptivity_lb.py + + - name: Run load balancing tests with 4 ranks + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/unit + mpiexec -n 4 --allow-run-as-root --oversubscribe python3 -m unittest test_global_adaptivity_lb.py diff --git a/.github/workflows/run-adaptivity-serial.yml b/.github/workflows/run-adaptivity-serial.yml new file mode 100644 index 00000000..1fbde3d6 --- /dev/null +++ b/.github/workflows/run-adaptivity-serial.yml @@ -0,0 +1,51 @@ +name: Test adaptivity functionality in serial +on: + push: + branches: + - main + - develop + pull_request: + branches: + - "*" +jobs: + unit_and_integration_tests: + name: Unit and integration tests + runs-on: ubuntu-latest + container: precice/micro-manager-ci:latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: micro-manager + + - name: Create a virtual environment and install the Micro Manager in it + working-directory: micro-manager + run: | + python3 -m venv .venv + . .venv/bin/activate + pip install . + + - name: Run integration test with local adaptivity + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/integration/test_unit_cube + micro-manager-precice micro-manager-config-local-adaptivity.json & + python3 unit_cube.py 2 + + - name: Run integration test with global adaptivity + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/integration/test_unit_cube + micro-manager-precice micro-manager-config-global-adaptivity.json & + python3 unit_cube.py 2 + + - name: Run adaptivity unit tests in serial + working-directory: micro-manager + run: | + . .venv/bin/activate + cd tests/unit + python3 -m unittest test_adaptivity_serial.py diff --git a/.github/workflows/run-domain-decomposition-tests.yml b/.github/workflows/run-domain-decomposition-tests.yml index 0b80ddf3..3234bd9e 100644 --- a/.github/workflows/run-domain-decomposition-tests.yml +++ b/.github/workflows/run-domain-decomposition-tests.yml @@ -11,19 +11,13 @@ jobs: unit_tests: name: Run domain decomposition unit tests runs-on: ubuntu-latest - container: precice/precice:nightly + container: precice/micro-manager-ci:latest steps: - name: Checkout Repository - uses: actions/checkout@v6 + uses: actions/checkout@v4 with: path: micro-manager - - name: Install Dependencies - working-directory: micro-manager - run: | - apt-get -qq update - apt-get -qq install python3-dev python3-venv git pkg-config - - name: Create a virtual environment and install the Micro Manager in it working-directory: micro-manager run: | diff --git a/.github/workflows/run-dummy.yml b/.github/workflows/run-dummy.yml new file mode 100644 index 00000000..9f096e07 --- /dev/null +++ b/.github/workflows/run-dummy.yml @@ -0,0 +1,70 @@ +name: Run Python and C++ dummy +on: + push: + branches: + - main + - develop + pull_request: + branches: + - "*" +jobs: + run_dummy: + name: Run dummy + runs-on: ubuntu-latest + container: precice/micro-manager-ci:latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + path: micro-manager + + - name: Create a virtual environment and install Micro Manager in it + timeout-minutes: 6 + working-directory: micro-manager + run: | + python3 -m venv .venv + . .venv/bin/activate + pip install . + + - name: Run python dummy + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd examples/ + micro-manager-precice micro-manager-python-config.json & + python3 macro_dummy.py no_adaptivity + ./clean-example.sh + + - name: Run python dummy with adaptivity + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd examples/ + micro-manager-precice micro-manager-python-adaptivity-config.json & + python3 macro_dummy.py adaptivity + ./clean-example.sh + + - name: Run C++ dummy + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd examples/cpp-dummy/ + pip install pybind11 + c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) micro_cpp_dummy.cpp -o micro_dummy$(python3-config --extension-suffix) + cd ../ + micro-manager-precice micro-manager-cpp-config.json & + python3 macro_dummy.py no_adaptivity + ./clean-example.sh + + - name: Run adaptive C++ dummy + timeout-minutes: 3 + working-directory: micro-manager + run: | + . .venv/bin/activate + cd examples/ + micro-manager-precice micro-manager-cpp-adaptivity-config.json & + python3 macro_dummy.py adaptivity + ./clean-example.sh diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index a34eded2..862506b9 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -10,50 +10,12 @@ on: jobs: unit_tests: runs-on: ubuntu-latest - container: precice/precice:nightly + container: precice/micro-manager-ci:latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 with: path: micro-manager - - name: Install dependencies - run: | - apt-get -qq update - apt-get -qq install python3-dev python3-venv git pkg-config - apt-get -qq install wget build-essential - - - name: Load Cache OpenMPI 5 - id: ompi-cache-load - uses: actions/cache/restore@v5 - with: - path: ~/openmpi - key: openmpi-v5-${{ runner.os }}-build - - - name: Build OpenMPI 5 - if: steps.ompi-cache-load.outputs.cache-hit != 'true' - run: | - wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz - tar -xzf openmpi-5.0.5.tar.gz - cd openmpi-5.0.5 - mkdir -p ~/openmpi - ./configure --prefix=$HOME/openmpi - make -j$(nproc) - make install - - - name: Save OpenMPI 5 to cache - if: steps.ompi-cache.outputs.cache-hit != 'true' - id: ompi-cache-store - uses: actions/cache/save@v5 - with: - path: ~/openmpi - key: openmpi-v5-${{ runner.os }}-build - - - name: Configure OpenMPI - run: | - cp -r ~/openmpi/* /usr/local/ - ldconfig - which mpiexec - mpiexec --version - name: Create a virtual environment and install Micro Manager in it timeout-minutes: 6 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4f22b24b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM precice/precice:nightly + +RUN apt-get -qq update && apt-get -qq install -y \ + sudo \ + python3-dev \ + python3-venv \ + git \ + pkg-config \ + pybind11-dev \ + libopenmpi-dev \ + openmpi-bin \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install mpi4py + +WORKDIR /micro-manager