Skip to content

cargo fmt

cargo fmt #1991

Workflow file for this run

name: aquadoggo
on: push
env:
CARGO_TERM_COLOR: always
cache_path: |
target
~/.cargo
cargo_manifest: aquadoggo/Cargo.toml
jobs:
rust-test-sqlite:
runs-on: ubuntu-latest
steps:
- name: Install Protocol Buffers compiler
run: sudo apt-get install protobuf-compiler
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: >-
--verbose
--manifest-path ${{ env.cargo_manifest }}
# Related issue: https://github.com/p2panda/aquadoggo/issues/414
- name: Temporary workaround for rustc bug
uses: actions-rs/cargo@v1
with:
command: clean
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path ${{ env.cargo_manifest }}
env:
# Ensure debug output is also tested
RUST_LOG: debug
rust-test-postgres:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: aquadoggo-development
ports:
# Maps TCP port 5432 on service container to the host
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install Protocol Buffers compiler
run: sudo apt-get install protobuf-compiler
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}
# Related issue: https://github.com/p2panda/aquadoggo/issues/414
- name: Temporary workaround for rustc bug
uses: actions-rs/cargo@v1
with:
command: clean
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
# Make sure the tests run consecutively to avoid accessing the same
# database by multiple test threads
args: >-
--manifest-path ${{ env.cargo_manifest }}
-- --test-threads 1
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/aquadoggo-development
rust-check:
runs-on: ubuntu-latest
steps:
- name: Install Protocol Buffers compiler
run: sudo apt-get install protobuf-compiler
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-check-${{ hashFiles('**/Cargo.lock') }}
- name: Check project and dependencies
uses: actions-rs/cargo@v1
with:
command: check
args: --manifest-path ${{ env.cargo_manifest }}
rust-fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-fmt-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ${{ env.cargo_manifest }} -- --check
rust-clippy:
runs-on: ubuntu-latest
steps:
- name: Install Protocol Buffers compiler
run: sudo apt-get install protobuf-compiler
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-clippy-${{ hashFiles('**/Cargo.lock') }}
- name: Check code with clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path ${{ env.cargo_manifest }} -- -D warnings --no-deps
rust-coverage:
runs-on: ubuntu-latest
steps:
- name: Install Protocol Buffers compiler
run: sudo apt-get install protobuf-compiler
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-tarpaulin-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1
with:
version: '0.20.1'
# Force cleaning via `--force-clean` flag to prevent buggy code coverage
args: >-
--manifest-path ${{ env.cargo_manifest }}
--locked
--force-clean
-- --test-threads=1
env:
# Ensure debug output is also tested
RUST_LOG: debug
- name: Upload to codecov.io
uses: codecov/codecov-action@v2