-
Notifications
You must be signed in to change notification settings - Fork 14
172 lines (147 loc) · 6.05 KB
/
docker_test_build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Docker images - Test build
on:
workflow_dispatch:
pull_request:
paths:
- 'docker/**'
- '.github/workflows/docker_test_build.yml'
push:
branches:
- main
paths:
- 'docker/**'
- '.github/workflows/docker_test_build.yml'
release:
types: [published]
env:
MAIN_PYTHON_VERSION: '3.10'
ANSRV_GEO_IMAGE_WINDOWS_TAG: ghcr.io/ansys/geometry:windows-latest-tmp
ANSRV_GEO_IMAGE_LINUX_TAG: ghcr.io/ansys/geometry:linux-latest-tmp
ANSRV_GEO_PORT: 700
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
GEO_CONT_NAME: ans_geo
RESET_IMAGE_CACHE: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# =================================================================================================
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# =================================================================================================
build-windows:
name: Building Geometry Service - Windows
runs-on: [self-hosted, Windows, pygeometry]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9' # use python3.9, self-hosted has an issue with 3.10
- name: Download Windows binaries
uses: dsaltares/fetch-gh-release-asset@master
with:
version: 'latest'
file: 'windows-binaries.zip'
token: ${{ secrets.GITHUB_TOKEN }}
target: 'docker/windows-binaries.zip'
- name: Build Docker image
working-directory: docker
run: |
docker build -f Dockerfile.windows -t ${{ env.ANSRV_GEO_IMAGE_WINDOWS_TAG }} .
- name: Check location of self-hosted runner and define license server accordingly
if: runner.name == 'pygeometry-ci-1'
run:
echo "ANSRV_GEO_LICENSE_SERVER=${{ secrets.INTERNAL_LICENSE_SERVER }}" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Launch Geometry service
run: |
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_WINDOWS_TAG }}
- name: Validate connection using PyGeometry
run: |
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -e .[tests]
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
- name: Restore images cache
uses: actions/cache@v3
with:
path: .\tests\integration\image_cache
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
- name: Testing
run: |
.\.venv\Scripts\Activate.ps1
pytest -v --use-existing-service=yes
- name: Stop the Geometry service
if: always()
run: |
docker stop ${{ env.GEO_CONT_NAME }}
docker logs ${{ env.GEO_CONT_NAME }}
docker rm ${{ env.GEO_CONT_NAME }}
- name: Stop any remaining containers
if: always()
run: |
$dockerContainers = docker ps -a -q
if (-not [string]::IsNullOrEmpty($dockerContainers)) {
docker stop $dockerContainers
docker rm $dockerContainers
}
- name: Delete the Docker images (and untagged ones)
if: always()
run: |
docker image rm ${{ env.ANSRV_GEO_IMAGE_WINDOWS_TAG }}
docker system prune -f
# =================================================================================================
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# =================================================================================================
build-linux:
name: Building Geometry Service - Linux
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Download Linux binaries
uses: dsaltares/fetch-gh-release-asset@master
with:
version: 'latest'
file: 'linux-binaries.zip'
token: ${{ secrets.GITHUB_TOKEN }}
target: 'docker/linux-binaries.zip'
- name: Build Docker image
working-directory: docker
run: |
docker build -f Dockerfile.linux -t ${{ env.ANSRV_GEO_IMAGE_LINUX_TAG }} .
- name: Launch Geometry service
run: |
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_LINUX_TAG }}
- name: Validate connection using PyGeometry
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
- name: Restore images cache
uses: actions/cache@v3
with:
path: .\tests\integration\image_cache
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
- name: Run pytest
uses: ansys/actions/tests-pytest@v4
env:
ALLOW_PLOTTING: true
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
pytest-extra-args: "--service-os=linux --use-existing-service=yes"
checkout: false
requires-xvfb: true
- name: Stop the Geometry service
if: always()
run: |
docker stop ${{ env.GEO_CONT_NAME }}
docker logs ${{ env.GEO_CONT_NAME }}
docker rm ${{ env.GEO_CONT_NAME }}