Skip to content

Commit a9e68e5

Browse files
feat: add run and keyword markers to composite action and matrix for keyword test (#819)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 745fef9 commit a9e68e5

File tree

5 files changed

+127
-83
lines changed

5 files changed

+127
-83
lines changed

.github/actions/unit-test/action.yml

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,35 @@ inputs:
77
required: true
88
default: "3.13"
99
type: string
10+
1011
github-token:
1112
description: GitHub token for authentication
1213
required: true
1314

15+
pytest-markers:
16+
description: Pytest markers to use (e.g., 'run', 'keywords')
17+
required: false
18+
default: ""
19+
type: string
20+
21+
docker-image:
22+
description: Docker image to use for LS-DYNA keyword server
23+
required: false
24+
default: "ghcr.io/ansys/ls-pre:latest"
25+
type: string
26+
27+
server-logs:
28+
description: Whether to extract server logs
29+
required: false
30+
default: "false"
31+
type: boolean
32+
33+
license-server:
34+
description: License server for LS-DYNA
35+
required: false
36+
default: ""
37+
type: string
38+
1439
runs:
1540
using: "composite"
1641
steps:
@@ -25,43 +50,55 @@ runs:
2550
cache-dependency-path: 'pyproject.toml'
2651

2752
- name: Login to GitHub container registry
28-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
53+
uses: docker/login-action@v3
2954
with:
3055
registry: ghcr.io
3156
username: ${{ github.actor }}
3257
password: ${{ inputs.github-token }}
3358

3459
- name: Pull and start LS-DYNA keyword server
60+
if: ${{ inputs.docker-image != '' && inputs.pytest-markers != 'keywords' }}
3561
run: |
36-
docker pull ghcr.io/ansys/ls-pre:latest
37-
docker run -d --name kw_server -p 50051:50051 ghcr.io/ansys/ls-pre:latest && echo "Keyword server active on port 50051."
62+
python -m pip install docker
63+
docker pull ${{ inputs.docker-image }}
64+
docker run -d --name kw_server -p 50051:50051 ${{ inputs.docker-image }} && echo "Keyword server active on port 50051."
3865
shell: bash
3966

40-
- name: Install package dependencies
67+
- name: Install test dependencies
4168
run: |
4269
pip install -e .[tests]
4370
shell: bash
4471

45-
- name: Run tests
72+
- name: Run pytest
4673
run: |
47-
pytest
74+
if [ "${{ inputs.pytest-markers }}" = "" ]; then
75+
pytest
76+
else
77+
pytest -m "${{ inputs.pytest-markers }}"
78+
fi
4879
shell: bash
80+
env:
81+
PYDYNA_RUN_CONTAINER: ${{ inputs.docker-image }}
82+
ANSYSLI_SERVERS: 2325@${{ inputs.license-server }}
83+
ANSYSLMD_LICENSE_FILE: 1055@${{ inputs.license-server }}
84+
LSTC_LICENSE: ansys
4985

5086
- name: Extract the server logs
51-
if: always()
87+
if: ${{ inputs.server-logs == 'true' }}
5288
run: |
5389
docker logs kw_server > server_output.txt
5490
shell: bash
5591

5692
- name: Upload the server logs
57-
if: always()
58-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
93+
if: ${{ inputs.server-logs == 'true' }}
94+
uses: actions/upload-artifact@v4
5995
with:
6096
name: server_output_tests.txt
6197
path: server_output.txt
6298

6399
- name: Upload coverage results
64-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
100+
if: ${{ inputs.server-logs == 'true' }}
101+
uses: actions/upload-artifact@v4
65102
with:
66103
name: coverage-html
67104
path: .cov/html

.github/workflows/ci_cd_night.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ on:
1010
required: false
1111
default: ghcr.io/ansys/pydyna-run:latest
1212

13-
push:
14-
1513

1614
concurrency:
1715
group: ${{ github.workflow }}-${{ github.ref }}
@@ -48,15 +46,15 @@ jobs:
4846
bot-token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
4947
github-actor: ${{ github.actor }}
5048

51-
# doc-deploy-dev:
52-
# name: "Deploy development documentation"
53-
# runs-on: ubuntu-latest
54-
# needs: [doc-build]
55-
# steps:
56-
# - uses: ansys/actions/doc-deploy-dev@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.15
57-
# with:
58-
# cname: ${{ env.DOCUMENTATION_CNAME }}
59-
# token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
60-
# bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
61-
# bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
49+
doc-deploy-dev:
50+
name: "Deploy development documentation"
51+
runs-on: ubuntu-latest
52+
needs: [doc-build]
53+
steps:
54+
- uses: ansys/actions/doc-deploy-dev@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.15
55+
with:
56+
cname: ${{ env.DOCUMENTATION_CNAME }}
57+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
58+
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
59+
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
6260

.github/workflows/ci_cd_pr.yml

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,54 +138,57 @@ jobs:
138138
operating-system: ${{ matrix.os }}
139139
python-version: ${{ matrix.python-version }}
140140

141-
tests:
142-
name: "Testing"
141+
142+
run-testing:
143+
name: Test the "run" subpackage
143144
runs-on: ubuntu-latest
144145
needs: [smoke-tests]
146+
145147
steps:
148+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
149+
146150
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
147151
- uses: ./.github/actions/unit-test
148152
with:
149153
python-version: ${{ env.MAIN_PYTHON_VERSION }}
150154
github-token: ${{ secrets.GITHUB_TOKEN }}
155+
docker-image: ${{ env.PYDYNA_RUN_CONTAINER }}
156+
pytest-markers: run
157+
license-server: ${{ secrets.LICENSE_SERVER }}
151158

159+
keyword-testing:
160+
name: "Keyword testing"
161+
runs-on: ${{ matrix.os }}
162+
needs: [smoke-tests]
163+
strategy:
164+
fail-fast: false
165+
matrix:
166+
os: [ubuntu-latest, windows-latest]
167+
python-version: ['3.10', '3.11', '3.12', '3.13']
168+
steps:
169+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
152170

153-
run-testing:
154-
name: Test the "run" subpackage
155-
runs-on: ubuntu-latest
156-
needs: [code-style]
171+
- uses: ./.github/actions/unit-test
172+
with:
173+
python-version: ${{ matrix.python-version }}
174+
github-token: ${{ secrets.GITHUB_TOKEN }}
175+
pytest-markers: keywords
157176

177+
unit-tests:
178+
name: "Testing"
179+
runs-on: ubuntu-latest
180+
needs: [run-testing, keyword-testing]
158181
steps:
159182
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
160-
161-
- name: "Set up Python ${{ env.MAIN_PYTHON_VERSION }}"
162-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
183+
- uses: ./.github/actions/unit-test
163184
with:
164185
python-version: ${{ env.MAIN_PYTHON_VERSION }}
165-
cache: 'pip'
166-
cache-dependency-path: 'pyproject.toml'
167-
168-
- name: "Install python dependencies"
169-
run: |
170-
python -m pip install docker # todo make this an option?
171-
python -m pip install .[tests]
172-
173-
- name: Pull PyDyna-run image
174-
run: |
175-
docker pull ${{ env.PYDYNA_RUN_CONTAINER }}
176-
177-
- name: Unit testing
178-
env:
179-
PYDYNA_RUN_CONTAINER: ${{ env.PYDYNA_RUN_CONTAINER }}
180-
ANSYSLI_SERVERS: 2325@${{secrets.LICENSE_SERVER}}
181-
ANSYSLMD_LICENSE_FILE: 1055@${{secrets.LICENSE_SERVER}}
182-
LSTC_LICENSE: ansys
183-
run: |
184-
pytest -m run
186+
github-token: ${{ secrets.GITHUB_TOKEN }}
187+
server-logs: true
185188

186189
build-library:
187190
name: "Build library"
188-
needs: [doc, tests, run-testing]
191+
needs: [doc, unit-tests]
189192
runs-on: ubuntu-latest
190193
steps:
191194
- uses: ansys/actions/build-library@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.15

.github/workflows/ci_cd_release.yml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,53 +103,58 @@ jobs:
103103
operating-system: ${{ matrix.os }}
104104
python-version: ${{ matrix.python-version }}
105105

106-
tests:
107-
name: "Testing"
106+
107+
run-testing:
108+
name: Test the "run" subpackage
108109
runs-on: ubuntu-latest
109110
needs: [smoke-tests]
111+
110112
steps:
113+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
114+
111115
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
112116
- uses: ./.github/actions/unit-test
113117
with:
114118
python-version: ${{ env.MAIN_PYTHON_VERSION }}
115119
github-token: ${{ secrets.GITHUB_TOKEN }}
120+
docker-image: ${{ env.PYDYNA_RUN_CONTAINER }}
121+
pytest-markers: run
122+
license-server: ${{ secrets.LICENSE_SERVER }}
116123

117-
run-testing:
118-
name: Test the "run" subpackage
119-
runs-on: ubuntu-latest
120-
needs: [code-style]
121-
124+
keyword-testing:
125+
name: "Keyword testing"
126+
runs-on: ${{ matrix.os }}
127+
needs: [smoke-tests]
128+
strategy:
129+
fail-fast: false
130+
matrix:
131+
os: [ubuntu-latest, windows-latest]
132+
python-version: ['3.10', '3.11', '3.12', '3.13']
122133
steps:
123134
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
124135

125-
- name: "Set up Python ${{ env.MAIN_PYTHON_VERSION }}"
126-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
136+
- uses: ./.github/actions/unit-test
137+
with:
138+
python-version: ${{ matrix.python-version }}
139+
github-token: ${{ secrets.GITHUB_TOKEN }}
140+
pytest-markers: keywords
141+
142+
unit-tests:
143+
name: "Testing"
144+
runs-on: ubuntu-latest
145+
needs: [run-testing, keyword-testing]
146+
steps:
147+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
148+
- uses: ./.github/actions/unit-test
127149
with:
128150
python-version: ${{ env.MAIN_PYTHON_VERSION }}
129-
cache: 'pip'
130-
cache-dependency-path: 'pyproject.toml'
131-
132-
- name: "Install python dependencies"
133-
run: |
134-
python -m pip install docker # todo make this an option?
135-
python -m pip install .[tests]
136-
137-
- name: Pull PyDyna-run image
138-
run: |
139-
docker pull ${{ env.PYDYNA_RUN_CONTAINER }}
140-
141-
- name: Unit testing
142-
env:
143-
PYDYNA_RUN_CONTAINER: ${{ env.PYDYNA_RUN_CONTAINER }}
144-
ANSYSLI_SERVERS: 2325@${{secrets.LICENSE_SERVER}}
145-
ANSYSLMD_LICENSE_FILE: 1055@${{secrets.LICENSE_SERVER}}
146-
LSTC_LICENSE: ansys
147-
run: |
148-
pytest -m run
151+
github-token: ${{ secrets.GITHUB_TOKEN }}
152+
server-logs: true
153+
149154

150155
build-library:
151156
name: "Build library"
152-
needs: [doc-build, tests, run-testing]
157+
needs: [doc-build, unit-tests]
153158
runs-on: ubuntu-latest
154159
steps:
155160
- uses: ansys/actions/build-library@2cf9a9c43235a000d613c2b13e64c954232a4553 # v9.0.15

doc/changelog/819.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add run and keyword markers to composite action and matrix for keyword test

0 commit comments

Comments
 (0)