Skip to content

Pool Indexer crate for uniswap-v3 liquidity from subgraphs #20212

Pool Indexer crate for uniswap-v3 liquidity from subgraphs

Pool Indexer crate for uniswap-v3 liquidity from subgraphs #20212

Workflow file for this run

name: pull request
on:
merge_group: {}
pull_request:
# We require PRs to be up to date before merging so technically it is not needed run the rust job
# on main. However for the cache to be usable in PRs we do need the job on main.
push:
branches: [main]
jobs:
lint:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- uses: tombi-toml/setup-tombi@9880d1d3ba5e745d410c697366c513b337704388 # v1.0.11
with:
version: "1.1.0"
- run: |
rustup --version
rustup show
cargo --version
cargo +nightly fmt --version
cargo clippy --version
tombi --version
- run: just fmt --check
- run: just clippy
- run: just fmt-toml --check
trivy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Run Trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: "fs"
format: "sarif"
output: "trivy-results.sarif"
- name: Upload Trivy scan results to GitHub Security
uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
with:
sarif_file: "trivy-results.sarif"
cargo-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
nitpicker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: ethanis/nitpicker@e891622bbd9a6ec97a473bcfacfca7332caf2862 # v1.7
with:
nitpicks: ".github/nitpicks.yml"
token: "${{ secrets.GITHUB_TOKEN }}"
doc-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- run: just test-doc
unit-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- run: cargo build --tests
- run: just test-unit
test-db:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
# Start the build process in the background. The following cargo test command will automatically
# wait for the build process to be done before proceeding.
- run: cargo build -p orderbook -p database -p autopilot --tests &
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- run: docker compose -f docker-compose.yaml up -d db
- run: docker compose -f docker-compose.yaml up migrations --abort-on-container-failure
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- run: just test-db
test-local-node:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
TOML_TRACE_ERROR: 1
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # v1.8.0
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
# Start the build process in the background. The following cargo test command will automatically
# wait for the build process to be done before proceeding.
- run: cargo build -p e2e --tests &
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- run: docker compose -f docker-compose.yaml up -d db
- run: docker compose -f docker-compose.yaml up migrations --abort-on-container-failure
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- run: just test-e2e-local
test-forked-node:
# Do not run this job on forks since some secrets are required for it.
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
FORK_URL_MAINNET: ${{ secrets.FORK_URL_MAINNET }}
FORK_URL_GNOSIS: ${{ secrets.FORK_URL_GNOSIS }}
TOML_TRACE_ERROR: 1
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # v1.8.0
with:
# the latest version introduced a bug caused forked node tests to fail
# only switch back to latest stable version after it was fixed in anvil
version: v1.0.0
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
# Start the build process in the background. The following cargo test command will automatically
# wait for the build process to be done before proceeding.
- run: cargo build -p e2e --tests &
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- run: docker compose -f docker-compose.yaml up -d db
- run: docker compose -f docker-compose.yaml up migrations --abort-on-container-failure
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- run: just test-e2e-forked
test-driver:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
TOML_TRACE_ERROR: 1
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # v1.8.0
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
# Build the driver's tests.
- run: cargo build -p driver --tests
# Don't spawn any docker containers. The driver's tests will spawn anvil itself.
- run: just test-driver
solidity-artifacts:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Build Solidity artifacts
working-directory: contracts/solidity
run: make -B artifacts
- name: Verify no JSON changes
run: |
if git diff --exit-code -- 'contracts/artifacts/*.json'; then
echo "✓ Solidity artifacts are up-to-date"
else
echo "✗ Solidity artifacts are out-of-date. Please run 'cd contracts/solidity && make -B artifacts' and commit the changes."
# run the command again to show exactly what the changes would be
git diff --exit-code -- 'contracts/artifacts/*.json'
exit 1
fi
openapi:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: npm install @apidevtools/swagger-cli @stoplight/spectral-cli
- run: node_modules/.bin/swagger-cli validate crates/orderbook/openapi.yml
- run: node_modules/.bin/swagger-cli validate crates/driver/openapi.yml
- run: node_modules/.bin/swagger-cli validate crates/solvers/openapi.yml
- run: node_modules/.bin/spectral lint crates/orderbook/openapi.yml
- run: node_modules/.bin/spectral lint crates/driver/openapi.yml
- run: node_modules/.bin/spectral lint crates/solvers/openapi.yml
run-flaky-test:
# to debug a flaky test set `if` to true and configure the flaky test in the `run` step
if: ${{ false }}
timeout-minutes: 60
runs-on: ubuntu-latest
env:
# Shrink artifact size by not including debug info. Makes build faster and shrinks cache.
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CARGO_TERM_COLOR: always
TOML_TRACE_ERROR: 1
FORK_URL_MAINNET: ${{ secrets.FORK_URL_MAINNET }}
FORK_URL_GNOSIS: ${{ secrets.FORK_URL_GNOSIS }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # v1.8.0
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
# Start the build process in the background. The following cargo test command will automatically
# wait for the build process to be done before proceeding.
- run: cargo build -p e2e --tests &
- uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # 2.79.7
with:
tool: nextest
- run: docker compose -f docker-compose.yaml up -d db
- run: docker compose -f docker-compose.yaml up migrations --abort-on-container-failure
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- name: Run test in a loop
run: |
attempt=1
while true; do
echo "Running test attempt #$attempt"
if ! just test-e2e forked_node_mainnet_repay_debt_with_collateral_of_safe; then
exit 1
fi
attempt=$((attempt+1))
done
generated-contracts:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- run: rustup toolchain install stable --profile minimal
- run: rustup toolchain install nightly --profile minimal --component rustfmt
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: 1.39.0
- uses: tombi-toml/setup-tombi@9880d1d3ba5e745d410c697366c513b337704388 # v1.0.11
with:
version: "1.1.0"
- name: Verify the code hasn't been tampered with by generating contracts again and making sure there has been no changes
run: |
just generate-contracts
if git diff --exit-code; then
echo "✓ Generated contracts are up-to-date"
else
echo "✗ Generated contracts are out-of-date or were modified by hand. Please run 'just generate-contracts' and commit the changes."
exit 1
fi