mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
Integrate GitHub Actions workflows for CI, replacing legacy scripts with xtask automation for formatting, linting, builds, tests, and documentation. Update Jenkinsfile to clarify its restricted usage for illumos builds.
This commit is contained in:
parent
8c2ec7e965
commit
3ea955fc5f
3 changed files with 244 additions and 11 deletions
77
.github/README.md
vendored
Normal file
77
.github/README.md
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
# GitHub Actions Workflows for IPS
|
||||||
|
|
||||||
|
This directory contains GitHub Actions workflows for the Image Packaging System (IPS) project.
|
||||||
|
|
||||||
|
## Rust CI Workflow
|
||||||
|
|
||||||
|
The `rust.yml` workflow is the main CI pipeline for the IPS project. It uses the xtask build system to build, test, and validate the codebase.
|
||||||
|
|
||||||
|
### Workflow Structure
|
||||||
|
|
||||||
|
The workflow consists of several jobs that run in sequence:
|
||||||
|
|
||||||
|
1. **Format**: Checks that the code follows Rust formatting standards using `rustfmt`.
|
||||||
|
2. **Clippy**: Runs the Rust linter to check for common mistakes and enforce code quality.
|
||||||
|
3. **Build**: Builds the project using the xtask build system.
|
||||||
|
4. **Test**: Runs unit tests for all crates.
|
||||||
|
5. **End-to-End Tests**: Builds the binaries for end-to-end tests and runs them.
|
||||||
|
6. **Documentation**: Builds the Rust documentation for the project.
|
||||||
|
|
||||||
|
### Xtask Integration
|
||||||
|
|
||||||
|
The workflow uses the xtask build system for most operations. Xtask is a Rust-based build system that allows us to write build scripts and automation tasks in Rust instead of shell scripts, making them more maintainable and cross-platform.
|
||||||
|
|
||||||
|
The following xtask commands are used in the workflow:
|
||||||
|
|
||||||
|
- `cargo run -p xtask -- build`: Builds the project
|
||||||
|
- `cargo run -p xtask -- build -r`: Builds the project in release mode
|
||||||
|
- `cargo run -p xtask -- test`: Runs unit tests
|
||||||
|
- `cargo run -p xtask -- build-e2e`: Builds binaries for end-to-end tests
|
||||||
|
- `cargo run -p xtask -- run-e2e`: Runs end-to-end tests
|
||||||
|
|
||||||
|
For more information about xtask, see the [xtask README](../xtask/README.md).
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
The workflow follows several best practices for GitHub Actions:
|
||||||
|
|
||||||
|
1. **Caching**: Dependencies are cached to speed up builds.
|
||||||
|
2. **Matrix Strategy**: The build and test jobs use a matrix strategy to allow testing on multiple platforms and Rust versions.
|
||||||
|
3. **Job Dependencies**: Jobs are properly sequenced to ensure efficient execution.
|
||||||
|
4. **Artifact Uploads**: Build artifacts and documentation are uploaded for later use.
|
||||||
|
5. **Error Handling**: Warnings are treated as errors to maintain code quality.
|
||||||
|
6. **Manual Triggering**: The workflow can be triggered manually using the workflow_dispatch event.
|
||||||
|
|
||||||
|
### Running the Workflow Locally
|
||||||
|
|
||||||
|
You can run the same checks locally using the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Format check
|
||||||
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
|
# Clippy
|
||||||
|
cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
|
# Build
|
||||||
|
cargo run -p xtask -- build
|
||||||
|
|
||||||
|
# Test
|
||||||
|
cargo run -p xtask -- test
|
||||||
|
|
||||||
|
# End-to-End Tests
|
||||||
|
cargo run -p xtask -- build-e2e
|
||||||
|
cargo run -p xtask -- run-e2e
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
cargo doc --no-deps
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If you encounter issues with the workflow:
|
||||||
|
|
||||||
|
1. Check that your code passes all checks locally.
|
||||||
|
2. Ensure that the xtask crate is properly set up.
|
||||||
|
3. Look at the workflow logs for specific error messages.
|
||||||
|
4. For end-to-end test failures, try running the tests locally with more verbose output.
|
||||||
176
.github/workflows/rust.yml
vendored
176
.github/workflows/rust.yml
vendored
|
|
@ -1,24 +1,178 @@
|
||||||
name: Rust
|
name: Rust CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ main, master ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ main, master ]
|
||||||
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
RUSTFLAGS: "-D warnings" # Treat warnings as errors
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# Check code formatting
|
||||||
|
format:
|
||||||
|
name: Format
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt
|
||||||
|
- name: Check formatting
|
||||||
|
run: cargo run -p xtask -- fmt
|
||||||
|
|
||||||
- name: Build
|
# Run clippy for linting
|
||||||
run: cargo build --verbose
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: clippy
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
target
|
||||||
|
key: ${{ runner.os }}-clippy-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
restore-keys: ${{ runner.os }}-clippy-
|
||||||
|
- name: Run clippy
|
||||||
|
run: cargo run -p xtask -- clippy
|
||||||
|
|
||||||
- name: Run tests
|
# Build the project
|
||||||
run: cargo test --verbose
|
build:
|
||||||
|
name: Build
|
||||||
|
needs: [format, clippy]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
rust: [stable]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
- 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
|
||||||
|
run: cargo run -p xtask -- build
|
||||||
|
- name: Build release
|
||||||
|
run: cargo run -p xtask -- build -r
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ips-binaries-${{ matrix.os }}
|
||||||
|
path: target/release/
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
rust: [stable]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
- 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: Run tests
|
||||||
|
run: cargo run -p xtask -- test
|
||||||
|
|
||||||
|
# Run end-to-end tests
|
||||||
|
e2e-test:
|
||||||
|
name: End-to-End Tests
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
- 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 E2E test binaries
|
||||||
|
run: cargo run -p xtask -- build-e2e
|
||||||
|
- name: Run E2E tests
|
||||||
|
run: cargo run -p xtask -- run-e2e
|
||||||
|
|
||||||
|
# Build documentation
|
||||||
|
docs:
|
||||||
|
name: Documentation
|
||||||
|
needs: [test, e2e-test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
- 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 documentation
|
||||||
|
run: cargo doc --no-deps
|
||||||
|
- name: Upload documentation
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: rust-docs
|
||||||
|
path: target/doc
|
||||||
|
retention-days: 7
|
||||||
|
|
|
||||||
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
|
// This Jenkinsfile is only used for illumos builds.
|
||||||
|
// For all other CI workflows, GitHub Actions is used (see .github/workflows/rust.yml)
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
node {
|
node {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue