Skip to content

Commit bada386

Browse files
dennis6pedd2abt
and
edd2abt
committed
Clean up package structure + add new update functionality (#45)
* Use proper .gitignore file * Implement update method and change result handling * Switch to uv for environment management * Add rules and change default python version * Fix merging issues after rebase * Fi x formatting issues * Union with string not allowed in >python3.10 * Run build and publish also for dev * Debug pyproject.toml * Don't update version number * Fix url * check url to handle duplication error * Use caching for uv setup * Debug command * Use index url * Check dist content * Use specific build folder * Use trusted publishing * debug issue * Use trusted publisher environment * Add permissions * Use environments for deployment * Check url in case version exists * Needs build running in advance * Increment version based on latest one for test * Remove ids * Adapt card fields according to pydantic rules * Enable tests again * Remove useless fixture * Add tests for actions * Implement proper update mechanism for items and actions * Add update card example * Update README file according to changes * Fix wrong info in README * Execute test properly * Add tests for teams client * move pytest to dev dependencies * Setup example for card validation * Fix wrong import in README example * Remove unused imports * Fix wrong grammar * Use different term --------- Co-authored-by: edd2abt <[email protected]>
1 parent ce834ea commit bada386

35 files changed

+2820
-1378
lines changed

.github/workflows/python-package.yml

+23-23
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.10", "3.11", "3.12"]
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1515

1616
steps:
17-
- uses: actions/checkout@v4
18-
19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v3
21-
with:
22-
python-version: ${{ matrix.python-version }}
23-
24-
- name: Install uv for package management
25-
run: |
26-
curl -LsSf https://astral.sh/uv/install.sh | sh
27-
28-
- name: Install dependencies
29-
run: |
30-
python -m pip install --upgrade pip
31-
uv pip install --system ruff
32-
uv pip install --system -r pyproject.toml
33-
34-
- uses: chartboost/ruff-action@v1
35-
36-
- name: Test with pytest
37-
run: |
38-
uv run tests/*.py
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install uv for package management
25+
run: |
26+
curl -LsSf https://astral.sh/uv/install.sh | sh
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
uv pip install --system ruff
32+
uv pip install --system -r pyproject.toml
33+
34+
- uses: chartboost/ruff-action@v1
35+
36+
- name: Test with pytest
37+
run: |
38+
uv run pytest tests/*.py

.github/workflows/python-publish.yml

+96-26
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,108 @@ name: Upload Python Package
1111
on:
1212
release:
1313
types: [published]
14+
pull_request:
1415

1516
permissions:
1617
contents: read
18+
id-token: write
1719

1820
jobs:
19-
deploy:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: "3.10"
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
32+
with:
33+
enable-cache: true
34+
cache-dependency-glob: uv.lock
35+
36+
- name: Update version in pyproject.toml
37+
run: |
38+
echo "Updating version in pyproject.toml"
39+
LAST_RELEASE=$(pip index \
40+
-i https://test.pypi.org/simple/ \
41+
versions adaptive-cards-py 2>/dev/null \
42+
| egrep -o '([0-9]+\.){2}[0-9]+' | head -n 1)
43+
NEW_RELEASE=$(echo "$LAST_RELEASE" | awk -F. -v OFS=. '{$NF += 1; print}')
44+
sed -i "s/version = \".*\"/version = \"${NEW_RELEASE}\"/" pyproject.toml
45+
if: github.event_name == 'pull_request'
2046

47+
- name: Update version in pyproject.toml
48+
run: |
49+
echo "Updating version in pyproject.toml"
50+
TAG_NAME=${GITHUB_REF##*/} # Get the tag name from GITHUB_REF
51+
# Optionally, you may want to sanitize TAG_NAME (remove 'v' prefix, etc.)
52+
sed -i "s/version = \".*\"/version = \"${TAG_NAME}\"/" pyproject.toml
53+
if: github.event_name == 'release'
54+
55+
- name: Build package
56+
run: uv build
57+
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: build-artifacts
61+
path: dist/
62+
63+
deploy-test:
64+
if: github.event_name == 'pull_request'
65+
needs: build
2166
runs-on: ubuntu-latest
67+
environment: test
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: Set up Python
71+
uses: actions/setup-python@v3
72+
with:
73+
python-version: "3.10"
2274

75+
- name: Install uv
76+
uses: astral-sh/setup-uv@v5
77+
with:
78+
enable-cache: true
79+
cache-dependency-glob: uv.lock
80+
81+
- uses: actions/download-artifact@v4
82+
with:
83+
name: build-artifacts
84+
path: dist/
85+
86+
- name: Publish package
87+
run: |
88+
cat pyproject.toml
89+
uv publish \
90+
--check-url https://test.pypi.org/simple/ \
91+
--publish-url https://test.pypi.org/legacy/ \
92+
--trusted-publishing always
93+
94+
deploy-release:
95+
if: github.event_name == 'release'
96+
needs: build
97+
runs-on: ubuntu-latest
98+
environment: release
2399
steps:
24-
- uses: actions/checkout@v4
25-
- name: Set up Python
26-
uses: actions/setup-python@v3
27-
with:
28-
python-version: '3.x'
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install build
33-
34-
- name: Update version in pyproject.toml
35-
id: update_version
36-
run: |
37-
echo "Updating version in pyproject.toml"
38-
TAG_NAME=${GITHUB_REF##*/} # Get the tag name from GITHUB_REF
39-
# Optionally, you may want to sanitize TAG_NAME (remove 'v' prefix, etc.)
40-
sed -i "s/version = \".*\"/version = \"${TAG_NAME}\"/" pyproject.toml
41-
42-
- name: Build package
43-
run: python -m build
44-
- name: Publish package
45-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
46-
with:
47-
user: __token__
48-
password: ${{ secrets.PYPI_API_TOKEN }}
100+
- uses: actions/checkout@v4
101+
- name: Set up Python
102+
uses: actions/setup-python@v3
103+
with:
104+
python-version: "3.10"
105+
106+
- name: Install uv
107+
uses: astral-sh/setup-uv@v5
108+
with:
109+
enable-cache: true
110+
cache-dependency-glob: uv.lock
111+
112+
- uses: actions/download-artifact@v4
113+
with:
114+
name: build-artifacts
115+
path: dist/
116+
117+
- name: Publish package
118+
run: uv publish --trusted-publishing always

.gitignore

+173-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,174 @@
1-
cards
2-
.vscode
3-
__pycache__
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
4132
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

0 commit comments

Comments
 (0)