Skip to content

Commit 5bd4322

Browse files
authored
Enhance examples with additional features and improvements, including… (#4)
* Enhance examples with additional features and improvements, including updated documentation and variable renaming. * Update CI configuration to include cache-dependency-path for Poetry in workflows * Update .gitignore to clarify the need for committing poetry.lock and adjust CI workflow cache-dependency-path for Poetry * Refactor CI workflow to implement caching for Poetry dependencies using actions/cache, removing deprecated cache settings. * Update poetry.lock to reflect new content hash after dependency resolution changes. * Fix CI workflow: handle pytest exit code 5 (no tests collected) * Add basic test for account creation and verification * Update test to match main.py setup and handle LocalNet unavailability * Add LocalNet setup to CI workflow so tests can run * Add algokit as dependency and remove manual installation from CI * Use poetry run algokit to run algokit from virtual environment * Fix LocalNet start command: use separate reset and start commands * Update poetry.lock and pyproject.toml to include new dev dependencies and adjust groups
1 parent e18dc35 commit 5bd4322

File tree

5 files changed

+1435
-2
lines changed

5 files changed

+1435
-2
lines changed

.github/workflows/ci.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.14"]
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
version: latest
29+
virtualenvs-create: true
30+
virtualenvs-in-project: true
31+
installer-parallel: true
32+
33+
- name: Cache Poetry dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: .venv
37+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
38+
restore-keys: |
39+
venv-${{ runner.os }}-${{ matrix.python-version }}-
40+
41+
- name: Install dependencies
42+
run: poetry install --no-interaction --no-root
43+
44+
- name: Install project
45+
run: poetry install --no-interaction
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Start LocalNet
51+
run: |
52+
poetry run algokit localnet reset || true
53+
poetry run algokit localnet start
54+
# Wait for LocalNet to be ready
55+
timeout 120 bash -c 'until curl -s http://localhost:4001/health > /dev/null; do sleep 2; done' || true
56+
57+
- name: Run tests
58+
run: |
59+
if [ -d "tests" ]; then
60+
poetry add --group dev pytest || true
61+
poetry run pytest tests/ -v; EXIT_CODE=$?
62+
# Exit code 5 means no tests were collected, which is OK
63+
if [ $EXIT_CODE -eq 5 ]; then
64+
echo "No tests collected, but this is OK"
65+
exit 0
66+
fi
67+
exit $EXIT_CODE
68+
else
69+
echo "No tests directory found, skipping test execution"
70+
fi
71+
72+
- name: Check imports
73+
run: poetry run python -c "import algo_utils_examples; import algo_utils_examples.accounts; import algo_utils_examples.transaction; import algo_utils_examples.assets; print('All imports successful')"
74+
75+
- name: Verify module structure
76+
run: |
77+
poetry run python -c "from algo_utils_examples.main import main; print('main() function imported successfully')"
78+
echo "Module structure verified (execution requires LocalNet)"
79+
80+
lint:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v4
85+
86+
- name: Set up Python 3.14
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: "3.14"
90+
91+
- name: Install Poetry
92+
uses: snok/install-poetry@v1
93+
with:
94+
version: latest
95+
virtualenvs-create: true
96+
virtualenvs-in-project: true
97+
installer-parallel: true
98+
99+
- name: Cache Poetry dependencies
100+
uses: actions/cache@v4
101+
with:
102+
path: .venv
103+
key: venv-${{ runner.os }}-3.14-${{ hashFiles('**/poetry.lock') }}
104+
restore-keys: |
105+
venv-${{ runner.os }}-3.14-
106+
107+
- name: Install dependencies
108+
run: poetry install --no-interaction
109+
110+
- name: Check code formatting with black (optional)
111+
run: |
112+
poetry add --group dev black || echo "black not available"
113+
poetry run black --check src/ tests/ || echo "Formatting check skipped"
114+
continue-on-error: true
115+
116+
- name: Lint with ruff (optional)
117+
run: |
118+
poetry add --group dev ruff || echo "ruff not available"
119+
poetry run ruff check src/ tests/ || echo "Linting check skipped"
120+
continue-on-error: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Thumbs.db
3131
.algokit/
3232

3333
# Poetry
34-
poetry.lock
34+
# poetry.lock should be committed for reproducible builds

0 commit comments

Comments
 (0)