Skip to content

🎨 cargo fmt

🎨 cargo fmt #2

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch: # Allow manual triggering
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Set Redis URL for tests
REDIS_URL: redis://localhost:6379
jobs:
check:
name: Check
runs-on: ubuntu-latest
services:
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Set up cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Check code format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Lint with clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Install Redis CLI
run: sudo apt-get install -y redis-tools
- name: Check Redis availability
run: ./scripts/check-redis.sh
env:
REDIS_URL: redis://localhost:6379
- name: Check compilation
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
test:
name: Test Suite
runs-on: ubuntu-latest
needs: check
services:
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Set up cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Install Redis CLI
run: sudo apt-get install -y redis-tools
- name: Check Redis availability
run: ./scripts/check-redis.sh
env:
REDIS_URL: redis://localhost:6379
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
env:
REDIS_URL: redis://localhost:6379
- name: Generate code coverage
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-tarpaulin
- name: Run cargo-tarpaulin
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --ignore-tests --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
file: ./cobertura.xml
fail_ci_if_error: false
security_audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-audit
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-audit
- name: Run cargo-audit
uses: actions-rs/cargo@v1
with:
command: audit
args: --deny-warnings
build:
name: Build
runs-on: ubuntu-latest
needs: [check, test]
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Set up cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: l402-server-example-rs
path: target/release/l402-server-example-rs
retention-days: 7
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [build]
if: github.ref == 'refs/heads/main' # Only run on main branch
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
push: false
tags: l402-server-example-rs:latest
cache-from: type=gha
cache-to: type=gha,mode=max