Skip to content

Commit f4cf179

Browse files
jorgepilotoRobPasMuewenhuiuy
authored
CI: improve workflow (#186)
* CI: improve * CI: improve * CI: improve * CI: improve * Update .github/workflows/ci_cd.yml --------- Co-authored-by: Roberto Pastor Muela <[email protected]> Co-authored-by: wenhuiuy <[email protected]>
1 parent 4ad8db0 commit f4cf179

File tree

1 file changed

+57
-60
lines changed

1 file changed

+57
-60
lines changed

.github/workflows/ci_cd.yml

Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: GitHub CI
1+
name: CI
22
on:
33
pull_request:
44
workflow_dispatch:
@@ -20,44 +20,55 @@ concurrency:
2020

2121
jobs:
2222

23-
docs-style:
24-
name: Documentation Style Check
23+
code-style:
24+
name: "Code style"
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: ansys/actions/code-style@v4
28+
with:
29+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
30+
31+
doc-style:
32+
name: "Documentation style"
2533
runs-on: ubuntu-latest
2634
steps:
2735
- name: PyAnsys documentation style checks
2836
uses: ansys/actions/doc-style@v4
2937
with:
3038
token: ${{ secrets.GITHUB_TOKEN }}
3139

32-
docs:
33-
name: Documentation
40+
doc:
41+
name: "Documentation build"
3442
runs-on: ubuntu-latest
35-
needs: [docs-style]
43+
needs: [doc-style]
3644
steps:
37-
- uses: actions/checkout@v3
45+
- name: "Checkout project"
46+
uses: actions/checkout@v3
3847

39-
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
48+
- name: "Set up Python ${{ env.MAIN_PYTHON_VERSION }}"
4049
uses: actions/setup-python@v4
4150
with:
4251
python-version: ${{ env.MAIN_PYTHON_VERSION }}
4352
cache: 'pip'
4453
cache-dependency-path: 'pyproject.toml'
4554

46-
- name: Install packages for documentation build
55+
- name: "Install system dependencies"
4756
run: |
4857
sudo apt-get update
4958
sudo apt-get install xvfb pandoc texlive-latex-extra latexmk
50-
pip install --upgrade build
51-
pip install .[doc]
5259
53-
- name: Login to GitHub Container Registry
60+
- name: "Install python dependencies"
61+
run: |
62+
python -m pip install .[doc]
63+
64+
- name: "Login to GitHub container registry"
5465
uses: docker/login-action@v2
5566
with:
5667
registry: ghcr.io
5768
username: ${{ github.actor }}
5869
password: ${{ secrets.GITHUB_TOKEN }}
5970

60-
- name: DPF server activation
71+
- name: "Install and run DPF server"
6172
run: |
6273
docker pull ghcr.io/ansys/dpf-core:22.2dev
6374
docker run -d --name dpfserver -p 50054:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port 50054."
@@ -67,22 +78,22 @@ jobs:
6778
docker pull ghcr.io/ansys/ls-pre:latest
6879
docker run -d --name kw_server -p 50051:50051 ghcr.io/ansys/ls-pre:latest && echo "Keyword server active on port 50051."
6980
70-
- name: Build the documentation (HTML)
81+
- name: "Build the html documentation"
7182
run: |
7283
xvfb-run make -C doc html
7384
74-
- name: Build the documentation (PDF)
85+
- name: "Build the pdf documentation"
7586
run: |
7687
make -C doc pdf
7788
78-
- name: Upload HTML documentation
89+
- name: "Upload html documentation"
7990
uses: actions/upload-artifact@v3
8091
with:
8192
name: documentation-html
8293
path: doc/_build/html
8394
retention-days: 7
8495

85-
- name: Upload PDF documentation
96+
- name: "Upload pdf documentation"
8697
uses: actions/upload-artifact@v3
8798
with:
8899
name: documentation-pdf
@@ -94,7 +105,7 @@ jobs:
94105
run: |
95106
docker logs kw_server > server_output.txt
96107
97-
- name: Upload the server logs
108+
- name: "Upload the server logs"
98109
if: always()
99110
uses: actions/upload-artifact@v3
100111
with:
@@ -107,137 +118,123 @@ jobs:
107118
docker logs dpfserver
108119
docker stop dpfserver
109120
110-
style:
111-
name: Code style
112-
runs-on: ubuntu-latest
113-
steps:
114-
- name: PyAnsys code style checks
115-
uses: ansys/actions/code-style@v4
116-
with:
117-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
118-
119121
smoke-tests:
120-
name: Build and Smoke tests
122+
name: "Build wheelhouse for ${{ matrix.os }} and Python ${{ matrix.python-version }}"
121123
runs-on: ${{ matrix.os }}
122-
needs: [style]
124+
needs: [code-style]
123125
strategy:
124126
fail-fast: false
125127
matrix:
126128
os: [windows-latest, ubuntu-latest]
127-
python-version: ['3.7', '3.8', '3.9', '3.10'] #, '3.11'] # --> At some point we should include Py3.11
128-
129+
python-version: ['3.7', '3.8', '3.9', '3.10']
129130
steps:
130-
- name: Build wheelhouse and perform smoke test
131-
uses: ansys/actions/build-wheelhouse@v4
131+
- uses: ansys/actions/build-wheelhouse@v4
132132
with:
133133
library-name: ${{ env.PACKAGE_NAME }}
134134
library-namespace: ${{ env.PACKAGE_NAMESPACE }}
135135
operating-system: ${{ matrix.os }}
136136
python-version: ${{ matrix.python-version }}
137137

138138
tests:
139-
name: Testing
139+
name: "Testing"
140140
runs-on: ubuntu-latest
141141
needs: [smoke-tests]
142142
steps:
143-
- name: Checkout repository
143+
- name: "Checkout repository"
144144
uses: actions/checkout@v3
145145

146-
- name: Set up Python
146+
- name: "Set up Python"
147147
uses: actions/setup-python@v4
148148
with:
149149
python-version: ${{ env.MAIN_PYTHON_VERSION }}
150150
cache: 'pip'
151151
cache-dependency-path: 'pyproject.toml'
152152

153-
- name: Login to GitHub Container Registry
153+
- name: "Login to GitHub container registry"
154154
uses: docker/login-action@v2
155155
with:
156156
registry: ghcr.io
157157
username: ${{ github.actor }}
158158
password: ${{ secrets.GITHUB_TOKEN }}
159159

160-
- name: LS-DYNA Keyword server activation
160+
- name: "Pull and start LS-DYNA keyword server"
161161
run: |
162162
docker pull ghcr.io/ansys/ls-pre:latest
163163
docker run -d --name kw_server -p 50051:50051 ghcr.io/ansys/ls-pre:latest && echo "Keyword server active on port 50051."
164164
165-
- name: Install ansys-dyna-core (with test requirements)
165+
- name: "Install package dependencies"
166166
run: |
167167
pip install -e .[tests]
168168
169-
- name: Run tests
169+
- name: "Run tests"
170170
run: |
171171
pytest
172172
173-
- name: Extract the server logs
173+
- name: "Extract the server logs"
174174
if: always()
175175
run: |
176176
docker logs kw_server > server_output.txt
177177
178-
- name: Upload the server logs
178+
- name: "Upload the server logs"
179179
if: always()
180180
uses: actions/upload-artifact@v3
181181
with:
182182
name: server_output.txt
183183
path: server_output.txt
184184

185-
- name: Upload coverage results
185+
- name: "Upload coverage results"
186186
uses: actions/upload-artifact@v3
187187
with:
188188
name: coverage-html
189189
path: .cov/html
190190
retention-days: 7
191191

192-
package:
193-
name: Package library
194-
needs: [docs, tests]
192+
build-library:
193+
name: "Build library"
194+
needs: [doc, tests]
195195
runs-on: ubuntu-latest
196196
steps:
197-
- name: Build library source and wheel artifacts
198-
uses: ansys/actions/build-library@v4
197+
- uses: ansys/actions/build-library@v4
199198
with:
200199
library-name: ${{ env.PACKAGE_NAME }}
201200
python-version: ${{ env.MAIN_PYTHON_VERSION }}
202201

203202
release:
204203
name: Release project
205204
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
206-
needs: [package]
205+
needs: [build-library]
207206
runs-on: ubuntu-latest
208207
steps:
209-
- name: Release to the private PyPI repository
208+
- name: "Release to the private PyPI repository"
210209
uses: ansys/actions/release-pypi-private@v4
211210
with:
212211
library-name: ${{ env.PACKAGE_NAME }}
213212
twine-username: "__token__"
214213
twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}
215214

