Skip to content

Commit 7edf09f

Browse files
committed
Use more PyAnsys actions
1 parent 311a46a commit 7edf09f

File tree

1 file changed

+101
-106
lines changed

1 file changed

+101
-106
lines changed

.github/workflows/ci_cd.yml

+101-106
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ on:
1111
branches:
1212
- main
1313

14+
env:
15+
MAIN_PYTHON_VERSION: '3.10'
16+
LIBRARY_NAME: 'ansys-openapi-common'
17+
1418
jobs:
1519
code-style:
1620
name: "Code style"
1721
runs-on: windows-latest
1822
steps:
1923
- uses: ansys/actions/code-style@v5
2024
with:
21-
python-version: "3.10"
25+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
2226
skip-install: "false"
2327

24-
docs-style:
28+
doc-style:
2529
name: Documentation Style Check
2630
runs-on: ubuntu-latest
2731
steps:
@@ -30,9 +34,81 @@ jobs:
3034
with:
3135
token: ${{ secrets.GITHUB_TOKEN }}
3236

33-
test:
37+
doc-build:
38+
name: Build Documentation
39+
runs-on: ubuntu-latest
40+
needs: doc-style
41+
42+
steps:
43+
- name: "Checkout the repository"
44+
uses: actions/checkout@v4
45+
46+
- name: "Set up Python"
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
50+
51+
- name: "Install system dependencies"
52+
run: |
53+
sudo apt-get update && sudo apt-get install pandoc libkrb5-dev
54+
55+
- name: "Install Python dependencies"
56+
run: |
57+
python -m pip install --upgrade pip tox
58+
python -m pip install poetry~=1.7.0
59+
60+
- name: Install library
61+
run: |
62+
poetry install --with docs --extras "oidc linux-kerberos"
63+
64+
- name: Build HTML
65+
run: make -C doc html SPHINXOPTS="-W"
66+
67+
- name: Build PDF Documentation
68+
run: |
69+
sudo apt update
70+
sudo apt-get install -y texlive-latex-extra latexmk texlive-xetex fonts-freefont-otf xindy
71+
make -C doc latexpdf
72+
73+
- name: Upload HTML Documentation
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: documentation-html
77+
path: doc/build/html
78+
retention-days: 7
79+
80+
- name: Upload PDF Documentation
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: documentation-pdf
84+
path: doc/build/latex/*.pdf
85+
retention-days: 7
86+
87+
smoke-tests:
88+
name: "Build wheelhouse for latest Python versions"
89+
runs-on: ${{ matrix.os }}
90+
needs: code-style
91+
strategy:
92+
matrix:
93+
os: [ubuntu-latest, windows-latest]
94+
python-version: ['3.9', '3.10', '3.11', '3.12']
95+
steps:
96+
- name: Install kerberos headers
97+
if: matrix.os == "ubuntu-latest"
98+
run: |
99+
sudo apt-get update
100+
sudo apt install libkrb5-dev
101+
102+
- uses: ansys/actions/build-wheelhouse@v5
103+
with:
104+
library-name: ${{ env.LIBRARY_NAME }}
105+
operating-system: ${{ matrix.os }}
106+
python-version: ${{ matrix.python-version }}
107+
108+
tests:
34109
name: Unit test on supported platforms
35110
runs-on: ubuntu-latest
111+
needs: smoke-tests
36112
services:
37113
# Label used to access the service container
38114
kdc-server:
@@ -83,97 +159,44 @@ jobs:
83159
fail_ci_if_error: true
84160
token: ${{ secrets.CODECOV_TOKEN }}
85161

86-
build:
87-
name: Build
162+
build-library:
163+
name: "Build library"
88164
runs-on: ubuntu-latest
89-
165+
needs: [ doc-build, tests ]
90166
steps:
91-
- uses: actions/checkout@v4
92-
- name: Setup Python
93-
uses: actions/setup-python@v5
94-
with:
95-
python-version: '3.10'
96-
97167
- name: Install kerberos headers
98168
run: |
99169
sudo apt-get update
100170
sudo apt install libkrb5-dev
101171
102-
- name: Create wheel
103-
run: |
104-
pip install poetry
105-
poetry build
106-
107-
- name: Validate wheel
108-
run: |
109-
pip install twine
110-
twine check dist/*
111-
112-
- name: Upload wheel
113-
uses: actions/upload-artifact@v4
172+
- uses: ansys/actions/build-library@v5
114173
with:
115-
name: ansys-grantami-common-wheel
116-
path: dist/
117-
retention-days: 7
174+
library-name: ${{ env.LIBRARY_NAME }}
175+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
118176

119-
docs:
120-
name: Build Documentation
177+
release:
178+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
179+
needs: [build-library]
121180
runs-on: ubuntu-latest
122-
123181
steps:
124-
- uses: actions/checkout@v4
125-
- name: Setup Python
126-
uses: actions/setup-python@v5
127-
with:
128-
python-version: '3.10'
129-
130-
- name: Install kerberos headers
131-
run: |
132-
sudo apt-get update
133-
sudo apt install libkrb5-dev
134-
135-
- name: Install library
136-
run: |
137-
pip install poetry
138-
poetry config installer.modern-installation false
139-
poetry install --with docs --extras "oidc linux-kerberos"
140-
141-
- name: Build HTML
142-
run: make -C doc html SPHINXOPTS="-W"
143-
144-
- name: Build PDF Documentation
145-
run: |
146-
sudo apt update
147-
sudo apt-get install -y texlive-latex-extra latexmk texlive-xetex fonts-freefont-otf xindy
148-
make -C doc latexpdf
149-
150-
- name: Upload HTML Documentation
151-
uses: actions/upload-artifact@v4
182+
- uses: ansys/actions/release-pypi-public@v5
183+
name: "Release to public PyPI"
152184
with:
153-
name: Documentation-html
154-
path: doc/build/html
155-
retention-days: 7
185+
library-name: ${{ env.LIBRARY_NAME }}
186+
twine-username: "__token__"
187+
twine-token: ${{ secrets.PYPI_TOKEN }}
156188

157-
- name: Upload PDF Documentation
158-
uses: actions/upload-artifact@v4
189+
- uses: ansys/actions/release-github@v5
190+
name: "Release to GitHub"
159191
with:
160-
name: Documentation-pdf
161-
path: doc/build/latex/*.pdf
162-
retention-days: 7
192+
library-name: ${{ env.LIBRARY_NAME }}
163193

164-
Release:
165-
if: contains(github.ref, 'refs/tags')
166-
needs: [build, test, code-style, docs]
194+
doc-deploy-stable:
195+
name: "Deploy stable documentation"
167196
runs-on: ubuntu-latest
197+
needs: release
198+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
168199
steps:
169-
- name: Set up Python
170-
uses: actions/setup-python@v5
171-
with:
172-
python-version: '3.10'
173-
174-
- uses: actions/checkout@v4
175-
176-
# used for documentation deployment
177200
- name: Get Bot Application Token
178201
id: get_workflow_token
179202
uses: peter-murray/workflow-application-token-action@v3
@@ -183,17 +206,7 @@ jobs:
183206

184207
- uses: actions/download-artifact@v4
185208
with:
186-
name: ansys-grantami-common-wheel
187-
path: ~/dist
188-
189-
- uses: actions/download-artifact@v4
190-
with:
191-
name: Documentation-pdf
192-
path: ~/pdf
193-
194-
- uses: actions/download-artifact@v4
195-
with:
196-
name: Documentation-html
209+
name: documentation-html
197210
path: ~/html
198211

199212
- name: Deploy
@@ -204,21 +217,3 @@ jobs:
204217
BRANCH: gh-pages
205218
FOLDER: ~/html
206219
CLEAN: true
207-
208-
# note how we use the PyPI tokens
209-
- name: Upload to PyPi
210-
run: |
211-
pip install twine
212-
twine upload --non-interactive --skip-existing ~/**/*.whl
213-
env:
214-
TWINE_USERNAME: __token__
215-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
216-
217-
- name: Release
218-
uses: softprops/action-gh-release@v1
219-
with:
220-
generate_release_notes: true
221-
files: |
222-
./**/*.whl
223-
./**/*.zip
224-
./**/*.pdf

0 commit comments

Comments
 (0)