debian

Debian上Rust项目如何进行持续集成

小樊
34
2025-11-17 09:19:24
栏目: 编程语言

Debian上Rust项目的持续集成实践

一、方案总览

二、GitHub Actions模板

示例:

name: Rust CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        run: rustup default stable

      - name: Check formatting
        run: cargo fmt -- --check

      - name: Lint with clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Build
        run: cargo build --verbose

      - name: Run tests
        run: cargo test --verbose

要点:

三、GitLab CI模板

示例:

stages:
  - check
  - test

variables:
  CARGO_HOME: $CI_PROJECT_DIR/.cargo

before_script:
  - rustup toolchain add stable
  - rustup default stable
  - cargo --version
  - rustc --version

fmt:
  stage: check
  script:
    - cargo fmt -- --check

clippy:
  stage: check
  script:
    - cargo clippy --all-targets --all-features -- -D warnings

build:
  stage: test
  script:
    - cargo build --verbose

test:
  stage: test
  script:
    - cargo test --verbose

要点:

四、质量门禁与扩展

0
看了该问题的人还看了