1- name : Check lock file, fmt, clippy
2- # This workflow uses github runners.
1+ ---
2+ name : Test code
33concurrency :
44 group : ${{ github.workflow }}-${{ github.ref }}
55 cancel-in-progress : true
66
7- # This may be adjusted to whatever suits best your runners config.
8- # Current config will build on manual trigger or pull-request (each push)
97on :
10- # pull_request can be removed, to save minutes on github runners
11- pull_request :
128 push :
13- branches :
14- - " main"
159 workflow_dispatch :
10+
1611env :
1712 CARGO_TERM_COLOR : always
13+
1814jobs :
1915 test :
20- runs-on : ubuntu-22.04
16+ strategy :
17+ matrix :
18+ os : [ubuntu-22.04]
19+
20+ runs-on : ["${{ matrix.os }}"]
2121 steps :
22- - name : checkout repo
23- uses : actions/checkout@v4
24- - name : set build cache
25- uses : actions/cache@v4
22+ - uses : actions/checkout@v4
23+ with :
24+ submodules : recursive
25+ fetch-depth : 0
26+
27+ - uses : actions/cache@v4
2628 with :
2729 path : |
2830 ~/.cargo/bin/
2931 ~/.cargo/registry/index/
3032 ~/.cargo/registry/cache/
3133 ~/.cargo/git/db/
32- yellowstone-vixen/target/
33- key : cargo-${{ hashFiles('**/Cargo.lock') }}-0002
34+ ./target
35+ key : v0001-${{ matrix.os }}-rust-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
36+ restore-keys : |
37+ v0001-${{ matrix.os }}-rust-${{ hashFiles('rust-toolchain.toml') }}
3438
35- # Cache Rust Nightly Toolchain
36- - name : Cache Rust Nightly
37- id : cache-rust-nightly
38- uses : actions/cache@v4
39- with :
40- path : ~/.rustup
41- key : rust-nightly-0001-${{ runner.os }}-${{ hashFiles('rust-toolchain') }}
39+ - name : Set rust version
40+ run : |
41+ echo "channel=$(cat rust-toolchain.toml | grep channel | awk '{print $3}' | sed 's/"//g')" >> "$GITHUB_ENV"
42+ echo "targets=$(cat rust-toolchain.toml | grep targets | awk '{print $3}' | sed 's/\[//' | sed 's/\]//' | sed 's/"//g')" >> "$GITHUB_ENV"
43+ echo "components=$(cat rust-toolchain.toml | grep components | awk -F = '{print $2}' | sed 's/\[//' | sed 's/\]//' | sed 's/"//g')" >> "$GITHUB_ENV"
4244
43- - name : Install Rust Nightly if Not Cached
44- if : steps.cache-rust-nightly.outputs.cache-hit != 'true'
45- uses : actions-rs/toolchain@v1
45+ - uses : dtolnay/rust-toolchain@stable
4646 with :
4747 toolchain : nightly
48- components : rustfmt, clippy
4948
50- - name : Check Rust Toolchain Version
51- run : |
52- rustc +nightly --version
53- rustc --version
54- cargo --version
55-
56- - name : Install Latest Protoc
57- run : |
58- PROTOC_VERSION=26.1
59- ARCH=x86_64
60- curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${ARCH}.zip
61- sudo apt-get update
62- sudo apt-get install -y unzip protobuf-compiler libprotobuf-dev
63- unzip protoc-${PROTOC_VERSION}-linux-${ARCH}.zip -d $HOME/.local
64- echo "$HOME/.local/bin" >> $GITHUB_PATH
65- protoc --version
49+ - uses : dtolnay/rust-toolchain@stable
50+ with :
51+ toolchain : ${{ env.channel }}
52+ components : ${{ env.components }}
6653
67- # Cargo.lock
68- - name : Check lock file
54+ - name : cargo tree
6955 run : |
7056 cargo tree
7157 git checkout Cargo.lock
72- cargo tree
58+ cargo tree --frozen --offline
7359
74- # fmt
75- - name : Check fmt
60+ - name : Install toolchain components
61+ run : |
62+ rustup component add --toolchain nightly rustfmt
63+ rustup component add --toolchain ${{ env.channel }} clippy
64+
65+ - name : Run fmt
7666 run : cargo +nightly fmt --all -- --check
7767
78- # clippy
79- - name : Check clippy
68+ - name : cargo deny check advisories
69+ uses : EmbarkStudios/cargo-deny-action@v1
70+ with :
71+ command : check advisories
72+
73+ - name : install protoc
74+ run : |
75+ sudo apt update
76+ sudo apt install protobuf-compiler
77+
78+ - name : Run clippy
8079 run : cargo clippy --all-targets --tests -- -Dwarnings
80+
81+ - name : Test build
82+ run : |
83+ cargo build
0 commit comments