Skip to content

CICD: implement tests in GitHub Actions #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI - Test Suite

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

jobs:
unit-test:
name: Unit Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run linting
run: make lint
- name: Run unit tests
run: make pytest-unit

integration-test:
name: Integration Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run integration tests
run: make ci-test

docset:
name: Generate Documentation
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-docs-pip-3.10-${{ hashFiles('**/requirements.txt', 'docs/requirements.txt') }}
restore-keys: |
${{ runner.os }}-docs-pip-3.10-

- name: Install dependencies and build documentation
run: |
pip install -r requirements.txt
cd docs
pip install -r requirements.txt
pip install sphinx sphinx_rtd_theme doc2dash
make html
doc2dash --name py-algo-sdk --index-page index.html --online-redirect-url https://py-algorand-sdk.readthedocs.io/en/latest/ _build/html
tar -czvf py-algo-sdk.docset.tar.gz py-algo-sdk.docset
mv py-algo-sdk.docset.tar.gz /tmp

- name: Upload docset artifact
uses: actions/upload-artifact@v4
with:
name: py-algo-sdk-docset
path: /tmp/py-algo-sdk.docset.tar.gz
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ ARG PYTHON_VERSION
FROM python:$PYTHON_VERSION

# Copy SDK code into the container
RUN mkdir -p $HOME/py-algorand-sdk
COPY . $HOME/py-algorand-sdk
WORKDIR $HOME/py-algorand-sdk
RUN mkdir -p /app/py-algorand-sdk
COPY . /app/py-algorand-sdk
WORKDIR /app/py-algorand-sdk

# SDK dependencies, and source version of behave with tag expression support
RUN pip install . -q \
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ docker-pysdk-build:

docker-pysdk-run:
docker ps -a
docker run -it --network host py-sdk-testing:latest
docker run -t --network host py-sdk-testing:latest

# todo replace with ports from harness .env file
smoke-test-examples:
cd examples && bash smoke_test.sh && cd -


docker-test: harness docker-pysdk-build docker-pysdk-run

ci-test: harness unit integration smoke-test-examples

.PHONY: ci-test
Loading