Skip to content

Commit d9e8ea0

Browse files
ci(py/dotpromptz): add smoke test to verify dotpromptz usability from pypi (#357)
* ci(py-dotpromptz): add smoke test to verify dotpromoptz usability * ci(py-dotpromptz): fix the bug in run smoke test script * ci(py-dotpromptz):append the run attempt num to the artifact name * ci(py-dotpromptz):append the run attempt num and python version to the artifact name * ci(py-dotpromptz):append the run attempt num and python version to the artifact name in download job as well * ci(py-dotpromptz):remove the run attempt num and python version to the artifact name * ci(py-dotpromptz):fix syntax error in smoke test * ci(py-dotpromptz):add different python version test in smoke test --------- Co-authored-by: Mengqin Shen <[email protected]>
1 parent ee08221 commit d9e8ea0

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

.github/workflows/publish_python_dotpromptz_package.yml

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ on:
3030
options:
3131
- testpypi
3232
- pypi
33-
# pull_request:
34-
# branches: [main]
3533

3634
permissions:
3735
contents: write
@@ -48,6 +46,7 @@ jobs:
4846
matrix:
4947
python-version:
5048
- "3.12"
49+
5150
fail-fast: false
5251

5352
steps:
@@ -58,16 +57,16 @@ jobs:
5857
with:
5958
python-version: ${{ matrix.python-version }}
6059

61-
# Dependency Check (Smoke Test)
60+
# Dependency Check of handlebars
6261
- name: Install Dependencies for Check
6362
run: pip install requests
6463

65-
- name: Smoke Test - Check handlebarrz Dependency
64+
- name: Smoke Test - Check handlebarrz Dependency on PyPI
6665
id: check_dependency
6766
run: |
6867
IS_FOUND=$(python -c '
6968
import requests
70-
url = "https://pypi.org/project/dotprompt-handlebars/json"
69+
url = "https://pypi.org/project/dotpromptz-handlebars/json"
7170
response = requests.get(url)
7271
7372
if response.status_code == 200:
@@ -98,18 +97,18 @@ jobs:
9897
python-version: ${{ matrix.python-version }}
9998
enable-cache: true
10099

101-
- name: Install Build and Publish Tools
100+
- name: Install Build Tools
102101
run: |
103102
uv pip install build twine
104103
105-
- name: Build dotpromptz distributions
104+
- name: Build dotpromptz Distributions
106105
run: |
107106
source .venv/bin/activate
108107
cd python/dotpromptz
109108
python -m build
110109
twine check dist/*
111110
112-
- name: Upload build packages
111+
- name: Upload dotpromptz Distributions for Python
113112
uses: actions/upload-artifact@v4
114113
with:
115114
name: dist-dotpromptz
@@ -138,9 +137,51 @@ jobs:
138137
name: dist-dotpromptz
139138
path: dist/
140139

141-
- name: Publish distribution to PyPI
140+
- name: Publish Distribution to PyPI
142141
uses: pypa/gh-action-pypi-publish@release/v1
143142
with:
144143
verbose: true
145144
packages-dir: dist/
146145
repository-url: ${{ inputs.target == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
146+
147+
smoke_test_pypi_package:
148+
name: Verify Package Usability
149+
needs: [pypi_publish]
150+
runs-on: ubuntu-latest
151+
strategy:
152+
matrix:
153+
python-version:
154+
- "3.10"
155+
- "3.11"
156+
- "3.12"
157+
- "3.13"
158+
steps:
159+
- uses: actions/checkout@v4
160+
161+
- name: Set up Python
162+
uses: actions/setup-python@v5
163+
with:
164+
python-version: ${{ matrix.python-version }}
165+
166+
- name: Install dotpromptz from PyPI
167+
run: |
168+
pip install dotpromptz
169+
170+
- name: Run Smoke Test Script
171+
run: |
172+
python -c "
173+
import importlib.metadata
174+
import sys
175+
176+
try:
177+
importlib.metadata.version('dotpromptz')
178+
print('Smoke test successful: Package found and imported.')
179+
180+
except importlib.metadata.PackageNotFoundError:
181+
print('Smoke test FAILED: Package not found in environment.')
182+
sys.exit(1)
183+
184+
except Exception as e:
185+
print(f'Smoke test FAILED due to unexpected error: {e}')
186+
sys.exit(1)
187+
"

0 commit comments

Comments
 (0)