Skip to content

Commit

Permalink
Add rust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Feb 13, 2024
1 parent cf9402d commit 5b42f89
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/tests-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:

env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]

runs-on: [self-hosted, '${{ matrix.os }}']
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./target
key: ${{ matrix.os }}-geyser-plugin-runner-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}-0001
restore-keys: |
${{ matrix.os }}-geyser-plugin-runner
- name: Set rust version
run: |
RUST_VERSION="$(./ci/rust-version.sh)"
echo "RUST_VERSION=$RUST_VERSION" >> "$GITHUB_ENV"
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
profile: minimal
components: clippy, rustfmt

- name: cargo tree
run: |
cargo tree
git checkout Cargo.lock
cargo tree --frozen --offline
- name: Run fmt
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets --tests -- -Dwarnings

- name: Run test
run: cargo test --all-targets
9 changes: 9 additions & 0 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Prints Rust version

while read -r name equals value _; do
if [[ $name = "channel" && $equals = = ]]; then
echo "${value//\"/}"
fi
done < <(cat $(dirname "${BASH_SOURCE[0]}")/../rust-toolchain.toml)

0 comments on commit 5b42f89

Please sign in to comment.