Skip to content

ci: Reduce image size testing [skip tests] #4194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 63 additions & 15 deletions .github/workflows/test-podman-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_TIMEOUT_FORCE_EXIT: 30
PYFLUENT_LAUNCH_CONTAINER: 1
PYFLUENT_USE_PODMAN_COMPOSE: 1
# PYFLUENT_USE_PODMAN_COMPOSE: 1
PYFLUENT_LOGGING: "DEBUG"
PYFLUENT_WATCHDOG_DEBUG: "OFF"
PYFLUENT_HIDE_LOG_SECRETS: 1
Expand All @@ -40,8 +40,8 @@ jobs:
fail-fast: false
matrix:
include:
- image-tag: v25.2.0
version: 252
- image-tag: v26.1.0
version: 261

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -85,26 +85,74 @@ jobs:
docker pull ghcr.io/ansys/pyfluent:${{ matrix.image-tag }}
docker images

- name: Transport docker image to podman
- name: Size of the original image
run: |
sudo podman pull docker-daemon:ghcr.io/ansys/pyfluent:${{ matrix.image-tag }}
sudo podman images
docker images ghcr.io/ansys/pyfluent:${{ matrix.image-tag }}

- name: Run API codegen
run: make api-codegen
- name: Create reduced image
run: |
# Create and start a container from the original image
docker run -it -d --name ${{ matrix.version }}-container -e ANSYSLMD_LICENSE_FILE="$ANSYSLMD_LICENSE_FILE" ghcr.io/ansys/pyfluent:${{ matrix.image-tag }} 3ddp -gu

# Delete unwanted files from the container
docker exec ${{ matrix.version }}-container rm -rf ansys_inc/v261/FluidsOne

# Stop the container
docker stop ${{ matrix.version }}-container

# Export the container's filesystem as a tarball
docker export ${{ matrix.version }}-container > new_${{ matrix.version }}.tar

# Import the tarball as a new image
cat new_${{ matrix.version }}.tar | docker import - ${{ matrix.version }}_reduced:${{ matrix.image-tag }}

- name: Clean up
run: |
docker rm ${{ matrix.version }}-container
docker rmi ghcr.io/ansys/pyfluent:${{ matrix.image-tag }}
rm new_${{ matrix.version }}.tar

- name: Print Fluent version info
- name: Verify reduced image
run: |
cat src/ansys/fluent/core/generated/fluent_version_${{ matrix.version }}.py
docker images ${{ matrix.version }}_reduced:${{ matrix.image-tag }}

- name: Install again after codegen
- name: Run solver container from the new reduced image
run: |
rm -rf dist
make install > /dev/null
docker run -it -d --name ${{ matrix.version }}-reduced-container-solver -e ANSYSLMD_LICENSE_FILE="$ANSYSLMD_LICENSE_FILE" ${{ matrix.version }}_reduced:${{ matrix.image-tag }} 3ddp -gu
docker exec ${{ matrix.version }}-reduced-container-solver ls -l /ansys_inc/v261/FluidsOne
docker stop ${{ matrix.version }}-reduced-container-solver
docker rm ${{ matrix.version }}-reduced-container-solver

- name: Run Fluent test script
- name: Run meshing container from the new reduced image
run: |
python tests/podman_compose.py
docker run -it -d --name ${{ matrix.version }}-reduced-container-meshing -e ANSYSLMD_LICENSE_FILE="$ANSYSLMD_LICENSE_FILE" ${{ matrix.version }}_reduced:${{ matrix.image-tag }} 3ddp -gu -meshing
docker stop ${{ matrix.version }}-reduced-container-meshing
docker rm ${{ matrix.version }}-reduced-container-meshing

- name: Run reduced image test script
run: |
python tests/verify_reduced_image.py

# - name: Transport docker image to podman
# run: |
# sudo podman pull docker-daemon:ghcr.io/ansys/pyfluent:${{ matrix.image-tag }}
# sudo podman images

# - name: Run API codegen
# run: make api-codegen

# - name: Print Fluent version info
# run: |
# cat src/ansys/fluent/core/generated/fluent_version_${{ matrix.version }}.py

# - name: Install again after codegen
# run: |
# rm -rf dist
# make install > /dev/null

# - name: Run Fluent test script
# run: |
# python tests/podman_compose.py

- name: Cleanup previous containers
if: always()
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/4194.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce image size testing [skip tests]
41 changes: 41 additions & 0 deletions tests/verify_reduced_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Verify reduced image."""


import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples
from ansys.fluent.core.utils.networking import get_free_port

port_1 = get_free_port()
port_2 = get_free_port()
container_dict = {
"fluent_image": "261_reduced:v26.1.0",
"ports": {f"{port_1}": port_1, f"{port_2}": port_2},
}

solver = pyfluent.launch_fluent(container_dict=container_dict)
assert len(solver._container.ports) == 2
case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
solver.file.read(file_name=case_file_name, file_type="case")
solver.exit()
Loading