|
| 1 | +name: I2::Dev::Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - '**.rs' |
| 8 | + - '**.json' |
| 9 | + - '**.toml' |
| 10 | + - '**.lock' |
| 11 | + - '**.py' |
| 12 | + - '.github/workflows/iroha2-dev-pr.yml' |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +env: |
| 19 | + CARGO_TERM_COLOR: always |
| 20 | + IROHA_CLI_DIR: "/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/test" |
| 21 | + DEFAULTS_DIR: defaults |
| 22 | + WASM_TARGET_DIR: wasm/target/prebuilt |
| 23 | + TEST_NETWORK_TMP_DIR: /tmp |
| 24 | + NEXTEST_PROFILE: ci |
| 25 | + |
| 26 | +jobs: |
| 27 | + consistency: |
| 28 | + runs-on: [self-hosted, Linux, iroha2] |
| 29 | + container: |
| 30 | + image: hyperledger/iroha2-ci:nightly-2024-09-09 |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - name: Check genesis.json |
| 34 | + if: always() |
| 35 | + run: ./scripts/tests/consistency.sh genesis |
| 36 | + - name: Check schema.json |
| 37 | + if: always() |
| 38 | + run: ./scripts/tests/consistency.sh schema |
| 39 | + - name: Check CommandLineHelp.md |
| 40 | + if: always() |
| 41 | + run: ./scripts/tests/consistency.sh cli-help |
| 42 | + - name: Check Docker Compose configurations |
| 43 | + if: always() |
| 44 | + run: ./scripts/tests/consistency.sh docker-compose |
| 45 | + |
| 46 | + fmt_and_clippy: |
| 47 | + runs-on: [self-hosted, Linux, iroha2] |
| 48 | + container: |
| 49 | + image: hyperledger/iroha2-ci:nightly-2024-09-09 |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - name: Format |
| 53 | + run: cargo fmt --all -- --check |
| 54 | + - name: Lints without features |
| 55 | + if: always() |
| 56 | + run: cargo clippy --workspace --benches --tests --examples --no-default-features --quiet |
| 57 | + - name: Lints with all features enabled |
| 58 | + if: always() |
| 59 | + run: cargo clippy --workspace --benches --tests --examples --all-features --quiet --message-format=json | tee clippy.json |
| 60 | + - name: Documentation |
| 61 | + if: always() |
| 62 | + run: cargo doc --no-deps --quiet |
| 63 | + - name: Upload clippy report artifact |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: report-clippy |
| 67 | + path: clippy.json |
| 68 | + |
| 69 | + build_wasm: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + container: |
| 72 | + image: hyperledger/iroha2-ci:nightly-2024-09-09 |
| 73 | + timeout-minutes: 30 |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + - name: Build |
| 77 | + run: ./scripts/build_wasm.sh |
| 78 | + - name: Upload all built WASMs |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: wasm |
| 82 | + path: ${{ env.WASM_TARGET_DIR }} |
| 83 | + retention-days: 1 |
| 84 | + |
| 85 | + test_with_coverage: |
| 86 | + runs-on: [self-hosted, Linux, iroha2] |
| 87 | + container: |
| 88 | + image: hyperledger/iroha2-ci:nightly-2024-09-09 |
| 89 | + needs: build_wasm |
| 90 | + env: |
| 91 | + LLVM_PROFILE_FILE_NAME: "iroha-%p-%m.profraw" |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v4 |
| 94 | + - uses: taiki-e/install-action@nextest |
| 95 | + - uses: taiki-e/install-action@cargo-llvm-cov |
| 96 | + - name: Download wasm |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: wasm |
| 100 | + path: ${{ env.WASM_TARGET_DIR }} |
| 101 | + - name: Move wasm libs |
| 102 | + run: | |
| 103 | + mv ${{ env.WASM_TARGET_DIR }}/libs ${{ env.DEFAULTS_DIR }}/libs |
| 104 | + mv ${{ env.DEFAULTS_DIR }}/libs/default_executor.wasm ${{ env.DEFAULTS_DIR }}/executor.wasm |
| 105 | + - name: Install irohad |
| 106 | + run: which irohad || cargo install --path crates/irohad --locked |
| 107 | + - name: Test with no default features |
| 108 | + id: test_no_features |
| 109 | + run: > |
| 110 | + mold --run cargo llvm-cov nextest |
| 111 | + --no-default-features |
| 112 | + --branch --no-report |
| 113 | + - name: Test with all features |
| 114 | + id: test_all_features |
| 115 | + run: > |
| 116 | + mold --run cargo llvm-cov nextest |
| 117 | + --all-features |
| 118 | + --branch --no-report |
| 119 | + - name: Doc test with all features |
| 120 | + run: > |
| 121 | + mold --run cargo llvm-cov --doc |
| 122 | + --all-features |
| 123 | + --branch --no-report |
| 124 | + - name: Generate lcov report |
| 125 | + run: cargo llvm-cov report --doctests --ignore-filename-regex 'iroha_cli|iroha_torii' --lcov --output-path lcov.info |
| 126 | + - name: Upload lcov report |
| 127 | + uses: actions/upload-artifact@v4 |
| 128 | + with: |
| 129 | + name: report-coverage |
| 130 | + path: lcov.info |
| 131 | + - name: Upload coverage to Coveralls |
| 132 | + uses: coverallsapp/github-action@v2.3.6 |
| 133 | + with: |
| 134 | + file: lcov.info |
| 135 | + format: lcov |
| 136 | + github-token: ${{ github.token }} |
| 137 | + - name: Upload test network artifacts |
| 138 | + if: failure() && (steps.test_no_features.outcome == 'failure' || steps.test_all_features.outcome == 'failure') |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: test_network_runs |
| 142 | + path: ${{ env.TEST_NETWORK_TMP_DIR }}/irohad_test_network_* |
| 143 | + retention-days: 3 |
| 144 | + |
| 145 | + # Run the job to check that the docker containers are properly buildable |
| 146 | + pr-generator-build: |
| 147 | + # Job will only execute if the head of the pull request is a branch for PR-generator case |
| 148 | + if: startsWith(github.head_ref, 'iroha2-pr-deploy/') |
| 149 | + runs-on: [self-hosted, Linux, iroha2] |
| 150 | + container: |
| 151 | + image: hyperledger/iroha2-ci:nightly-2024-09-09 |
| 152 | + steps: |
| 153 | + - uses: actions/checkout@v4 |
| 154 | + - name: Login to Soramitsu Harbor |
| 155 | + uses: docker/login-action@v3 |
| 156 | + with: |
| 157 | + registry: docker.soramitsu.co.jp |
| 158 | + username: ${{ secrets.HARBOR_USERNAME }} |
| 159 | + password: ${{ secrets.HARBOR_TOKEN }} |
| 160 | + - name: Set up Docker Buildx |
| 161 | + id: buildx |
| 162 | + if: always() |
| 163 | + uses: docker/setup-buildx-action@v2 |
| 164 | + with: |
| 165 | + install: true |
| 166 | + - name: Build and push iroha:dev image |
| 167 | + uses: docker/build-push-action@v6 |
| 168 | + if: always() |
| 169 | + with: |
| 170 | + push: true |
| 171 | + tags: docker.soramitsu.co.jp/iroha2/iroha:dev-${{ github.event.pull_request.head.sha }} |
| 172 | + labels: commit=${{ github.sha }} |
| 173 | + build-args: TAG=dev |
| 174 | + # This context specification is required |
| 175 | + context: . |
| 176 | + |
| 177 | + docker-compose-and-pytests: |
| 178 | + needs: build_wasm |
| 179 | + runs-on: [self-hosted, Linux, iroha2] |
| 180 | + timeout-minutes: 60 |
| 181 | + env: |
| 182 | + PYTHON_VERSION: "3.11" |
| 183 | + POETRY_PATH: "/root/.local/bin/poetry" |
| 184 | + TEST_DIR: "tmp/test" |
| 185 | + IROHA_BIN: "iroha" |
| 186 | + IROHA_CONTAINER: "defaults-irohad0-1" |
| 187 | + steps: |
| 188 | + - name: Checkout code |
| 189 | + uses: actions/checkout@v4 |
| 190 | + - name: Download wasm libs |
| 191 | + uses: actions/download-artifact@v4 |
| 192 | + with: |
| 193 | + name: wasm |
| 194 | + path: ${{ env.WASM_TARGET_DIR }} |
| 195 | + - name: Move wasm libs |
| 196 | + run: | |
| 197 | + mv ${{ env.WASM_TARGET_DIR }}/libs ${{ env.DEFAULTS_DIR }}/libs |
| 198 | + mv ${{ env.DEFAULTS_DIR }}/libs/default_executor.wasm ${{ env.DEFAULTS_DIR }}/executor.wasm |
| 199 | + - name: Install Python and Poetry |
| 200 | + run: | |
| 201 | + yum install -y python${{ env.PYTHON_VERSION }} python${{ env.PYTHON_VERSION }}-devel |
| 202 | + curl -sSL https://install.python-poetry.org | python3 - |
| 203 | + echo 'export PATH="${{ env.POETRY_PATH }}:$PATH"' >> /etc/profile |
| 204 | + source /etc/profile |
| 205 | + - name: Set up Docker buildx |
| 206 | + id: buildx |
| 207 | + uses: docker/setup-buildx-action@v3 |
| 208 | + with: |
| 209 | + install: true |
| 210 | + - name: Build and tag Docker images |
| 211 | + uses: docker/build-push-action@v6 |
| 212 | + if: always() |
| 213 | + with: |
| 214 | + context: . |
| 215 | + load: true |
| 216 | + tags: | |
| 217 | + hyperledger/iroha:local |
| 218 | + hyperledger/iroha:dev |
| 219 | + cache-from: type=gha |
| 220 | + cache-to: type=gha,mode=max |
| 221 | + - name: Test docker-compose.single.yml |
| 222 | + run: | |
| 223 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.single.yml up --wait || { |
| 224 | + echo "docker-compose failed. Logs:"; |
| 225 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.single.yml logs --tail="all"; |
| 226 | + exit 1; |
| 227 | + } |
| 228 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.single.yml down |
| 229 | + - name: Test docker-compose.local.yml |
| 230 | + run: | |
| 231 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.local.yml up --wait || { |
| 232 | + echo "docker-compose failed. Logs:"; |
| 233 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.local.yml logs --tail="all"; |
| 234 | + exit 1; |
| 235 | + } |
| 236 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.local.yml down |
| 237 | + - name: Run docker-compose.yml containers |
| 238 | + run: docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.yml up --wait || exit 1 |
| 239 | + - name: Install Torii pytest dependencies |
| 240 | + working-directory: pytests/iroha_torii_tests |
| 241 | + run: ${{ env.POETRY_PATH }} install --no-root |
| 242 | + - name: Run Torii pytests |
| 243 | + working-directory: pytests/iroha_torii_tests |
| 244 | + run: ${{ env.POETRY_PATH }} run pytest |
| 245 | + - name: Copy client binary from Iroha container |
| 246 | + if: always() |
| 247 | + run: | |
| 248 | + mkdir -p ${{ env.TEST_DIR }} |
| 249 | + cp ./defaults/client.toml ${{ env.TEST_DIR }} |
| 250 | + docker cp ${{ env.IROHA_CONTAINER }}:/usr/local/bin/${{ env.IROHA_BIN }} ${{ env.TEST_DIR }} |
| 251 | + chmod +x ${{ env.TEST_DIR }}/${{ env.IROHA_BIN }} |
| 252 | + - name: Install client pytest dependencies |
| 253 | + working-directory: pytests/iroha_cli_tests |
| 254 | + run: ${{ env.POETRY_PATH }} install --no-root |
| 255 | + - name: Run client pytests |
| 256 | + uses: nick-fields/retry@v3 |
| 257 | + env: |
| 258 | + TMP_DIR: ../../${{ env.TEST_DIR }} |
| 259 | + IROHA_CLI_BINARY: ${{ env.IROHA_BIN }} |
| 260 | + IROHA_CLI_CONFIG: client.toml |
| 261 | + with: |
| 262 | + timeout_minutes: 10 |
| 263 | + max_attempts: 5 |
| 264 | + command: | |
| 265 | + cd pytests/iroha_cli_tests |
| 266 | + ${{ env.POETRY_PATH }} run pytest |
| 267 | + on_retry_command: | |
| 268 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.yml down |
| 269 | + docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.local.yml up --wait || exit 1 |
| 270 | + - name: Wipe docker-compose.yml containers |
| 271 | + if: always() |
| 272 | + run: docker compose -f ${{ env.DEFAULTS_DIR }}/docker-compose.yml down |
0 commit comments