-
Notifications
You must be signed in to change notification settings - Fork 0
261 lines (239 loc) · 8.18 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# check spelling, codestyle
name: GitHub CI
# run only on main branch. This avoids duplicated actions on PRs
on:
pull_request:
push:
tags:
- "*"
branches:
- main
workflow_dispatch:
env:
PYTHON_VERSION: '3.12'
DOCUMENTATION_CNAME: 'filetransfer-server.tools.docs.pyansys.com'
PACKAGE_NAME: 'ansys-tools-filetransfer-server'
jobs:
style:
name: Pre-commit Check
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build and run pre-commit hooks via docker
run: |
docker build -f docker/Dockerfile --target precommit --tag filetransfer-precommit .
docker run filetransfer-precommit
env:
DOCKER_BUILDKIT: '1'
build:
name: Compile and Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
conan_config: linux_x86_64_Release
- os: windows-2019
conan_config: windows_x86_64_Release
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/cache@v4
name: Pip cache
with:
path: ${{ startsWith(runner.os, 'Linux') && '~/.cache/pip' || '~\AppData\Local\pip\Cache' }}
key: ${{ runner.os }}-pip-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dev dependencies
run: |
pip install -U poetry
poetry install
- name: Run Conan and build with CMake
run: |
poetry run conan install -of build --build missing --profile:host=./conan/${{ matrix.conan_config }} --profile:build=./conan/${{ matrix.conan_config }} ./conan
cmake -B build . -DCMAKE_TOOLCHAIN_FILE='build/conan_toolchain.cmake' -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
- name: Run tests
run: |
ctest --output-on-failure -V
working-directory: build
docs:
name: Documentation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/cache@v4
name: Pip cache
with:
path: ${{ startsWith(runner.os, 'Linux') && '~/.cache/pip' || '~\AppData\Local\pip\Cache' }}
key: ${{ runner.os }}-pip-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dev dependencies
run: |
pip install -U poetry
poetry install
- name: "Install OS packages for docs"
run: |
sudo apt-get install doxygen
- name: Build documentation
run: |
poetry run make -C doc html
- name: "Upload HTML Documentation"
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: doc/_build/html
retention-days: 7
- name: "Install OS packages for PDF docs"
run: |
sudo apt-get install latexmk texlive-latex-extra
- name: Generate the PDF documentation
run: poetry run make -C doc latexpdf
- name: "Upload PDF Documentation"
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/_build/latex/ansys-tools-filetransfer-server.pdf
retention-days: 7
docker-build:
name: Build and publish Docker container
needs: [style, build] # run only for successful build
runs-on: ubuntu-22.04
env:
REGISTRY: ghcr.io
IMAGE_OWNER: ansys
IMAGE_NAME_BASE: tools-filetransfer
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set the current date as build date
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Verify conditions for building and pushing the image
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "IS_A_RELEASE=true" >> $GITHUB_ENV
else
echo "IS_A_RELEASE=false" >> $GITHUB_ENV
fi
- name: Build image and export to GHCR
uses: docker/build-push-action@v6
if: env.IS_A_RELEASE == 'false'
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
target: app_minimal
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME_BASE }}:latest
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
VCS_REF=${{ github.sha }}
- name: Build image and export to GHCR (on release only)
if: env.IS_A_RELEASE == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
target: app_minimal
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME_BASE }}:${{ github.ref_name }}
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
VCS_REF=${{ github.sha }}
verify-tag:
name: Verify tag name consistency
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Verify tag created matches value on VERSION file
run: |
version=$(cat VERSION)
if [[ ${{ github.ref_name }} != "v$version" ]]; then
echo "Tag ${{ github.ref_name }} does not match version value in repository: $version"
exit 1
fi
release:
name: Release project
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [build, verify-tag]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: "Download all artifacts that got generated in the CI/CD"
uses: actions/download-artifact@v4
with:
path: dist
- name: "Display the structure of the 'dist/' folder"
shell: bash
run: ls -R dist/
- name: "Compressing HTML documentation"
uses: vimtor/[email protected]
with:
files: dist/documentation/documentation-html
dest: dist/documentation/documentation-html.zip
- name: "Compressing PDF documentation"
uses: vimtor/[email protected]
with:
files: dist/documentation/documentation-pdf
dest: dist/documentation/documentation-pdf.zip
- name: "Release to GitHub"
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/documentation/documentation-html.zip
dist/documentation/documentation-pdf.zip
upload_docs_dev:
name: "Upload dev documentation"
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [docs]
steps:
- name: Deploy the latest documentation
uses: ansys/actions/doc-deploy-dev@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
upload_docs_release:
name: Upload release documentation
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [docs]
steps:
- name: Deploy the stable documentation
uses: ansys/actions/doc-deploy-stable@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}