135 lines
3.5 KiB
YAML
135 lines
3.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, dev ]
|
|
pull_request:
|
|
branches: [ main, dev ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
redis:
|
|
image: redis
|
|
ports:
|
|
- 6379:6379
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Build with extreme memory optimization
|
|
run: |
|
|
# Create additional swap for memory-intensive compilation
|
|
sudo fallocate -l 4G /swapfile || sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
|
|
sudo chmod 600 /swapfile
|
|
sudo mkswap /swapfile
|
|
sudo swapon /swapfile
|
|
|
|
# Apply memory optimizations for CI environment
|
|
export CARGO_NET_GIT_FETCH_WITH_CLI=true
|
|
export CARGO_NET_RETRY=3
|
|
export CARGO_NET_TIMEOUT=60
|
|
export CARGO_HTTP_TIMEOUT=60
|
|
export RUSTC_FORCE_INCREMENTAL=0
|
|
|
|
# Build with all optimizations
|
|
cargo build --verbose
|
|
|
|
# Clean up swap
|
|
sudo swapoff /swapfile || true
|
|
sudo rm -f /swapfile || true
|
|
|
|
- name: Install cargo-llvm-cov
|
|
run: |
|
|
mkdir -p $HOME/.cargo/bin
|
|
curl -LO https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
tar xf cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
chmod +x cargo-llvm-cov
|
|
mv cargo-llvm-cov $HOME/.cargo/bin/
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
rm cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz
|
|
|
|
- name: Run tests
|
|
run: cargo test --verbose --tests
|
|
|
|
- name: Generate code coverage
|
|
run: |
|
|
cargo llvm-cov --lcov --output-path lcov.info
|
|
cargo llvm-cov --html
|
|
|
|
- name: Extract Coverage Percentage
|
|
id: coverage
|
|
run: |
|
|
COVERAGE=$(cargo llvm-cov --summary | grep -oP 'coverage: \K[0-9.]+%' || echo "0%")
|
|
echo "total_coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
|
echo "Coverage: $COVERAGE"
|
|
|
|
- name: Upload coverage HTML
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: code-coverage
|
|
path: target/llvm-cov/html
|
|
|
|
- name: Upload LCOV report
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: lcov-report
|
|
path: lcov.info
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Clippy with memory optimization
|
|
run: |
|
|
# Apply same memory optimizations for clippy
|
|
export CARGO_NET_GIT_FETCH_WITH_CLI=true
|
|
export RUSTC_FORCE_INCREMENTAL=0
|
|
# Run clippy with our allow list for collapsible_if
|
|
cargo clippy -- -D warnings -A clippy::collapsible-if
|
|
|