ci: add ci to pytests #52
Workflow file for this run
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: Iroha 2 pull request workflow | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
check: | |
runs-on: iroha-ubuntu-latest | |
container: rust:1.65-buster | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
apt-get update | |
apt-get install -y --no-install-recommends \ | |
build-essential \ | |
ca-certificates \ | |
clang \ | |
git \ | |
llvm-dev \ | |
python3-pip | |
rustup component add clippy rustfmt | |
pip3 install yapf | |
cargo install cargo-lints | |
- name: Check Cargo.toml | |
run: cat Cargo.toml | |
- name: Check Cargo.lock | |
run: cat Cargo.lock | |
- name: Debug Dependencies | |
run: cargo metadata --format-version 1 --verbose | |
- name: Format check | |
run: cargo fmt --all -- --check | |
- name: Static analysis | |
run: cargo lints clippy --all --benches --tests | |
- name: Check regeneration of python sys library and formatting (PEP8) | |
run: | | |
cargo run -p generate -- iroha2/sys | |
yapf --style pep8 -e 'iroha2/sys/**/*.py' -r -i iroha2 example | |
git diff --quiet | |
pytest: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ 3.12 ] | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
- name: Checkout Iroha code | |
uses: actions/checkout@v4 | |
with: | |
repository: 'hyperledger/iroha' | |
ref: '2.0.0-pre-rc.22' | |
- name: Run docker-compose.yml containers | |
run: | | |
docker compose -f ./configs/swarm/docker-compose.yml up --wait || exit 1 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Maturin build | |
run: | | |
pip install maturin | |
maturin build | |
poetry add target/wheels/* | |
- name: Install project dependencies | |
run: poetry install | |
- name: Run tests | |
run: poetry run pytest tests | |
- name: Tear down Docker containers | |
if: always() | |
run: | | |
docker stop $(docker ps -q) && docker rm $(docker ps -a -q) | |
integration-test: | |
runs-on: iroha-ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build Iroha Python test Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
push: false | |
dockerfile: example/Dockerfile | |
repository: iroha | |
tags: python-test | |
- name: Run test in docker | |
working-directory: example | |
run: | | |
docker-compose up -d && sleep 5 | |
docker run --net example_default -v $PWD:/test iroha:python-test \ | |
timeout 5 python3 test.py || | |
(docker-compose logs && false) |