Skip to content

Commit dd04ad9

Browse files
authored
CICD: implement tests in GitHub Actions (#575)
1 parent 900361f commit dd04ad9

File tree

3 files changed

+106
-5
lines changed

3 files changed

+106
-5
lines changed

.github/workflows/ci-pr.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI - Test Suite
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
unit-test:
11+
name: Unit Tests (Python ${{ matrix.python-version }})
12+
runs-on: ubuntu-24.04
13+
strategy:
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Cache pip dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-${{ matrix.python-version }}-
31+
- name: Install dependencies
32+
run: pip install -r requirements.txt
33+
- name: Run linting
34+
run: make lint
35+
- name: Run unit tests
36+
run: make pytest-unit
37+
38+
integration-test:
39+
name: Integration Tests (Python ${{ matrix.python-version }})
40+
runs-on: ubuntu-24.04
41+
strategy:
42+
matrix:
43+
python-version: ["3.10", "3.11", "3.12"]
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
- name: Cache pip dependencies
53+
uses: actions/cache@v3
54+
with:
55+
path: ~/.cache/pip
56+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
57+
restore-keys: |
58+
${{ runner.os }}-pip-${{ matrix.python-version }}-
59+
- name: Install dependencies
60+
run: pip install -r requirements.txt
61+
- name: Run integration tests
62+
run: make ci-test
63+
64+
docset:
65+
name: Generate Documentation
66+
runs-on: ubuntu-24.04
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
- name: Set up Python 3.10
72+
uses: actions/setup-python@v4
73+
with:
74+
python-version: '3.10'
75+
- name: Cache pip dependencies
76+
uses: actions/cache@v3
77+
with:
78+
path: ~/.cache/pip
79+
key: ${{ runner.os }}-docs-pip-3.10-${{ hashFiles('**/requirements.txt', 'docs/requirements.txt') }}
80+
restore-keys: |
81+
${{ runner.os }}-docs-pip-3.10-
82+
83+
- name: Install dependencies and build documentation
84+
run: |
85+
pip install -r requirements.txt
86+
cd docs
87+
pip install -r requirements.txt
88+
pip install sphinx sphinx_rtd_theme doc2dash
89+
make html
90+
doc2dash --name py-algo-sdk --index-page index.html --online-redirect-url https://py-algorand-sdk.readthedocs.io/en/latest/ _build/html
91+
tar -czvf py-algo-sdk.docset.tar.gz py-algo-sdk.docset
92+
mv py-algo-sdk.docset.tar.gz /tmp
93+
94+
- name: Upload docset artifact
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: py-algo-sdk-docset
98+
path: /tmp/py-algo-sdk.docset.tar.gz

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ ARG PYTHON_VERSION
22
FROM python:$PYTHON_VERSION
33

44
# Copy SDK code into the container
5-
RUN mkdir -p $HOME/py-algorand-sdk
6-
COPY . $HOME/py-algorand-sdk
7-
WORKDIR $HOME/py-algorand-sdk
5+
RUN mkdir -p /app/py-algorand-sdk
6+
COPY . /app/py-algorand-sdk
7+
WORKDIR /app/py-algorand-sdk
88

99
# SDK dependencies, and source version of behave with tag expression support
1010
RUN pip install . -q \

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ docker-pysdk-build:
4343

4444
docker-pysdk-run:
4545
docker ps -a
46-
docker run -it --network host py-sdk-testing:latest
46+
docker run -t --network host py-sdk-testing:latest
4747

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

52-
5352
docker-test: harness docker-pysdk-build docker-pysdk-run
53+
54+
ci-test: harness unit integration smoke-test-examples
55+
56+
.PHONY: ci-test

0 commit comments

Comments
 (0)