Build and Commit Slurm DEB Packages #245
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Commit Slurm DEB Packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| SLURM_VERSION_OVERRIDE: | |
| description: 'Optional: Specific Slurm version to build (e.g., 24-11-5-1). Leave empty to use latest.' | |
| required: false | |
| default: '' | |
| jobs: | |
| build-and-commit-debs: | |
| runs-on: ubuntu-22.04 # Host runner (required by GitHub Actions) | |
| container: | |
| image: debian:bullseye-slim | |
| options: --user root # Run as root for build process | |
| steps: | |
| - name: 🐛 Debug Information | |
| run: | | |
| echo "Event name: ${{ github.event_name }}" | |
| echo "Event type: ${{ github.event.type }}" | |
| echo "Actor: ${{ github.actor }}" | |
| echo "Repository: ${{ github.repository }}" | |
| echo "Ref: ${{ github.ref }}" | |
| echo "SHA: ${{ github.sha }}" | |
| echo "Workflow: ${{ github.workflow }}" | |
| echo "Job: ${{ github.job }}" | |
| echo "Run ID: ${{ github.run_id }}" | |
| echo "Run number: ${{ github.run_number }}" | |
| echo "Current time: $(date)" | |
| echo "UTC time: $(date -u)" | |
| echo "User: $(whoami)" | |
| echo "UID: $(id -u)" | |
| - name: 🎯 Determine Target Slurm Version | |
| id: vars | |
| run: | | |
| set -e # Exit on error | |
| apt-get update | |
| apt-get install jq curl git -y | |
| # Check if this is a manual dispatch with version override | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}" ]; then | |
| echo "✅ Using manual dispatch version override: ${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}" | |
| VERSION="${{ github.event.inputs.SLURM_VERSION_OVERRIDE }}" | |
| else | |
| echo "🔍 No version override set. Detecting latest stable version..." | |
| # Fetch all tags from the SchedMD/slurm repo | |
| TAGS=$(curl -s https://api.github.com/repos/SchedMD/slurm/tags | jq -r '.[].name') | |
| # Filter for stable release tags (e.g., slurm-23-11-7-1) and get the latest | |
| LATEST_TAG=$(echo "$TAGS" \ | |
| | grep -E '^slurm-[0-9]+-[0-9]+-[0-9]+-[0-9]+$' \ | |
| | sort -V \ | |
| | tail -n1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "❌ Could not determine the latest Slurm tag." | |
| exit 1 | |
| fi | |
| VERSION="${LATEST_TAG#slurm-}" | |
| echo "🔬 Detected latest version: $VERSION" | |
| fi | |
| # Construct the tag name and download URL | |
| TAG_NAME="slurm-${VERSION}" | |
| TARBALL_URL="https://codeload.github.com/SchedMD/slurm/tar.gz/refs/tags/${TAG_NAME}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "tarball_url=${TARBALL_URL}" >> $GITHUB_OUTPUT | |
| - name: 🛑 Check if DEBs for this version already exist | |
| id: version-check | |
| run: | | |
| version="${{ steps.vars.outputs.version }}" | |
| debver="$(echo "$version" | sed 's/^\([0-9]*\)-\([0-9]*\)-\([0-9]*\)-\([0-9]*\)$/\1.\2.\3-\4/')" | |
| echo "🔍 Inputs:" | |
| echo " Raw version = $version" | |
| echo " Debian version = $debver" | |
| echo " Search pattern = *_${debver}_*.deb" | |
| # Clone the repo to check for existing DEBs | |
| git clone https://github.com/${{ github.repository }}.git /tmp/repo | |
| cd /tmp/repo | |
| if [ -d "slurm-debs" ]; then | |
| count=$(find "slurm-debs" -type f -name "*_${debver}_*.deb" | wc -l || true) | |
| if [ "$count" -gt 0 ]; then | |
| echo "✅ DEBs for Slurm $version already exist. Skipping build." | |
| echo "skip_build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "🚧 No existing DEBs for Slurm $version. Proceeding with build." | |
| echo "skip_build=false" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "🚧 No slurm-debs directory found. Proceeding with build." | |
| echo "skip_build=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: 🛠 Install Build Dependencies | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| apt-get update | |
| echo "🔍 Checking available packages in Debian Bullseye..." | |
| apt-cache policy devscripts equivs build-essential fakeroot debhelper curl jq git libpmix-dev libpmix2 libopenmpi-dev libopenmpi3 openmpi-bin libpam0g-dev | |
| echo "📦 Installing build dependencies..." | |
| apt-get install -y \ | |
| devscripts equivs build-essential fakeroot debhelper curl jq git \ | |
| libpmix-dev libpmix2 libopenmpi-dev libopenmpi3 openmpi-bin \ | |
| libpam0g-dev | |
| - name: 📥 Download and Extract Slurm Source | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| set -e | |
| mkdir -p /tmp/slurm && cd /tmp/slurm | |
| echo "Downloading from ${{ steps.vars.outputs.tarball_url }}" | |
| curl -L "${{ steps.vars.outputs.tarball_url }}" -o slurm.tar.gz | |
| tar -xzf slurm.tar.gz | |
| src_dir=$(find . -maxdepth 1 -type d -name "slurm-*") | |
| mv "$src_dir" slurm-src | |
| - name: 🔧 Fix PAM Configuration in debian/rules | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| set -e | |
| cd /tmp/slurm/slurm-src | |
| # Why PAM might have stopped working: | |
| # - Newer Slurm versions (e.g., 25.11) added stricter validation for PAM directory paths | |
| # - The debian/rules file may now use /usr/lib/x86_64-linux-gnu/security which doesn't exist | |
| # - Configure script now validates the path exists before accepting it | |
| if [ -f debian/rules ]; then | |
| echo "🔧 Analyzing PAM configuration in debian/rules..." | |
| echo "📋 Current PAM-related configuration:" | |
| grep -n "pam\|PAM\|with-pam_dir\|enable-pam" debian/rules || echo "No PAM references found" | |
| # Fix the PAM directory path - ensure it exists so configure accepts it | |
| # The debian packaging expects /usr/lib/x86_64-linux-gnu/security, so we keep that path | |
| # but create the directory so configure doesn't reject it | |
| if grep -q "with-pam_dir" debian/rules; then | |
| echo "🔧 Ensuring PAM directory exists for configure..." | |
| # Create the directory that configure will check (and where debian expects files) | |
| mkdir -p /usr/lib/x86_64-linux-gnu/security || true | |
| echo "✅ PAM directory /usr/lib/x86_64-linux-gnu/security created" | |
| echo "✅ PAM will be enabled and built with correct directory" | |
| fi | |
| echo "📋 Final PAM-related configuration:" | |
| grep -n "pam\|PAM\|with-pam_dir\|enable-pam" debian/rules || echo "✅ No PAM references remaining" | |
| else | |
| echo "⚠️ debian/rules not found, skipping patch" | |
| fi | |
| - name: 📦 Build Slurm DEBs | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| set -e | |
| cd /tmp/slurm/slurm-src | |
| # Use mk-build-deps to install dependencies from debian/control | |
| mk-build-deps -ir --tool='apt-get -qq -y ' debian/control | |
| # Build binary packages only, without signing | |
| debuild -b -uc -us | |
| - name: 📁 Rename and Move DEBs to Repo | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| set -e | |
| DEST_DIR="/tmp/repo/slurm-debs" | |
| mkdir -p "$DEST_DIR" | |
| # Move all .deb files from the parent directory without renaming | |
| # The packages already have proper names from debuild (including architecture) | |
| for deb in /tmp/slurm/*.deb; do | |
| if [ -f "$deb" ]; then | |
| mv "$deb" "$DEST_DIR/" | |
| fi | |
| done | |
| echo "Moved DEBs to $DEST_DIR" | |
| ls -l "$DEST_DIR" | |
| - name: 📤 Commit and Push DEBs | |
| if: steps.version-check.outputs.skip_build == 'false' | |
| run: | | |
| set -e | |
| cd /tmp/repo | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Configure git to use the token for authentication | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
| git add slurm-debs/ | |
| # Check if there are staged changes before committing | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit." | |
| else | |
| git commit -m "Add Slurm DEBs (v${{ steps.vars.outputs.version }}) for Debian" | |
| git push origin HEAD:${{ github.ref_name }} | |
| fi |