Files
rustfs/.github/workflows/rust.yml
2024-10-11 20:02:39 +08:00

98 lines
2.7 KiB
YAML

name: Rust
on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
skip-check:
permissions:
actions: write
contents: read
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'same_content_newer'
cancel_others: true
paths_ignore: '["*.md"]'
build:
# See this url if required matrix jobs are hanging
# https://github.com/fkirc/skip-duplicate-actions#how-to-use-skip-check-with-required-matrix-jobs
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
steps:
- name: cache protoc bin
id: cache-protoc-action
uses: actions/cache@v4
env:
cache-name: cache-protoc-action-bin
with:
path: /usr/local/bin/protoc
key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1
- name: install protoc
if: steps.cache-protoc-action.outputs.cache-hit != 'true'
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip
unzip protoc-27.0-linux-x86_64.zip -d protoc3
mv protoc3/bin/* /usr/local/bin/
chmod +x /usr/local/bin/protoc
rm -rf protoc-27.0-linux-x86_64.zip protoc3
- name: print protoc version
run: protoc --version
- name: cache flatc bin
id: cache-flatc-action
uses: actions/cache@v4
env:
cache-name: cache-flatc-action-bin
with:
path: /usr/local/bin/flatc
key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1
- name: install flatc
if: steps.cache-flatc-action.outputs.cache-hit != 'true'
run: |
wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip
unzip Linux.flatc.binary.g++-13.zip
mv flatc /usr/local/bin/
chmod +x /usr/local/bin/flatc
rm -rf Linux.flatc.binary.g++-13.zip
- uses: actions/checkout@v4
- name: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: cargo fmt --all --check
- name: cargo clippy
run: cargo clippy -- -D warnings
- name: cargo test
run: cargo test --all --exclude e2e_test