- Add 'rustup component add rustfmt' to both workflows - Resolves 'cargo-fmt is not installed' error - Now workflows can run formatting checks after successful compilation - Combined with clippy, this completes the Rust toolchain setup - Workflow should now complete successfully with all quality checks
114 lines
3.7 KiB
YAML
114 lines
3.7 KiB
YAML
name: Simple Build & Upload
|
|
|
|
# Simple workflow for building deb-bootupd and uploading artifacts
|
|
# Based on patterns from: https://domaindrivenarchitecture.org/pages/dda-pallet/
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
# Use official Rust image with Debian Trixie base - much better than manual Rust setup
|
|
# Rust 1.89.0 is pre-installed and > 1.84.1 requirement
|
|
image: rust:1.89-slim-trixie
|
|
steps:
|
|
- name: Checkout code and setup environment
|
|
run: |
|
|
apt update -y
|
|
apt install -y git curl pkg-config libssl-dev libsystemd-dev build-essential file
|
|
|
|
# Install Rust clippy component
|
|
rustup component add clippy
|
|
|
|
# Install Rust rustfmt component
|
|
rustup component add rustfmt
|
|
|
|
# Rust 1.89.0 is already installed in rust:1.89-slim-trixie
|
|
# No need for rustup or toolchain management!
|
|
echo "✅ Using pre-installed Rust from official image:"
|
|
rustc --version
|
|
cargo --version
|
|
|
|
# Clone repository
|
|
git clone https://git.raines.xyz/robojerk/deb-bootupd.git /tmp/deb-bootupd
|
|
cd /tmp/deb-bootupd
|
|
|
|
echo "Repository: $(git remote get-url origin)"
|
|
echo "Branch: $(git branch --show-current)"
|
|
echo "Commit: $(git rev-parse --short HEAD)"
|
|
|
|
# Verify Rust version meets requirements (need 1.84.1+)
|
|
RUST_VERSION=$(rustc --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1)
|
|
echo "Rust version: $RUST_VERSION"
|
|
|
|
if [ "$(printf '%s\n' "1.84.1" "$RUST_VERSION" | sort -V | head -n1)" != "1.84.1" ]; then
|
|
echo "❌ Rust version $RUST_VERSION is too old, need 1.84.1+"
|
|
exit 1
|
|
else
|
|
echo "✅ Rust version $RUST_VERSION meets requirement (1.84.1+)"
|
|
fi
|
|
|
|
# Rust environment is already set up in the container
|
|
echo "Rust environment ready:"
|
|
echo "RUSTUP_HOME: $RUSTUP_HOME"
|
|
echo "CARGO_HOME: $CARGO_HOME"
|
|
echo "PATH includes: $PATH"
|
|
|
|
- name: Build project
|
|
run: |
|
|
cd /tmp/deb-bootupd
|
|
|
|
echo "Building deb-bootupd in release mode..."
|
|
cargo build --release
|
|
|
|
echo "Build artifacts:"
|
|
ls -la target/release/
|
|
|
|
# Show binary info
|
|
if [ -f target/release/bootupd ]; then
|
|
echo "bootupd binary info:"
|
|
file target/release/bootupd
|
|
fi
|
|
|
|
- name: Run tests
|
|
run: |
|
|
cd /tmp/deb-bootupd
|
|
|
|
echo "Running tests..."
|
|
cargo test --release
|
|
|
|
echo "Running clippy..."
|
|
cargo clippy --release
|
|
|
|
echo "Checking formatting..."
|
|
cargo fmt --check
|
|
|
|
- name: Create artifacts
|
|
run: |
|
|
cd /tmp/deb-bootupd
|
|
|
|
mkdir -p artifacts
|
|
cp target/release/bootupd artifacts/
|
|
cp -r src/ artifacts/
|
|
cp Cargo.toml artifacts/
|
|
|
|
# Create build info
|
|
echo "Build: $(date) - $(git rev-parse --short HEAD)" > artifacts/build-info.txt
|
|
echo "Rust Version: $(rustc --version)" >> artifacts/build-info.txt
|
|
|
|
echo "Artifacts created:"
|
|
ls -la artifacts/
|
|
|
|
- name: Upload artifacts
|
|
uses: https://data.forgejo.org/actions/upload-artifact@v3
|
|
with:
|
|
name: deb-bootupd-build
|
|
path: /tmp/deb-bootupd/artifacts/
|
|
if-no-files-found: error
|
|
retention-days: 30
|