216-
- name: Release to GitHub
215+
- name: "Release to GitHub"
217216
uses: ansys/actions/release-github@v4
218217
with:
219218
library-name: ${{ env.PACKAGE_NAME }}
220219

221-
upload_dev_docs:
222-
name: Upload dev documentation
220+
doc-deploy-dev:
221+
name: "Deploy development documentation"
223222
if: github.ref == 'refs/heads/main'
224223
runs-on: ubuntu-latest
225-
needs: [package]
224+
needs: [build-library]
226225
steps:
227-
- name: Deploy the latest documentation
228-
uses: ansys/actions/doc-deploy-dev@v4
226+
- uses: ansys/actions/doc-deploy-dev@v4
229227
with:
230228
cname: ${{ env.DOCUMENTATION_CNAME }}
231229
token: ${{ secrets.GITHUB_TOKEN }}
232230

233-
upload_docs_release:
234-
name: Upload release documentation
231+
doc-deploy-stable:
232+
name: "Deploy stable documentation"
235233
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
236234
runs-on: ubuntu-latest
237235
needs: [release]
238236
steps:
239-
- name: Deploy the stable documentation
240-
uses: ansys/actions/doc-deploy-stable@v4
237+
- uses: ansys/actions/doc-deploy-stable@v4
241238
with:
242239
cname: ${{ env.DOCUMENTATION_CNAME }}
243240
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)