Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars committed Nov 8, 2024
1 parent 2089d36 commit 9f89e5f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 151 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/_external_rust_tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Rust tests

on: workflow_call
on:
workflow_call:
inputs:
changedCrates:
type: string
required: false

concurrency:
group: ext-rust-tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -12,21 +17,8 @@ env:
CARGO_INCREMENTAL: 0

jobs:
changes:
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # pin@v3
id: filter
with:
list-files: "json"
filters: .github/external-crates-filters.yml

test:
name: Test external crates
needs: changes
if: (!cancelled())
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
Expand All @@ -43,7 +35,7 @@ jobs:
run: pip install pyopenssl --upgrade --break-system-packages
- name: cargo test
run: |
array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }})
array=(${{ inputs.changedCrates }})
result=""
Expand Down
38 changes: 33 additions & 5 deletions .github/workflows/_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,47 @@ jobs:
deny:
uses: ./.github/workflows/_cargo_deny.yml

rust-tests:
crates-changes:
needs: rust-lints
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # pin@v3
id: filter
with:
list-files: "json"
filters: .github/crates-filters.yml

external-changes:
needs: rust-lints
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # pin@v3
id: filter
with:
list-files: "json"
filters: .github/external-crates-filters.yml

crates-tests:
if: |
!cancelled() && !failure() && inputs.isRust && github.event.pull_request.draft == false
needs:
- rust-lints
needs: crates-changes
uses: ./.github/workflows/_rust_tests.yml
with:
changedCrates: ${{ join(fromJson(needs.crates-changes.outputs.components), ' ') }}

external-tests:
if: |
!cancelled() && !failure() && inputs.isRust && github.event.pull_request.draft == false
needs:
- rust-lints
needs: external-changes
uses: ./.github/workflows/_external_rust_tests.yml
with:
changedCrates: ${{ join(fromJson(needs.external-changes.outputs.components), ' ') }}

execution-cut:
if: |
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/_rust_tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Rust tests

on: workflow_call
on:
workflow_call:
inputs:
changedCrates:
type: string
required: false

concurrency:
group: rust-tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -21,21 +26,8 @@ env:
RUSTDOCFLAGS: -D warnings

jobs:
changes:
runs-on: [self-hosted]
outputs:
components: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # pin@v3
id: filter
with:
list-files: "json"
filters: .github/crates-filters.yml

test:
name: Test rust crates
needs: changes
if: (!cancelled())
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
Expand All @@ -50,7 +42,7 @@ jobs:
tool: nextest
- name: cargo test
run: |
array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }})
array=(${{ inputs.changedCrates }})
result=""
Expand Down Expand Up @@ -126,7 +118,6 @@ jobs:

simtest:
name: Simtest rust
needs: changes
timeout-minutes: 45
runs-on: [self-hosted]
env:
Expand All @@ -138,7 +129,7 @@ jobs:
tool: nextest
- name: setup filter
run: |
array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }})
array=(${{ inputs.changedCrates }})
result=""
Expand Down
115 changes: 1 addition & 114 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,120 +69,7 @@ jobs:
args: --all-targets --all-features --release

test:
name: Test rust crates
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
# non-deterministic `test` job.
IOTA_SKIP_SIMTESTS: 1
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # pin@v2
with:
tool: nextest
- name: cargo test
run: cargo nextest run --profile ci

test-extra:
env:
# Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var
# causes #[sim_test] to only run under the deterministic `simtest` job, and not the
# non-deterministic `test` job.
IOTA_SKIP_SIMTESTS: 1
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # Pin v4
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # pin@v2
with:
tool: nextest
- name: benchmark (smoke)
run: |
cargo run --package iota-benchmark --bin stress -- --log-path /tmp/stress.log --num-client-threads 10 --num-server-threads 24 --num-transfer-accounts 2 bench --target-qps 100 --num-workers 10 --transfer-object 50 --shared-counter 50 --run-duration 10s --stress-stat-collection
- name: doctests
run: |
cargo test --doc
- name: rustdoc
run: |
cargo doc --all-features --workspace --no-deps
- name: Install cargo-hakari, and cache the binary
uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # pin@v3
with:
crate: cargo-hakari
locked: true
- name: Install nightly rustfmt
run: rustup toolchain install nightly --component rustfmt --allow-downgrade
- name: iota-execution
run: |
./scripts/execution_layer.py generate-lib
# Ensure there are no uncommitted changes in the repo after running tests
- run: scripts/changed-files.sh
shell: bash

simtest:
name: Simtest rust
timeout-minutes: 45
runs-on: [self-hosted]
env:
MSIM_WATCHDOG_TIMEOUT_MS: 60000
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # pin@v2
with:
tool: nextest
- run: scripts/simtest/cargo-simtest simtest --profile ci
- name: check new tests for flakiness
run: |
command="scripts/simtest/stress-new-tests.sh $filters"
echo "$command"
eval ${command}
graphql-rpc:
name: graphql-rpc
timeout-minutes: 45
runs-on: [self-hosted]
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgrespw
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres_container
ports:
- 5432:5432
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # pin@v2
with:
tool: nextest
- name: Install postgresql-client
run: sudo apt-get install -y postgresql-client
- name: Setup db
run: |
PGPASSWORD=$POSTGRES_PASSWORD psql -h localhost -U $POSTGRES_USER -c 'CREATE DATABASE iota_indexer;' -c 'ALTER SYSTEM SET max_connections = 500;'
- run: docker restart --time 0 postgres_container
- run: sleep 5
- name: tests-requiring-postgres
run: |
cargo nextest run --no-fail-fast --test-threads 1 --package iota-graphql-rpc --test e2e_tests --test examples_validation_tests --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-graphql-rpc --lib --features pg_integration -- test_query_cost
cargo nextest run --no-fail-fast --test-threads 8 --package iota-graphql-e2e-tests --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-cluster-test --test local_cluster_test --features pg_integration
cargo nextest run --no-fail-fast --test-threads 1 --package iota-indexer --test ingestion_tests --features pg_integration
# Iota-indexer's RPC tests, which depend on a shared runtime, are incompatible with nextest due to its process-per-test execution model.
# cargo test, on the other hand, allows tests to share state and resources by default.
cargo test --profile simulator --package iota-indexer --test rpc-tests --features shared_test_runtime
uses: ./.github/workflows/_rust_tests.yml

move-tests:
uses: ./.github/workflows/_move_tests.yml
Expand Down

0 comments on commit 9f89e5f

Please sign in to comment.