forked from ualberta-rcg/warewulf-slurmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-and-commit-slurm-debs.yml
More file actions
167 lines (140 loc) · 6.26 KB
/
Copy pathbuild-and-commit-slurm-debs.yml
File metadata and controls
167 lines (140 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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: ''
schedule:
- cron: '0 2 * * 1' # Every Monday at 2:00 AM UTC
jobs:
build-debs:
runs-on: ubuntu-24.04
container: ubuntu:26.04
outputs:
version: ${{ steps.vars.outputs.version }}
skip_build: ${{ steps.version-check.outputs.skip_build }}
steps:
- name: 🧰 Bootstrap Ubuntu 26.04 Container
run: |
set -e
apt-get update
apt-get install -y ca-certificates curl git jq
- name: 📦 Checkout Repository
uses: actions/checkout@v6
with:
# Fetch all history for all branches and tags
fetch-depth: 0
- name: 🎯 Determine Target Slurm Version
id: vars
run: |
set -e # Exit on error
# Use the manual dispatch input first, then the repo variable as a fallback
VERSION_OVERRIDE="${{ github.event.inputs.SLURM_VERSION_OVERRIDE || vars.SLURM_VERSION_OVERRIDE }}"
if [ -n "$VERSION_OVERRIDE" ] && [ "$VERSION_OVERRIDE" != "0" ]; then
echo "✅ Using specified version override: $VERSION_OVERRIDE"
VERSION="$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/')"
debdir="$GITHUB_WORKSPACE/slurm-debs"
OS_CODENAME="u2604"
echo "🔍 Inputs:"
echo " Raw version = $version"
echo " Debian version = $debver"
echo " Search directory = $debdir"
echo " Search pattern = *_${debver}_*_${OS_CODENAME}.deb"
mkdir -p "$debdir"
echo "📂 Directory contents before search:"
ls -l "$debdir" || true
count=$(find "$debdir" -type f -name "*_${debver}_*_${OS_CODENAME}.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
- name: 🛠 Install Build Dependencies
if: steps.version-check.outputs.skip_build == 'false'
run: |
apt-get update
apt-get install -y \
devscripts equivs build-essential fakeroot debhelper curl jq git \
libpmix-dev libpmix2 libopenmpi-dev libopenmpi40 openmpi-bin libnvidia-ml-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: 📦 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
OS_CODENAME="u2604" # Change to ${{ matrix.os_codename }} if using a matrix
DEST_DIR="$GITHUB_WORKSPACE/slurm-debs"
mkdir -p "$DEST_DIR"
# Move all .deb files from the parent directory
for deb in /tmp/slurm/*.deb; do
base=$(basename "$deb" .deb)
mv "$deb" "$DEST_DIR/${base}_${OS_CODENAME}.deb"
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
OS_CODENAME="u2604" # Change to ${{ matrix.os_codename }} if using a matrix
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
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 Ubuntu ${OS_CODENAME}"
git push
fi
env:
# Use a PAT if you have branch protection rules that GITHUB_TOKEN can't bypass
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}