Skip to content

chore: Add rust audit GitHub action (#430) #859

chore: Add rust audit GitHub action (#430)

chore: Add rust audit GitHub action (#430) #859

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [ opened, reopened, synchronize ]
paths:
- ".github/workflows/ci-rust.yaml"
- "Cargo.*"
- "crates/**"
- "extra/**"
- "modules/meteroid/**"
- "modules/metering/**"
- "modules/adapters/**"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
naming:
permissions:
pull-requests: read
name: Validate PR title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
check:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang unzip libsasl2-dev
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-x86_64.zip
unzip protoc*.zip
sudo mv bin/protoc /usr/local/bin
sudo mv include/google /usr/local/include
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.6
- name: Install nextest
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-nextest
- name: Test
run: cargo nextest run
- name: Compile
run: cargo check
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang unzip libsasl2-dev
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-x86_64.zip
unzip protoc*.zip
sudo mv bin/protoc /usr/local/bin
sudo mv include/google /usr/local/include
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.6
- name: Linting
run: cargo clippy -- -D warnings
openapi:
name: Open API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang unzip libsasl2-dev
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-x86_64.zip
unzip protoc*.zip
sudo mv bin/protoc /usr/local/bin
sudo mv include/google /usr/local/include
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.6
- name: Validate OpenAPI
run: |
cargo run -p meteroid --bin openapi-generate
if [[ -n "$(git status --porcelain spec/api/v1/openapi.json)" ]]; then
echo "openapi.json is not up to date. Please run `cargo run -p meteroid --bin openapi-generate` and commit changes."
exit 1
fi