Skip to content
Merged
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
135 changes: 56 additions & 79 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ env:
LIBRARY_NAME: 'ansys-stk-core'
LIBRARY_NAMESPACE: 'ansys.stk.core'
DOCUMENTATION_CNAME: 'stk.docs.pyansys.com'

STK_DOCKER_IMAGE: 'ansys/stk:latest-centos7'
LICENSE_SERVER_PORT: '1055'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -30,7 +31,7 @@ jobs:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

doc-style:
name: "Documentation style checks"
name: "Doc style checks"
runs-on: ubuntu-latest
steps:
- name: "Run code style checks"
Expand All @@ -39,7 +40,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

doc-build:
name: "Build project documentation"
name: "Doc build"
runs-on: ubuntu-latest
needs: doc-style
steps:
Expand All @@ -48,92 +49,68 @@ jobs:
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

doc-deploy-dev:
name: "Deploy developers documentation"
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main')
needs: doc-build
steps:
- name: "Deploy development documentation"
uses: pyansys/actions/doc-deploy-dev@v4
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

doc-deploy-stable:
name: "Deploy stable documentation"
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: doc-deploy-dev
steps:
- name: "Deploy stable documentation"
uses: pyansys/actions/doc-deploy-stable@v4
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

tests:
name: "Test Python ${{ matrix.cfg.python-version }} in ${{ matrix.os }} "
runs-on: ${{ matrix.os }}
needs: code-style
name: "Tests Python ${{ matrix.python }}"
runs-on: [self-hosted, pystk]
# needs: code-style
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
cfg:
- {python-version: '3.7', extra-args: ''}
- {python-version: '3.8', extra-args: ''}
- {python-version: '3.9', extra-args: ''}
- {python-version: '3.10', extra-args: '--cov=ansys.stk --cov-report=term --cov-report=html:.cov/html'}

python: ["3.8", "3.9", "3.10"]
fail-fast: false
steps:

- name: "Run test suite with pytest"
uses: pyansys/actions/tests-pytest@v4
with:
python-version: ${{ matrix.cfg.python-version }}
pytest-extra-args: ${{ matrix.cfg.extra-args }}

- name: "Upload coverage results"
uses: actions/upload-artifact@v3
if: matrix.cfg.python-version == env.MAIN_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
with:
name: coverage-html
path: .cov/html
retention-days: 7
- name: "Checkout the project"
uses: actions/checkout@v3

- name: "Generate the name of the docker image and the container"
run: |
python_image_name=${{ env.STK_DOCKER_IMAGE }}-python${{ matrix.python }}
container_name=stk-python${{ matrix.python }}
echo "STK_PYTHON_IMAGE=$python_image_name" >> $GITHUB_ENV
echo "STK_CONTAINER=$container_name" >> $GITHUB_ENV

- name: "Start the container from the desired image"
run: |
docker run \
--detach -it \
--name ${{ env.STK_CONTAINER }} \
--env ANSYSLMD_LICENSE_FILE=${{ env.LICENSE_SERVER_PORT }}@${{ secrets.LICENSE_SERVER }} \
--volume ${PWD}:/home/stk/pystk \
${{ env.STK_PYTHON_IMAGE }}

- name: "Install the project"
run: |
docker exec ${{ env.STK_CONTAINER }} /bin/bash -c \
"python -m pip install /home/stk/pystk"

- name: "Show the version of the engine"
run: |
docker exec ${{ env.STK_CONTAINER }} /bin/bash -c \
"python -c 'from ansys.stk.core.stkengine import STKEngine; print(STKEngine.StartApplication().Version)'"

- name: "Stop the container"
if: always()
run: |
docker stop ${{ env.STK_CONTAINER }}
docker logs ${{ env.STK_CONTAINER }}
docker rm ${{ env.STK_CONTAINER }}

build-library:
name: "Build library artifacts"
name: "Build library"
runs-on: ubuntu-latest
needs: [doc-deploy-stable, tests]
needs: [doc-build, tests]
steps:
- name: "Build library source and wheel artifacts"
uses: pyansys/actions/build-library@v4
- uses: pyansys/actions/build-library@v4
with:
library-name: ${{ env.LIBRARY_NAME }}

# release:
# name: "Release to private and public PyPI and to GitHub"
# if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
# runs-on: ubuntu-latest
# needs: [build-library]
# steps:

# - name: "Release to the private PyPI repository"
# uses: pyansys/actions/release-pypi-private@v1
# with:
# library-name: ${{ env.LIBRARY_NAME }}
# twine-username: "__token__"
# twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}

# - name: "Release to the public PyPI repository"
# uses: pyansys/actions/release-pypi-public@main
# with:
# library-name: ${{ env.LIBRARY_NAME }}
# twine-username: "__token__"
# twine-token: ${{ secrets.PYPI_TOKEN }}

# - name: "Release to GitHub"
# uses: pyansys/actions/release-github@main
# with:
# library-name: ${{ env.LIBRARY_NAME }}
doc-deploy-dev:
name: "Deploy dev docs"
runs-on: ubuntu-latest
needs: build-library
if: github.event_name == 'push' && contains(github.ref, 'refs/heads/main')
steps:
- uses: pyansys/actions/doc-deploy-dev@v4
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,6 @@ cython_debug/
#.idea/

