ci: reorganise workflows [EXPERIMENTAL] #2
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: pull_request | |
on: | |
pull_request: | |
branches: [main] | |
paths: | |
- '**.rs' | |
- '**.json' | |
- '**.toml' | |
- '**.lock' | |
- '**.py' | |
- 'pull_request.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
IROHA_CLI_DIR: "/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/test" | |
DOCKER_COMPOSE_PATH: defaults | |
WASM_SAMPLES_TARGET_DIR: wasm_samples/target/prebuilt | |
jobs: | |
consistency: | |
runs-on: [self-hosted, Linux, iroha2] | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check genesis.json | |
if: always() | |
run: ./scripts/tests/consistency.sh genesis | |
- name: Check schema.json | |
if: always() | |
run: ./scripts/tests/consistency.sh schema | |
- name: Check Docker Compose configurations | |
if: always() | |
run: ./scripts/tests/consistency.sh docker-compose | |
fmt_and_clippy: | |
runs-on: [self-hosted, Linux, iroha2] | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Format | |
if: always() | |
run: cargo fmt --all -- --check | |
- name: Format (wasm_samples) | |
run: cargo fmt --manifest-path wasm_samples/Cargo.toml --all -- --check | |
- name: Lints without features | |
if: always() | |
run: cargo clippy --workspace --benches --tests --examples --no-default-features --quiet | |
- name: Lints with all features enabled | |
if: always() | |
run: cargo clippy --workspace --benches --tests --examples --all-features --quiet --message-format=json | tee clippy.json | |
- name: Documentation | |
if: always() | |
run: cargo doc --no-deps --quiet | |
- name: Upload clippy report artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: report-clippy | |
path: clippy.json | |
python_static_analysis: | |
runs-on: ubuntu-latest | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
strategy: | |
matrix: | |
suite: [iroha_cli_tests, iroha_torii_tests] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies using Poetry for pytests/${{ matrix.suite }} | |
working-directory: pytests/${{ matrix.suite }} | |
run: | | |
poetry lock --no-update | |
poetry install | |
- name: Check code formatting with Black in pytests/${{ matrix.suite }} | |
working-directory: pytests/${{ matrix.suite }} | |
run: | | |
poetry run black --check . | |
- name: Run mypy (Type Checker) in pytests/${{ matrix.suite }} | |
working-directory: pytests/${{ matrix.suite }} | |
run: | | |
poetry run mypy --explicit-package-bases --ignore-missing-imports . | |
- name: Run flake8 (Linter) in pytests/${{ matrix.suite }} | |
working-directory: pytests/${{ matrix.suite }} | |
run: | | |
poetry run flake8 . --max-line-length=110 --ignore=F401,W503,E203 | |
build_wasm_samples: | |
runs-on: ubuntu-latest | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build | |
run: ./scripts/build_wasm_samples.sh | |
- name: Upload all built WASMs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wasm_samples | |
path: ${{ env.WASM_SAMPLES_TARGET_DIR }} | |
retention-days: 1 | |
- name: Upload executor.wasm specifically | |
uses: actions/upload-artifact@v4 | |
with: | |
name: executor.wasm | |
path: ${{ env.DOCKER_COMPOSE_PATH }}/executor.wasm | |
retention-days: 1 | |
test_with_coverage: | |
runs-on: [self-hosted, Linux, iroha2] | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
needs: build_wasm_samples | |
env: | |
LLVM_PROFILE_FILE_NAME: "iroha-%p-%m.profraw" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download executor.wasm | |
uses: actions/download-artifact@v4 | |
with: | |
name: executor.wasm | |
path: ${{ env.DOCKER_COMPOSE_PATH }} | |
- name: Download the rest of WASM samples | |
uses: actions/download-artifact@v4 | |
with: | |
name: wasm_samples | |
path: ${{ env.WASM_SAMPLES_TARGET_DIR }} | |
- name: Install irohad | |
run: which irohad || cargo install --path crates/irohad --locked | |
- uses: taiki-e/install-action@nextest | |
- uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Run tests (no default features) | |
run: > | |
mold --run cargo llvm-cov nextest | |
--no-default-features | |
--no-fail-fast --retries 2 | |
--failure-output immediate-final | |
--branch --no-report | |
- name: Run tests (all features) | |
run: > | |
mold --run cargo llvm-cov nextest | |
--all-features | |
--no-fail-fast --retries 2 | |
--failure-output immediate-final | |
--branch --no-report | |
- name: Generate lcov report | |
run: cargo llvm-cov report --lcov --output-path lcov.info | |
- name: Upload lcov report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: report-coverage | |
path: lcov.info | |
test_wasms: | |
runs-on: ubuntu-latest | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
needs: build_wasm_samples | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download executor.wasm | |
uses: actions/download-artifact@v4 | |
with: | |
name: executor.wasm | |
path: ${{ env.DOCKER_COMPOSE_PATH }} | |
- name: Install iroha_wasm_test_runner | |
run: which iroha_wasm_test_runner || cargo install --path crates/iroha_wasm_test_runner | |
- name: Run smart contract tests on WebAssembly VM | |
working-directory: crates/iroha_smart_contract | |
run: mold --run cargo test -p iroha_smart_contract -p iroha_smart_contract_utils --release --tests --target wasm32-unknown-unknown --no-fail-fast --quiet | |
# Run the job to check that the docker containers are properly buildable | |
image_build_push: | |
# Job will only execute if the head of the pull request is a branch for PR-generator case | |
if: startsWith(github.head_ref, 'iroha2-pr-deploy/') | |
runs-on: [self-hosted, Linux, iroha2] | |
container: | |
image: hyperledger/iroha2-ci:nightly-2024-09-09 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Soramitsu Harbor | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.soramitsu.co.jp | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
if: always() | |
uses: docker/setup-buildx-action@v2 | |
with: | |
install: true | |
- name: Build and push iroha2:dev image | |
uses: docker/build-push-action@v6 | |
if: always() | |
with: | |
push: true | |
tags: docker.soramitsu.co.jp/iroha2/iroha2:dev-${{ github.event.pull_request.head.sha }} | |
labels: commit=${{ github.sha }} | |
build-args: TAG=dev | |
file: Dockerfile.glibc | |
# This context specification is required | |
context: . | |
docker-compose-and-pytests: | |
needs: build_wasm_samples | |
runs-on: [self-hosted, Linux, iroha2] | |
timeout-minutes: 60 | |
env: | |
PYTHON_VERSION: "3.11" | |
POETRY_PATH: "/root/.local/bin/poetry" | |
TEST_DIR: "tmp/test" | |
IROHA_BIN: "iroha" | |
IROHA_CONTAINER: "defaults-irohad0-1" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download executor.wasm | |
uses: actions/download-artifact@v4 | |
with: | |
name: executor.wasm | |
path: ${{ env.DOCKER_COMPOSE_PATH }} | |
- name: Install Python and Poetry | |
run: | | |
yum install -y python${{ env.PYTHON_VERSION }} python${{ env.PYTHON_VERSION }}-devel | |
curl -sSL https://install.python-poetry.org | python3 - | |
echo 'export PATH="${{ env.POETRY_PATH }}:$PATH"' >> /etc/profile | |
source /etc/profile | |
- name: Set up Docker buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Build and tag Docker images | |
uses: docker/build-push-action@v6 | |
if: always() | |
with: | |
context: . | |
load: true | |
file: Dockerfile.glibc | |
tags: | | |
hyperledger/iroha:local | |
hyperledger/iroha:dev | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test docker-compose.single.yml | |
run: | | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.single.yml up --wait || exit 1 | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.single.yml down | |
- name: Test docker-compose.local.yml | |
run: | | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml up --wait || exit 1 | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml down | |
- name: Run docker-compose.yml containers | |
run: docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml up --wait || exit 1 | |
- name: Install Torii pytest dependencies | |
working-directory: pytests/iroha_torii_tests | |
run: ${{ env.POETRY_PATH }} install | |
- name: Run Torii pytests | |
working-directory: pytests/iroha_torii_tests | |
run: ${{ env.POETRY_PATH }} run pytest | |
- name: Copy client binary from Iroha container | |
if: always() | |
run: | | |
mkdir -p ${{ env.TEST_DIR }} | |
cp ./defaults/client.toml ${{ env.TEST_DIR }} | |
docker cp ${{ env.IROHA_CONTAINER }}:/usr/local/bin/${{ env.IROHA_BIN }} ${{ env.TEST_DIR }} | |
chmod +x ${{ env.TEST_DIR }}/${{ env.IROHA_BIN }} | |
- name: Install client pytest dependencies | |
working-directory: pytests/iroha_cli_tests | |
run: ${{ env.POETRY_PATH }} install | |
- name: Run client pytests | |
uses: nick-fields/retry@v3 | |
env: | |
TMP_DIR: ../../${{ env.TEST_DIR }} | |
IROHA_CLI_BINARY: ${{ env.IROHA_BIN }} | |
IROHA_CLI_CONFIG: client.toml | |
with: | |
timeout_minutes: 10 | |
max_attempts: 5 | |
command: | | |
cd pytests/iroha_cli_tests | |
${{ env.POETRY_PATH }} run pytest | |
on_retry_command: | | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml down | |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml up --wait || exit 1 | |
- name: Wipe docker-compose.yml containers | |
if: always() | |
run: docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml down |