particle-os-tools/.forgejo/workflows/compile-apt-layer-v2.yml
robojerk 2f8492e65f
Some checks failed
Compile apt-layer (v2) / compile (push) Has been cancelled
Fix YAML syntax error in workflow: replace heredoc with echo statements
2025-07-15 09:18:19 -07:00

324 lines
No EOL
13 KiB
YAML

name: Compile apt-layer (v2)
on:
push:
branches: [ main, master ]
paths:
- 'src/apt-layer/**'
- '.forgejo/workflows/compile-apt-layer*.yml'
pull_request:
branches: [ main, master ]
paths:
- 'src/apt-layer/**'
- '.forgejo/workflows/compile-apt-layer*.yml'
workflow_dispatch: # Allow manual triggering
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout code
run: |
echo "Cloning repository from Forgejo..."
git clone http://forgejo:3000/robojerk/particle-os-tools.git .
git checkout ${{ github.sha }}
echo "Repository checked out successfully"
- name: Set up environment
run: |
echo "Setting up compilation environment..."
# Try different package managers
if command -v apt-get >/dev/null 2>&1; then
echo "Using apt-get package manager..."
apt-get update
apt-get install -y jq dos2unix bash coreutils zip
elif command -v apk >/dev/null 2>&1; then
echo "Using apk package manager..."
apk update
apk add jq dos2unix bash coreutils zip
elif command -v yum >/dev/null 2>&1; then
echo "Using yum package manager..."
yum install -y jq dos2unix bash coreutils zip
elif command -v dnf >/dev/null 2>&1; then
echo "Using dnf package manager..."
dnf install -y jq dos2unix bash coreutils zip
else
echo "No supported package manager found. Checking if tools are already available..."
# Check if tools are already available
if ! command -v jq >/dev/null 2>&1; then
echo "❌ jq not found and no package manager available"
exit 1
fi
if ! command -v dos2unix >/dev/null 2>&1; then
echo "⚠️ dos2unix not found, but continuing..."
fi
if ! command -v bash >/dev/null 2>&1; then
echo "❌ bash not found and no package manager available"
exit 1
fi
if ! command -v numfmt >/dev/null 2>&1; then
echo "❌ numfmt not found and no package manager available"
exit 1
fi
if ! command -v zip >/dev/null 2>&1; then
echo "❌ zip not found and no package manager available"
exit 1
fi
echo "✅ Required tools are already available"
fi
- name: Make compile scripts executable
run: |
chmod +x src/apt-layer/compile.sh
chmod +x src/apt-layer/compile-installer.sh
- name: Compile apt-layer
run: |
echo "Compiling apt-layer..."
cd src/apt-layer
./compile.sh -o ../../apt-layer.sh
- name: Compile installer
run: |
echo "Compiling installer with latest paths.json..."
cd src/apt-layer
./compile-installer.sh -o ../../install-apt-layer.sh
- name: Verify compilation
run: |
echo "Verifying compiled scripts..."
# Check apt-layer.sh
if [[ ! -f apt-layer.sh ]]; then
echo "❌ apt-layer compilation failed - apt-layer.sh not found"
exit 1
fi
if [[ ! -x apt-layer.sh ]]; then
echo "❌ apt-layer script is not executable"
exit 1
fi
# Test apt-layer.sh syntax
if bash -n apt-layer.sh; then
echo "✅ apt-layer.sh syntax validation passed"
else
echo "❌ apt-layer.sh syntax validation failed"
exit 1
fi
# Check apt-layer.sh file size
file_size=$(du -h apt-layer.sh | cut -f1)
echo "📦 apt-layer.sh size: $file_size"
# Count apt-layer.sh lines
line_count=$(wc -l < apt-layer.sh)
echo "📄 apt-layer.sh lines: $line_count"
# Check install-apt-layer.sh
if [[ ! -f install-apt-layer.sh ]]; then
echo "❌ Installer compilation failed - install-apt-layer.sh not found"
exit 1
fi
if [[ ! -x install-apt-layer.sh ]]; then
echo "❌ Installer script is not executable"
exit 1
fi
# Test install-apt-layer.sh syntax
if bash -n install-apt-layer.sh; then
echo "✅ install-apt-layer.sh syntax validation passed"
else
echo "❌ install-apt-layer.sh syntax validation failed"
exit 1
fi
# Check install-apt-layer.sh file size
installer_size=$(du -h install-apt-layer.sh | cut -f1)
echo "📦 install-apt-layer.sh size: $installer_size"
# Count install-apt-layer.sh lines
installer_lines=$(wc -l < install-apt-layer.sh)
echo "📄 install-apt-layer.sh lines: $installer_lines"
- name: Test basic functionality
run: |
echo "Testing basic functionality..."
# Test apt-layer.sh help command
if ./apt-layer.sh --help > /dev/null 2>&1; then
echo "✅ apt-layer.sh help command works"
else
echo "❌ apt-layer.sh help command failed"
exit 1
fi
# Test apt-layer.sh version info
if ./apt-layer.sh --version > /dev/null 2>&1; then
echo "✅ apt-layer.sh version command works"
else
echo "⚠️ apt-layer.sh version command not available (this is optional)"
fi
# Test install-apt-layer.sh help command
if ./install-apt-layer.sh --help > /dev/null 2>&1; then
echo "✅ install-apt-layer.sh help command works"
else
echo "❌ install-apt-layer.sh help command failed"
exit 1
fi
- name: Create compilation report
run: |
echo "Creating compilation report..."
{
echo "# apt-layer Compilation Report"
echo ""
echo "**Compilation Date:** $(date)"
echo "**Commit:** ${{ github.sha }}"
echo "**Branch:** ${{ github.ref_name }}"
echo ""
echo "## File Information"
echo ""
echo "### apt-layer.sh"
echo "- **File:** apt-layer.sh"
echo "- **Size:** $(du -h apt-layer.sh | cut -f1)"
echo "- **Lines:** $(wc -l < apt-layer.sh)"
echo "- **Executable:** $(test -x apt-layer.sh && echo "Yes" || echo "No")"
echo ""
echo "### install-apt-layer.sh"
echo "- **File:** install-apt-layer.sh"
echo "- **Size:** $(du -h install-apt-layer.sh | cut -f1)"
echo "- **Lines:** $(wc -l < install-apt-layer.sh)"
echo "- **Executable:** $(test -x install-apt-layer.sh && echo "Yes" || echo "No")"
echo ""
echo "## Validation Results"
echo "- **apt-layer.sh Syntax Check:** $(bash -n apt-layer.sh && echo "✅ Passed" || echo "❌ Failed")"
echo "- **apt-layer.sh Help Command:** $(./apt-layer.sh --help > /dev/null 2>&1 && echo "✅ Works" || echo "❌ Failed")"
echo "- **install-apt-layer.sh Syntax Check:** $(bash -n install-apt-layer.sh && echo "✅ Passed" || echo "❌ Failed")"
echo "- **install-apt-layer.sh Help Command:** $(./install-apt-layer.sh --help > /dev/null 2>&1 && echo "✅ Works" || echo "❌ Failed")"
echo ""
echo "## Included Components"
echo ""
echo "### apt-layer.sh"
echo "- apt-layer configuration integration"
echo "- Transactional operations with automatic rollback"
echo "- Traditional chroot-based layer creation"
echo "- Container-based layer creation (Apx-style)"
echo "- OCI export/import integration"
echo "- Live overlay system (rpm-ostree style)"
echo "- Bootloader integration (UEFI/GRUB/systemd-boot)"
echo "- Atomic deployment system with rollback"
echo "- rpm-ostree compatibility layer"
echo "- ComposeFS backend integration"
echo "- Dependency validation and error handling"
echo "- Comprehensive JSON configuration system"
echo "- Direct dpkg installation (Performance optimization)"
echo ""
echo "### install-apt-layer.sh"
echo "- Latest paths.json configuration embedded"
echo "- All installation and uninstallation functionality"
echo "- Dependency checking and installation"
echo "- System initialization"
echo "- Proper error handling and validation"
echo ""
echo "## Ready for Distribution"
echo "Both compiled scripts are self-contained and ready for use!"
} > COMPILATION_REPORT.md
- name: Create artifacts directory
run: |
mkdir -p artifacts
cp apt-layer.sh artifacts/
cp install-apt-layer.sh artifacts/
cp COMPILATION_REPORT.md artifacts/
- name: Display compilation results
run: |
echo "=========================================="
echo "📦 COMPILATION COMPLETED SUCCESSFULLY"
echo "=========================================="
echo ""
echo "Generated files:"
echo "✅ apt-layer.sh ($(du -h apt-layer.sh | cut -f1))"
echo "✅ install-apt-layer.sh ($(du -h install-apt-layer.sh | cut -f1))"
echo "✅ COMPILATION_REPORT.md"
echo ""
echo "Files are available in the artifacts/ directory"
echo "=========================================="
- name: Create downloadable artifacts
run: |
echo "Creating downloadable artifacts..."
# Create a timestamp for the artifacts
timestamp=$(date +%Y%m%d-%H%M%S)
# Create a zip file with all artifacts
zip -r "apt-layer-compiled-${timestamp}.zip" artifacts/
# Create a simple download script
echo '#!/bin/bash' > download-artifacts.sh
echo 'echo "apt-layer Compiled Scripts Downloader"' >> download-artifacts.sh
echo 'echo "====================================="' >> download-artifacts.sh
echo 'echo ""' >> download-artifacts.sh
echo 'echo "This script will download the compiled apt-layer scripts."' >> download-artifacts.sh
echo 'echo ""' >> download-artifacts.sh
echo '' >> download-artifacts.sh
echo '# Check if we are in a workflow environment' >> download-artifacts.sh
echo 'if [[ -n "$GITHUB_WORKSPACE" ]]; then' >> download-artifacts.sh
echo ' echo "Running in workflow environment..."' >> download-artifacts.sh
echo ' echo "Artifacts are available in the artifacts/ directory"' >> download-artifacts.sh
echo ' echo ""' >> download-artifacts.sh
echo ' echo "Files:"' >> download-artifacts.sh
echo ' ls -la artifacts/' >> download-artifacts.sh
echo ' echo ""' >> download-artifacts.sh
echo ' echo "To download these files, check the workflow run artifacts section."' >> download-artifacts.sh
echo 'else' >> download-artifacts.sh
echo ' echo "Not in workflow environment."' >> download-artifacts.sh
echo ' echo "Please run this in the context of a workflow run."' >> download-artifacts.sh
echo 'fi' >> download-artifacts.sh
chmod +x download-artifacts.sh
echo "✅ Artifacts prepared for download"
echo "📦 Created: apt-layer-compiled-${timestamp}.zip"
echo "📄 Created: download-artifacts.sh"
echo ""
echo "Files available in artifacts/ directory:"
ls -la artifacts/
- name: Commit compiled scripts (if on main/master)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
run: |
echo "Committing compiled scripts to repository..."
# Configure git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Add the compiled files
git add apt-layer.sh install-apt-layer.sh
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "No changes to commit - compiled files are identical to repository"
else
# Commit the changes (this works even in detached HEAD)
git commit -m "Auto-compile apt-layer and installer from commit ${{ github.sha }}"
# Push directly to the target branch using the commit hash
echo "Pushing compiled scripts to ${{ github.ref_name }}..."
if git push origin HEAD:${{ github.ref_name }}; then
echo "✅ Compiled scripts successfully pushed to ${{ github.ref_name }}"
else
echo "⚠️ Failed to push to repository, but compilation was successful"
echo "📦 Compiled scripts are available in the artifacts/ directory"
echo "📝 You can manually download and commit the compiled scripts"
echo "📄 Check the workflow logs for the compiled files"
exit 0 # Don't fail the workflow, compilation was successful
fi
fi