From 4ef6bd998c9074743ee0384570f94efd63addcd5 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Mon, 13 Jun 2022 14:27:15 +0530 Subject: [PATCH 1/2] Support both tags of docker image --- .ci/pull_fluent_image.py | 5 ++++- .github/workflows/ci.yml | 23 +++++++++++++++++++---- .github/workflows/nightly-doc-build.yml | 6 ++++++ codegen/tuigen.py | 3 ++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.ci/pull_fluent_image.py b/.ci/pull_fluent_image.py index 05f0f4d313d0..3fc1d1fa379c 100644 --- a/.ci/pull_fluent_image.py +++ b/.ci/pull_fluent_image.py @@ -1,6 +1,9 @@ +import os + import docker -_IMAGE_NAME = "ghcr.io/pyansys/pyfluent:latest" +_IMAGE_TAG = os.getenv("FLUENT_IMAGE_TAG", "latest") +_IMAGE_NAME = f"ghcr.io/pyansys/pyfluent:{_IMAGE_TAG}" def _is_newer_version_available(client: docker.DockerClient): diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37fa406fb86b..0b057ac172d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ env: # You should go up in number, if you go down (or repeat a previous value) # you might end up reusing a previous cache if it haven't been deleted already. # It applies 7 days retention policy by default. - RESET_EXAMPLES_CACHE: 3 + RESET_EXAMPLES_CACHE: 4 jobs: stylecheck: @@ -93,6 +93,9 @@ jobs: docs_build: name: Build Documentation runs-on: self-hosted + strategy: + matrix: + image-tag: [latest, solver-latest] steps: - uses: actions/checkout@v3 @@ -136,6 +139,8 @@ jobs: - name: Pull Fluent docker image run: make docker-pull + env: + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Retrieve PyFluent version run: | @@ -149,6 +154,7 @@ jobs: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 PYFLUENT_LAUNCH_CONTAINER: 1 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Cache examples uses: actions/cache@v3 @@ -163,16 +169,17 @@ jobs: env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Upload HTML Documentation uses: actions/upload-artifact@v3 with: - name: HTML-Documentation + name: HTML-Documentation-tag-${{ matrix.image-tag }} path: doc/_build/html retention-days: 7 - name: Deploy - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') && ${{ matrix.image-tag == 'latest'}} uses: JamesIves/github-pages-deploy-action@4.1.4 with: repository-name: pyansys/pyfluent-docs @@ -185,6 +192,9 @@ jobs: name: Build and Unit Testing needs: test-import runs-on: self-hosted + strategy: + matrix: + image-tag: [latest, solver-latest] steps: - uses: actions/checkout@v3 @@ -217,6 +227,8 @@ jobs: - name: Pull Fluent docker image run: make docker-pull + env: + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Run API codegen run: make api-codegen @@ -224,6 +236,7 @@ jobs: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 PYFLUENT_LAUNCH_CONTAINER: 1 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Install again after codegen run: | @@ -235,11 +248,12 @@ jobs: env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Upload Coverage Results uses: actions/upload-artifact@v3 with: - name: HTML-Coverage + name: HTML-Coverage-tag-${{ matrix.image-tag }} path: cov_html retention-days: 7 @@ -249,6 +263,7 @@ jobs: twine check dist/* - name: Upload package + if: ${{ matrix.image-tag == 'latest'}} uses: actions/upload-artifact@v3 with: name: PyFluent-packages diff --git a/.github/workflows/nightly-doc-build.yml b/.github/workflows/nightly-doc-build.yml index 3c01435a9ea3..61760e992f3f 100644 --- a/.github/workflows/nightly-doc-build.yml +++ b/.github/workflows/nightly-doc-build.yml @@ -8,6 +8,9 @@ on: jobs: nightly_docs_build: runs-on: self-hosted + strategy: + matrix: + image-tag: [latest, solver-latest] steps: - uses: actions/checkout@v3 @@ -49,14 +52,17 @@ jobs: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 PYFLUENT_LAUNCH_CONTAINER: 1 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Build Documentation run: make build-doc DOCS_CNAME=dev.fluentdocs.pyansys.com env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} PYFLUENT_START_INSTANCE: 0 + FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Deploy + if: ${{ matrix.image-tag == 'latest'}} uses: JamesIves/github-pages-deploy-action@4.1.4 with: repository-name: pyansys/pyfluent-dev-docs diff --git a/codegen/tuigen.py b/codegen/tuigen.py index ecd0fea1cf3b..c6700f7b076f 100644 --- a/codegen/tuigen.py +++ b/codegen/tuigen.py @@ -92,7 +92,8 @@ ) _XML_HELPSTRINGS = {} -_FLUENT_IMAGE_NAME = "ghcr.io/pyansys/pyfluent:latest" +_FLUENT_IMAGE_TAG = os.getenv("FLUENT_IMAGE_TAG", "latest") +_FLUENT_IMAGE_NAME = f"ghcr.io/pyansys/pyfluent:{_FLUENT_IMAGE_TAG}" def _copy_tui_help_xml_file(): From 50ab601407034280c8b4ef0d8519515e88323193 Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Mon, 13 Jun 2022 16:05:24 +0530 Subject: [PATCH 2/2] Cache API code --- .github/workflows/ci.yml | 57 +++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b057ac172d7..54b4ecde0428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ env: # you might end up reusing a previous cache if it haven't been deleted already. # It applies 7 days retention policy by default. RESET_EXAMPLES_CACHE: 4 + API_CODE_CACHE: 0 jobs: stylecheck: @@ -130,7 +131,27 @@ jobs: - name: Install pyfluent run: make install + - name: Retrieve PyFluent version + run: | + echo "::set-output name=PYFLUENT_VERSION::$(python -c "from ansys.fluent.core import __version__; print(__version__)")" + echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")" + id: version + + - name: Cache API Code + uses: actions/cache@v3 + id: cache-api-code + with: + path: + src/ansys/fluent/core/datamodel + src/ansys/fluent/core/fluent_version.py + src/ansys/fluent/core/meshing/tui.py + src/ansys/fluent/core/solver/settings + src/ansys/fluent/core/solver/tui.py + key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }}-${{ github.sha }} + restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }} + - name: Login to GitHub Container Registry + if: steps.cache-api-code.outputs.cache-hit != 'true' uses: docker/login-action@v1 with: registry: ghcr.io @@ -138,17 +159,13 @@ jobs: password: ${{ secrets.REPO_DOWNLOAD_PAT }} - name: Pull Fluent docker image + if: steps.cache-api-code.outputs.cache-hit != 'true' run: make docker-pull env: FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - - name: Retrieve PyFluent version - run: | - echo "::set-output name=PYFLUENT_VERSION::$(python -c "from ansys.fluent.core import __version__; print(__version__)")" - echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")" - id: version - - name: Run API codegen + if: steps.cache-api-code.outputs.cache-hit != 'true' run: make api-codegen env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} @@ -160,9 +177,9 @@ jobs: uses: actions/cache@v3 with: path: doc/source/examples - key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ hashFiles('examples/**') }}-${{ github.sha }} + key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('examples/**') }}-${{ github.sha }} restore-keys: | - Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ hashFiles('examples/**') }} + Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('examples/**') }} - name: Build Documentation run: make build-doc DOCS_CNAME=fluentdocs.pyansys.com @@ -218,19 +235,41 @@ jobs: - name: Install pyfluent run: make install + - name: Retrieve PyFluent version + run: | + echo "::set-output name=PYFLUENT_VERSION::$(python -c "from ansys.fluent.core import __version__; print(__version__)")" + echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")" + id: version + + - name: Cache API Code + uses: actions/cache@v3 + id: cache-api-code + with: + path: + src/ansys/fluent/core/datamodel + src/ansys/fluent/core/fluent_version.py + src/ansys/fluent/core/meshing/tui.py + src/ansys/fluent/core/solver/settings + src/ansys/fluent/core/solver/tui.py + key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }}-${{ github.sha }} + restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }} + - name: Login to GitHub Container Registry + if: steps.cache-api-code.outputs.cache-hit != 'true' uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ secrets.GH_USERNAME }} password: ${{ secrets.REPO_DOWNLOAD_PAT }} - - name: Pull Fluent docker image + - name: Pull Fluent docker image\ + if: steps.cache-api-code.outputs.cache-hit != 'true' run: make docker-pull env: FLUENT_IMAGE_TAG: ${{ matrix.image-tag }} - name: Run API codegen + if: steps.cache-api-code.outputs.cache-hit != 'true' run: make api-codegen env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}