Some checks failed
CI Pipeline / Rust Format Check (push) Successful in 4s
CI Pipeline / Clippy Lints (push) Successful in 45s
CI Pipeline / Security Audit (push) Has been cancelled
CI Pipeline / Frontend Lint & Type Check (push) Has been cancelled
CI Pipeline / Build .deb & Release (push) Has been cancelled
CI Pipeline / Rust Unit Tests (push) Has been cancelled
278 lines
8.8 KiB
YAML
278 lines
8.8 KiB
YAML
name: CI Pipeline
|
|
|
|
"on":
|
|
push:
|
|
branches: [master]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
# ─── Quality Gates (run on every push/PR/tag) ───
|
|
|
|
rust-format:
|
|
name: Rust Format Check
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install checkout dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends curl ca-certificates
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Ensure Rust toolchain
|
|
run: |
|
|
if ! command -v cargo &>/dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. "$HOME/.cargo/env"
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
rustup component add rustfmt
|
|
echo "Rust: $(cargo --version)"
|
|
echo "Rustfmt: $(rustfmt --version)"
|
|
|
|
- name: Check formatting
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo fmt --check --all 2>&1
|
|
|
|
clippy:
|
|
name: Clippy Lints
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends curl ca-certificates pkg-config libssl-dev
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Ensure Rust toolchain
|
|
run: |
|
|
if ! command -v cargo &>/dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. "$HOME/.cargo/env"
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
rustup component add clippy
|
|
echo "Rust: $(cargo --version)"
|
|
|
|
- name: Run Clippy
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo clippy --all-targets --all-features 2>&1
|
|
|
|
rust-test:
|
|
name: Rust Unit Tests
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends curl ca-certificates pkg-config libssl-dev
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Ensure Rust toolchain
|
|
run: |
|
|
if ! command -v cargo &>/dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. "$HOME/.cargo/env"
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
echo "Rust: $(cargo --version)"
|
|
|
|
- name: Run tests
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo test --workspace --all-features 2>&1
|
|
|
|
security-audit:
|
|
name: Security Audit
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install checkout dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends curl ca-certificates
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Ensure Rust toolchain
|
|
run: |
|
|
if ! command -v cargo &>/dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. "$HOME/.cargo/env"
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
echo "Rust: $(cargo --version)"
|
|
|
|
- name: Install cargo-audit
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo install cargo-audit 2>&1
|
|
|
|
- name: Run security audit
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo audit 2>&1
|
|
|
|
frontend-lint:
|
|
name: Frontend Lint & Type Check
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install checkout dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends curl ca-certificates
|
|
|
|
- name: Install Node.js 18
|
|
run: |
|
|
# Download and install Node.js 18 binary directly
|
|
NODE_VERSION="18.20.8"
|
|
curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz" -o /tmp/nodejs.tar.gz
|
|
tar -xzf /tmp/nodejs.tar.gz -C /usr/local --strip-components=1
|
|
rm -f /tmp/nodejs.tar.gz
|
|
# Create symlinks
|
|
ln -sf /usr/local/bin/node /usr/bin/node
|
|
ln -sf /usr/local/bin/npm /usr/bin/npm
|
|
ln -sf /usr/local/bin/npx /usr/bin/npx
|
|
node --version
|
|
npm --version
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Install Node.js dependencies
|
|
working-directory: frontend
|
|
run: npm ci
|
|
|
|
- name: Run ESLint
|
|
working-directory: frontend
|
|
run: npx eslint src/ --ext .ts,.tsx --max-warnings 0 2>&1
|
|
|
|
- name: TypeScript type check
|
|
working-directory: frontend
|
|
run: npx tsc --noEmit 2>&1
|
|
|
|
# ─── Build & Release (only on tag pushes, gated by quality checks) ───
|
|
|
|
build-and-release:
|
|
name: Build .deb & Release
|
|
runs-on: ubuntu-22.04
|
|
needs: [rust-format, clippy, rust-test, security-audit, frontend-lint]
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends \
|
|
curl ca-certificates pkg-config libssl-dev \
|
|
git nodejs npm dpkg-dev python3
|
|
|
|
- name: Checkout repository
|
|
run: |
|
|
TOKEN="${{ secrets.GITEATOKEN }}"
|
|
curl -sf -H "Authorization: token ${TOKEN}" \
|
|
"https://gitea-lxc.moon-dragon.us/echo/linux_patch_manager/archive/${GITHUB_SHA}.tar.gz" \
|
|
-o repo.tar.gz
|
|
tar xzf repo.tar.gz --strip-components=1
|
|
rm repo.tar.gz
|
|
|
|
- name: Ensure Rust toolchain
|
|
run: |
|
|
if ! command -v cargo &>/dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
. "$HOME/.cargo/env"
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
echo "Rust: $(cargo --version)"
|
|
|
|
- name: Build Rust backend (release)
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo build --release 2>&1
|
|
|
|
- name: Run Rust tests
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo test --workspace --all-features 2>&1
|
|
|
|
- name: Strip binaries
|
|
run: |
|
|
strip target/release/pm-web target/release/pm-worker
|
|
|
|
- name: Build frontend
|
|
run: |
|
|
cd frontend && npm ci && npm run build
|
|
|
|
- name: Determine version
|
|
run: |
|
|
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\(.*\)"/\1/')
|
|
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
|
|
echo "Building version: ${VERSION}"
|
|
|
|
- name: Assemble .deb package
|
|
run: |
|
|
chmod +x scripts/build-package.sh
|
|
scripts/build-package.sh
|
|
|
|
- name: Verify package
|
|
run: |
|
|
ls -la target/package/*.deb
|
|
dpkg-deb -I target/package/linux-patch-manager_*.deb
|
|
|
|
- name: Create Gitea Release (tags only)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\(.*\)"/\1/')
|
|
REPO="${GITHUB_REPOSITORY:-echo/linux_patch_manager}"
|
|
REF_NAME="${GITHUB_REF_NAME:-v${VERSION}}"
|
|
DEB=$(ls target/package/linux-patch-manager_*.deb)
|
|
python3 scripts/create-release.py \
|
|
--repo "${REPO}" \
|
|
--tag "${REF_NAME}" \
|
|
--title "Release ${REF_NAME}" \
|
|
--token "${{ secrets.GITEATOKEN }}" \
|
|
--gitea-url "https://gitea-lxc.moon-dragon.us"
|