# End of https://www.toptal.com/developers/gitignore/api/python

# Ignore any distributions directory to prevent accidental publications
distributions/
63 changes: 63 additions & 0 deletions docker/linux/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: '3.8'
services:

stk:
image: ansys/stk:latest-centos7
container_name: stk
build:
context: ./stk-engine
args:
baseImage: centos:7
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE

stk-pybase:
image: ansys/stk:latest-centos7-pybase
depends_on:
- stk
container_name: stk-pybase
build:
context: ./stk-engine-pybase
args:
baseImage: ansys/stk:latest-centos7
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE

stk-python3.8:
image: ansys/stk:latest-centos7-python3.8
depends_on:
- stk-pybase
container_name: stk-python3.8
build:
context: ./stk-engine-py38
args:
baseImage: ansys/stk:latest-centos7
basePythonImage: ansys/stk:latest-centos7-pybase
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE

stk-python3.9:
image: ansys/stk:latest-centos7-python3.9
depends_on:
- stk-pybase
container_name: stk-python3.9
build:
context: ./stk-engine-py39
args:
baseImage: ansys/stk:latest-centos7
basePythonImage: ansys/stk:latest-centos7-pybase
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE

stk-python3.10:
image: ansys/stk:latest-centos7-python3.10
depends_on:
- stk-pybase
container_name: stk-python3.10
build:
context: ./stk-engine-py310
args:
baseImage: ansys/stk:latest-centos7
basePythonImage: ansys/stk:latest-centos7-pybase
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE
44 changes: 44 additions & 0 deletions docker/linux/stk-engine-py310/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# By default, start from the base STK Engine Python image
ARG baseImage=ansys/stk:latest-centos7
ARG basePythonImage=ansys/stk:latest-centos7-pybase
FROM ${basePythonImage} as builder

##############################################
# 1) Build Python into its own builder stage
##############################################

# Install Python 3.10 and create a symbolic link named "python".
# This overrides the default Python 2.7 in CentOS7.
USER root
RUN cd /tmp && \
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz && \
tar xzf Python-3.10.10.tgz && \
cd Python-3.10.10 && \
./configure --enable-optimizations && \
make altinstall

#############################################################
# 2) Copy the Python build to the system in the second stage
#############################################################

# Switch back to non-root user
FROM ${baseImage}
USER root

# Copy the Python interpreter, the standard library and pip to the final image
COPY --from=builder /usr/local/bin/python3.10 /usr/local/bin/python3.10
COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
COPY --from=builder /usr/local/bin/pip3.10 /usr/local/bin/pip3.10

RUN ln -sfn /usr/local/bin/python3.10 /usr/bin/python && \
ln -sfn /usr/local/bin/pip3.10 /usr/bin/pip

# Switch back to non-root user
USER stk

# Update the path to include Python executables
ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \
PIP_DEFAULT_TIMEOUT=600 \
PIP_RETRY=50

ENTRYPOINT [ "python3.10" ]
12 changes: 12 additions & 0 deletions docker/linux/stk-engine-py310/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'
services:
stk-python3.10:
image: ansys/stk:latest-centos7-python3.10
container_name: stk-python3.10
build:
context: .
args:
baseImage: ansys/stk:latest-centos7
basePythonImage: ansys/stk:latest-centos7-pybase
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE
44 changes: 44 additions & 0 deletions docker/linux/stk-engine-py38/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# By default, start from the base STK Engine Python image
ARG baseImage=ansys/stk:latest-centos7
ARG basePythonImage=ansys/stk:latest-centos7-pybase
FROM ${basePythonImage} as builder

##############################################
# 1) Build Python into its own builder stage
##############################################

# Install Python 3.8 and create a symbolic link named "python".
# This overrides the default Python 2.7 in CentOS7.
USER root
RUN cd /tmp && \
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz && \
tar xzf Python-3.8.16.tgz && \
cd Python-3.8.16 && \
./configure --enable-optimizations && \
make altinstall

#############################################################
# 2) Copy the Python build to the system in the second stage
#############################################################

# Switch back to non-root user
FROM ${baseImage}
USER root

# Copy the Python interpreter, the standard library and pip to the final image
COPY --from=builder /usr/local/bin/python3.8 /usr/local/bin/python3.8
COPY --from=builder /usr/local/lib/python3.8 /usr/local/lib/python3.8
COPY --from=builder /usr/local/bin/pip3.8 /usr/local/bin/pip3.8

RUN ln -sfn /usr/local/bin/python3.8 /usr/bin/python && \
ln -sfn /usr/local/bin/pip3.8 /usr/bin/pip

# Switch back to non-root user
USER stk

# Update the path to include Python executables
ENV PATH="${STK_USER_HOME}/.local/bin:${PATH}" \
PIP_DEFAULT_TIMEOUT=600 \
PIP_RETRY=50

ENTRYPOINT [ "python3.8" ]
14 changes: 14 additions & 0 deletions docker/linux/stk-engine-py38/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'
services:
stk-python3.8:
image: ansys/stk:latest-centos7-python3.8
container_name: stk-python3.8
build:
context: .
args:
baseImage: ansys/stk:latest-centos7
basePythonImage: ansys/stk:latest-centos7-pybase
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE
environment:
- ANSYSLMD_LICENSE_FILE=$ANSYSLMD_LICENSE_FILE
Loading