PyThemis #1284
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PyThemis | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/test-python.yaml' | |
- 'docs/examples/python/**' | |
- 'src/soter/**' | |
- 'src/themis/**' | |
- 'src/wrappers/themis/python/**' | |
- 'tests/pythemis/**' | |
- '**/*.mk' | |
- 'Makefile' | |
- '!**/README*' | |
push: | |
branches: | |
- master | |
- stable | |
- release/* | |
schedule: | |
- cron: '20 6 * * 1' # every Monday at 6:20 UTC | |
env: | |
WITH_FATAL_WARNINGS: yes | |
jobs: | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install system dependencies | |
run: | | |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment' | |
sudo apt update | |
sudo apt install --yes gcc make libssl-dev \ | |
python python-setuptools \ | |
python3 python3-setuptools | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Prepare Themis Core | |
run: | | |
make | |
sudo make install | |
make prepare_tests_all | |
- name: Install PyThemis | |
run: sudo make pythemis_install | |
- name: Run test suite | |
run: make test_python | |
unit-tests-venv: | |
name: Unit tests (virtualenv install) | |
# TODO: Switch to something more fresh, Ubuntu 22.04 or Debian Bookworm, | |
# after issue with deprecates in C++ tests is fixed | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install system dependencies | |
run: | | |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment' | |
sudo apt update | |
sudo apt install --yes gcc make libssl-dev \ | |
python3 python3-pip python3-venv | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Prepare Themis Core | |
run: | | |
make | |
sudo make install | |
make prepare_tests_all | |
- name: Create virtualenv | |
run: mkdir /tmp/test_venv && python3 -m venv /tmp/test_venv | |
- name: Install PyThemis into virtualenv | |
run: | | |
source /tmp/test_venv/bin/activate && make pythemis_install | |
- name: Run test suite | |
run: source /tmp/test_venv/bin/activate && make test_python | |
- name: Uninstall PyThemis | |
run: source /tmp/test_venv/bin/activate && pip uninstall -y pythemis | |
unit-tests-deb-pkg: | |
name: Unit tests (deb package) | |
# TODO: Switch to something more fresh, Ubuntu 22.04 or Debian Bookworm, | |
# after issue with deprecates in C++ tests is fixed | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install system dependencies | |
run: | | |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment' | |
sudo apt update | |
sudo apt install --yes gcc make libssl-dev \ | |
python3 python3-setuptools \ | |
ruby | |
sudo gem install fpm | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Prepare Themis Core | |
run: | | |
make | |
sudo make install | |
make prepare_tests_all | |
- name: Install libthemis deb | |
run: | | |
make deb WITHOUT_THEMISPP=1 WITHOUT_JAVA=1 | |
sudo apt install ./build/deb/libthemis_*.deb | |
- name: Install PyThemis (deb package) | |
run: | | |
sudo make pythemis_install_deb | |
- name: Run test suite | |
run: make test_python | |
- name: Uninstall PyThemis | |
run: sudo apt remove -y python3-pythemis | |
examples: | |
name: Code examples | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: scell_token_protect_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
rabbitmq: | |
image: rabbitmq | |
ports: | |
- 5672:5672 | |
options: --hostname=localhost | |
steps: | |
- name: Install system dependencies | |
run: | | |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment' | |
sudo apt update | |
sudo apt install --yes gcc make libssl-dev \ | |
python3 python3-pip python3-setuptools \ | |
libpq-dev | |
- name: Install Python modules | |
run: | | |
sudo pip3 install tornado twisted psycopg2 pika | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Install Themis Core | |
run: | | |
make | |
sudo make install | |
- name: Install PyThemis | |
run: sudo make pythemis_install | |
- name: Test examples (Secure Cell) | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE/docs/examples/python | |
echo "Secure Cell: showcase" | |
python3 scell_test.py | |
echo | |
echo "Secure Cell: PostgreSQL" | |
python3 scell_test_postgres.py | |
echo | |
echo "Secure Cell: XML processing" | |
python3 scell_xml_format-preserving_encryption.py | |
diff -q example_data/test.xml decoded_data.xml | |
echo | |
- name: Test examples (Secure Message) | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE/docs/examples/python | |
echo "Generating keys..." | |
python3 skeygen_test.py private.key public.key | |
echo | |
echo "Secure Message: sockets: encryption" | |
python3 smessage_test_server.py & | |
sleep 1 # give server time to start | |
python3 smessage_test_client.py | |
echo | |
echo "Secure Message: sockets: sign/verify" | |
python3 smessage_sv_test_server.py & | |
sleep 1 # give server time to start | |
python3 smessage_sv_test_client.py | |
echo | |
echo "Secure Message: Twisted" | |
python3 smessage_test_twisted.py & | |
sleep 2 # give server time to start | |
python3 smessage_test_client.py | |
kill -SIGTERM $! | |
echo | |
echo "Secure Message: Tornado" | |
python3 smessage_test_tornado_server.py & | |
sleep 1 # give server time to start | |
python3 smessage_test_tornado_client.py | |
kill -SIGTERM $! | |
echo | |
echo "Secure Message: RabbitMQ" | |
python3 smessage_test_rabbitMQ_server.py & | |
sleep 1 # give server time to start | |
python3 smessage_test_rabbitMQ_client.py | |
kill -SIGTERM $! | |
echo | |
- name: Test examples (Secure Session) | |
if: always() | |
# This step tends to randomly hang up. Use a shorter timeout here | |
# instead of the default 6-hour one. | |
timeout-minutes: 5 | |
run: | | |
cd $GITHUB_WORKSPACE/docs/examples/python | |
echo "Secure Session: sockets" | |
python3 ssession_test_server.py & | |
sleep 1 # give server time to start | |
python3 ssession_test_client.py | |
echo | |
echo "Secure Session: Twisted" | |
python3 ssession_test_twisted.py & | |
sleep 1 # give server time to start | |
python3 ssession_test_client.py | |
kill -SIGTERM $! | |
echo | |
echo "Secure Session: Tornado" | |
python3 ssession_test_tornado_server.py & | |
sleep 1 # give server time to start | |
python3 ssession_test_tornado_client.py | |
kill -SIGTERM $! | |
echo | |
echo "Secure Session: RabbitMQ" | |
python3 ssession_rabbitMQ_server_test.py & | |
sleep 1 # give server time to start | |
python3 ssession_rabbitMQ_client_test.py | |
kill -SIGTERM $! | |
echo | |
- name: Test examples (Secure Comparator) | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE/docs/examples/python | |
python3 scomparator_test_server.py | tee server-output.txt & | |
sleep 1 # give server time to start | |
python3 scomparator_test_client.py | tee client-output.txt | |
test "$(cat server-output.txt)" = "match" | |
test "$(cat client-output.txt)" = "match" |