Skip to content

Commit 3d6f62c

Browse files
authored
feat: test artifacts before releasing (#709)
1 parent 63c7ef2 commit 3d6f62c

File tree

2 files changed

+149
-14
lines changed

2 files changed

+149
-14
lines changed

.github/workflows/ci_cd.yml

Lines changed: 145 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,14 @@ env:
1919
GEO_CONT_NAME: ans_geo
2020
RESET_IMAGE_CACHE: 2
2121
IS_WORKFLOW_RUNNING: True
22+
ARTIFACTORY_VERSION: v241
2223

2324
concurrency:
2425
group: ${{ github.workflow }}-${{ github.ref }}
2526
cancel-in-progress: true
2627

2728
jobs:
2829

29-
style:
30-
name: Code style
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: PyAnsys code style checks
34-
uses: ansys/actions/code-style@v4
35-
with:
36-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
37-
3830
docs-style:
3931
name: Documentation Style Check
4032
runs-on: ubuntu-latest
@@ -47,7 +39,6 @@ jobs:
4739
smoke-tests:
4840
name: Build and Smoke tests
4941
runs-on: ${{ matrix.os }}
50-
needs: [style]
5142
strategy:
5243
fail-fast: false
5344
matrix:
@@ -363,6 +354,10 @@ jobs:
363354
library-name: ${{ env.PACKAGE_NAME }}
364355
python-version: ${{ env.MAIN_PYTHON_VERSION }}
365356

357+
# =================================================================================================
358+
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
359+
# =================================================================================================
360+
366361
fetch-release-artifacts:
367362
name: Fetch release artifacts
368363
needs: [testing-windows, testing-linux, docs]
@@ -374,8 +369,8 @@ jobs:
374369
steps:
375370
- name: Download binaries
376371
run: |
377-
curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/DockerWindows.zip --output windows-binaries.zip
378-
curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/DockerLinux.zip --output linux-binaries.zip
372+
curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/${{ env.ARTIFACTORY_VERSION }}/DockerWindows.zip --output windows-binaries.zip
373+
curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/${{ env.ARTIFACTORY_VERSION }}/DockerLinux.zip --output linux-binaries.zip
379374
380375
- name: Upload Windows binaries as workflow artifacts
381376
uses: actions/upload-artifact@v3
@@ -391,10 +386,147 @@ jobs:
391386
path: linux-binaries.zip
392387
retention-days: 7
393388

389+
build-windows-container:
390+
name: Building Geometry Service - Windows
391+
runs-on: [self-hosted, Windows, pygeometry]
392+
needs: [fetch-release-artifacts]
393+
steps:
394+
- name: Checkout repository
395+
uses: actions/checkout@v4
396+
397+
- name: Set up Python
398+
uses: actions/setup-python@v4
399+
with:
400+
python-version: '3.9' # use python3.9, self-hosted has an issue with 3.10
401+
402+
- name: Download Windows binaries
403+
uses: actions/download-artifact@v3
404+
with:
405+
name: windows-binaries.zip
406+
path: docker/windows-binaries.zip
407+
408+
- name: Build Docker image
409+
working-directory: docker
410+
run: |
411+
docker build -f Dockerfile.windows -t ghcr.io/ansys/geometry:windows-latest-tmp .
412+
413+
- name: Check location of self-hosted runner and define license server accordingly
414+
if: runner.name == 'pygeometry-ci-1' || runner.name == 'pygeometry-ci-2'
415+
run:
416+
echo "ANSRV_GEO_LICENSE_SERVER=${{ secrets.INTERNAL_LICENSE_SERVER }}" | Out-File -FilePath $env:GITHUB_ENV -Append
417+
418+
- name: Launch Geometry service
419+
run: |
420+
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ghcr.io/ansys/geometry:windows-latest-tmp
421+
422+
- name: Validate connection using PyAnsys Geometry
423+
run: |
424+
python -m venv .venv
425+
.\.venv\Scripts\Activate.ps1
426+
python -m pip install --upgrade pip
427+
pip install -e .[tests]
428+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
429+
430+
- name: Restore images cache
431+
uses: actions/cache@v3
432+
with:
433+
path: .\tests\integration\image_cache
434+
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
435+
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
436+
437+
- name: Testing
438+
run: |
439+
.\.venv\Scripts\Activate.ps1
440+
pytest -v --use-existing-service=yes
441+
442+
- name: Stop the Geometry service
443+
if: always()
444+
run: |
445+
docker stop ${{ env.GEO_CONT_NAME }}
446+
docker logs ${{ env.GEO_CONT_NAME }}
447+
docker rm ${{ env.GEO_CONT_NAME }}
448+
449+
- name: Stop any remaining containers
450+
if: always()
451+
run: |
452+
$dockerContainers = docker ps -a -q
453+
if (-not [string]::IsNullOrEmpty($dockerContainers)) {
454+
docker stop $dockerContainers
455+
docker rm $dockerContainers
456+
}
457+
458+
- name: Delete the Docker images (and untagged ones)
459+
if: always()
460+
run: |
461+
docker image rm ghcr.io/ansys/geometry:windows-latest-tmp
462+
docker system prune -f
463+
464+
# =================================================================================================
465+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
466+
# =================================================================================================
467+
468+
build-linux-container:
469+
name: Building Geometry Service - Linux
470+
runs-on: ubuntu-latest
471+
needs: [fetch-release-artifacts]
472+
steps:
473+
- name: Checkout repository
474+
uses: actions/checkout@v4
475+
476+
- name: Set up Python
477+
uses: actions/setup-python@v4
478+
with:
479+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
480+
481+
- name: Download Linux binaries
482+
uses: actions/download-artifact@v3
483+
with:
484+
name: linux-binaries.zip
485+
path: docker/linux-binaries.zip
486+
487+
- name: Build Docker image
488+
working-directory: docker
489+
run: |
490+
docker build -f Dockerfile.linux -t ghcr.io/ansys/geometry:linux-latest-tmp .
491+
492+
- name: Launch Geometry service
493+
run: |
494+
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ghcr.io/ansys/geometry:linux-latest-tmp
495+
496+
- name: Validate connection using PyAnsys Geometry
497+
run: |
498+
python -m pip install --upgrade pip
499+
pip install -e .[tests]
500+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
501+
502+
- name: Restore images cache
503+
uses: actions/cache@v3
504+
with:
505+
path: .\tests\integration\image_cache
506+
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
507+
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
508+
509+
- name: Run pytest
510+
uses: ansys/actions/tests-pytest@v4
511+
env:
512+
ALLOW_PLOTTING: true
513+
with:
514+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
515+
pytest-extra-args: "--service-os=linux --use-existing-service=yes"
516+
checkout: false
517+
requires-xvfb: true
518+
519+
- name: Stop the Geometry service
520+
if: always()
521+
run: |
522+
docker stop ${{ env.GEO_CONT_NAME }}
523+
docker logs ${{ env.GEO_CONT_NAME }}
524+
docker rm ${{ env.GEO_CONT_NAME }}
525+
394526
release:
395527
name: Release project
396528
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
397-
needs: [package, fetch-release-artifacts]
529+
needs: [package, build-windows-container, build-linux-container]
398530
runs-on: ubuntu-latest
399531
steps:
400532
- name: Release to the public PyPI repository

README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PyAnsys Geometry
22
================
3-
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black|
3+
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| |pre-commit|
44

55
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
66
:target: https://docs.pyansys.com/
@@ -30,6 +30,9 @@ PyAnsys Geometry
3030
:target: https://github.com/psf/black
3131
:alt: Black
3232

33+
.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/ansys/pyansys-geometry/main.svg
34+
:target: https://results.pre-commit.ci/latest/github/ansys/pyansys-geometry/main
35+
:alt: pre-commit.ci
3336

3437
PyAnsys Geometry is a Python client library for the Ansys Geometry service.
3538

0 commit comments

Comments
 (0)