-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (176 loc) · 6.21 KB
/
ci_cd.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: GitHub CI
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
- release/*
env:
PYMECHANICAL_PORT: 10000 # default won't work on GitHub runners
PYMECHANICAL_START_INSTANCE: FALSE
DOCKER_PACKAGE: ghcr.io/ansys/mechanical
DOCKER_IMAGE_VERSION: 23.2.0
DOCKER_MECH_CONTAINER_NAME: mechanical
MAIN_PYTHON_VERSION: '3.10'
PACKAGE_NAME: ansys-mechanical-stubs
PACKAGE_NAMESPACE: ansys.mechanical.stubs
DOCUMENTATION_CNAME: scripting.mechanical.docs.pyansys.com
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
style:
name: Code style
runs-on: ubuntu-latest
steps:
- name: PyAnsys code style checks
uses: ansys/actions/code-style@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
doc-style:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: ansys/actions/doc-style@v4
with:
vale-config: package/doc/.vale.ini
token: ${{ secrets.GITHUB_TOKEN }}
doc-build:
name: Create docstrings
needs: [style, doc-style]
runs-on: ubuntu-latest
container:
image: ghcr.io/ansys/mechanical:23.2.0
options: --entrypoint /bin/bash
strategy:
matrix:
python-version: ['3.9']
steps:
- name: Install Git and checkout project
uses: actions/checkout@v3
- name: Install dependencies
run: |
apt update
apt install --reinstall ca-certificates
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa -y
apt install python${{ matrix.python-version }} -y
ln -s /usr/bin/python${{ matrix.python-version }} /usr/bin/python
apt install python${{ matrix.python-version }}-venv -y
python -m ensurepip --default-pip
pip install --upgrade pip
python --version
pip --version
apt update
apt install -y lsb-release
apt install -y mono-complete
apt install -y make
apt-get install -y zip
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools
pip install --upgrade pip flit pytz tzdata
cd package
mkdir -p src/ansys/mechanical/stubs
touch src/ansys/mechanical/stubs/__init__.py
pip install -e .[doc]
- name: Run main.py
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSCL232_DIR: /install/ansys_inc/v232/licensingclient
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
AWP_ROOTDV_DEV: /install/ansys_inc/v232
NUM_CORES: 1
run: |
pip install ansys-pythonnet
python main.py > results.txt
continue-on-error: True
- name: Check main.py results
run: |
cat results.txt
# Check if failure occurred
output=$(grep -c "Done processing all mechanical stubs" results.txt)
if [ $output -eq 1 ]; then
echo "All mechanical stubs were created"
exit 0
else
echo "There was an issue creating the mechanical stubs"
exit 1
fi
- name: Retrieve Mechanial version
run: |
cd package
pip install -e .
echo "MECHANICAL_VERSION=$(python -c 'from ansys.mechanical.stubs import __version__; print(__version__)')" >> $GITHUB_ENV
echo "Mechanical version is: $(python -c "from ansys.mechanical.stubs import __version__; print(__version__)")"
- name: Install build and twine, and build dist artifacts
run: |
cd package
python -m pip install .[package]
python -m pip install build twine
python -m build && python -m twine check dist/*
- name: "Upload distribution artifacts to GitHub artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-artifacts
path: package/dist/
retention-days: 7
- name: Install package and create wheelhouse
run: |
cd package
python -m pip install .[package]
python -m pip install importlib-metadata
python -m pip wheel .[package] -w wheelhouse
- name: "Compress the wheelhouse"
uses: vimtor/[email protected]
with:
files: package/wheelhouse
dest: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-ubuntu-latest-${{ matrix.python-version }}.zip
- name: "Upload the wheelhouse files"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-ubuntu-latest-${{ matrix.python-version }}
path: package/wheelhouse/*
retention-days: 7
- name: Create Sphinx documentation
run: |
apt-get install git -y
make -C package/doc html
- name: Generate needed files for deploying pages
run: |
touch package/doc/_build/html/.nojekyll
echo ${{ env.DOCUMENTATION_CNAME }} >> package/doc/_build/html/CNAME
- name: Upload HTML Documentation
uses: actions/upload-artifact@v3
with:
name: documentation-html
path: package/doc/_build/html
retention-days: 7
doc-deploy:
name: Documentation deploy
runs-on: ubuntu-latest
needs: [doc-build]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: documentation-html
path: documentation-html
- name: List all files
run: ls -R .
- name: Deploy to GitHub Pages
if: contains(github.ref, 'refs/heads/main')
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: documentation-html/
clean: true
single-commit: true