Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: changelog

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: changelog-${{ github.ref }}
cancel-in-progress: true

jobs:
draft:
name: towncrier build --draft
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
- name: Draft the changelog
run: |
set -euo pipefail
# The draft heading needs a version; Cargo.toml holds the one a release cuts.
version=$(sed -n '0,/^version = /s/^version = "\(.*\)"$/\1/p' Cargo.toml)
test -n "$version"
uvx [email protected] build --draft --version "$version"
- name: A malformed fragment fails the draft
run: |
set -euo pipefail
version=$(sed -n '0,/^version = /s/^version = "\(.*\)"$/\1/p' Cargo.toml)
name=not-a-fragment.md
printf '%s\n' 'This name has no fragment type.' > "changelog.d/$name"
set +e
out=$(uvx [email protected] build --draft --version "$version" 2>&1)
code=$?
set -e
printf '%s\n' "$out"
rm -f "changelog.d/$name"
test "$code" -ne 0
printf '%s\n' "$out" | grep -F "Invalid news fragment name: $name"
1 change: 1 addition & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ jobs:
--test eb_robot_paths \
--test easyblock_layers \
--test easyblock_owed \
--test eessi_extend_eb_script \
--test extension_provides \
--test family_site_layer \
--test fetch_prs_script \
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project are documented here.

<!-- towncrier release notes start -->

## 0.7.4 - 2026-11-13

### Added
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Build heavy work on a remote builder when local compiles thrash the machine.
either a unit test or an integration test under `tests/`
- Known maintainer-bump regressions live in `tests/reproduce_real_prs.rs` and
must stay green (library **and** CLI auto-bump)
- Every pull request adds a news fragment, `changelog.d/+<topic>.<type>.md`
with type `feature`, `bugfix`, `doc`, `removal` or `misc`;
`towncrier build --draft --version X.Y.Z` shows how it renders

## Documentation

Expand Down Expand Up @@ -84,7 +87,8 @@ Keep these in lockstep on every release:
2. `pyproject.toml` `version` and `server.json` (both `version` fields)
3. `CITATION.cff` `version`
4. `docs/source/conf.py` `release`
5. `CHANGELOG.md`: move Unreleased notes into `## X.Y.Z - YYYY-MM-DD`
5. `CHANGELOG.md`: `towncrier build --version X.Y.Z` turns the fragments in
`changelog.d/` into `## X.Y.Z - YYYY-MM-DD`
6. `CITATION.cff`: add `date-released` when the version is published
7. The version a recorded command prints: `README.md`, this file,
`docs/orgmode/index.org` (the install section), `docs/orgmode/install.org`,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+eessi-extend-eb.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`scripts/eessi-extend-eb.sh` defaults to EESSI 2026.06, takes the repository from `EESSI_CVMFS_REPO`, puts the compatibility layer's `ld` on `PATH` from `EESSI_EPREFIX` whether or not `EESSI_VERSION` was set, and creates a named `EESSI_USER_INSTALL` as well as the default one. The Cargo prelude takes the compatibility layer from `EESSI_EPREFIX` too.
1 change: 1 addition & 0 deletions changelog.d/+eessi-extend-empty-prefix.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`scripts/eessi-extend-eb.sh` counts a present `EESSI_*_INSTALL` variable as set when the value is empty, matching EESSI-extend. An empty `EESSI_SITE_INSTALL` or `EESSI_CVMFS_INSTALL` stays in that mode and no longer also creates a user prefix.
1 change: 1 addition & 0 deletions changelog.d/+eessi-extend-rustc.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`scripts/eessi-extend-eb.sh` still reaches EasyBuild when `rustc` is not on `PATH`, and the Cargo prelude takes a mirror's compatibility layer from `EESSI_CVMFS_REPO` when `EESSI_EPREFIX` is unset. CI runs `tests/eessi_extend_eb_script.rs`.
1 change: 1 addition & 0 deletions changelog.d/+towncrier.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
News fragments in `changelog.d/`, assembled into `CHANGELOG.md` by towncrier at release, as in the other stackhands repositories.
Empty file added changelog.d/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion examples/targets/eessi-extend.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ work_root = "/tmp/eb-stack-eessi/work"
tmp_root = "/tmp/eb-stack-eessi/tmp"

[targets.easybuild.environment]
EESSI_VERSION = "2025.06"
EESSI_VERSION = "2026.06"
EESSI_USER_INSTALL = "/tmp/eb-stack-eessi/install"
WORKING_DIR = "/tmp"
EASYBUILD_SOURCEPATH = "/tmp/eb-stack-eessi/sources"
47 changes: 31 additions & 16 deletions scripts/eessi-extend-eb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# EESSI init is not nounset-safe.
set -eo pipefail

ver=${EESSI_VERSION:-2025.06}
init=/cvmfs/software.eessi.io/versions/${ver}/init/lmod/bash
# EESSI_CVMFS_REPO names a mirror or another EESSI repository.
repo=${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}
ver=${EESSI_VERSION:-2026.06}
init=${repo}/versions/${ver}/init/lmod/bash
if [[ ! -e $init ]]; then
echo "eessi-extend-eb: missing ${init}" >&2
exit 2
Expand All @@ -13,18 +15,27 @@ fi
source "$init"

# Exactly one prefix variable; the module reads them at load time.
# EESSI-extend uses os.getenv(name) ~= nil, so a present empty value is
# set. An empty EESSI_SITE_INSTALL is site mode. Counting only non-empty
# values also exported EESSI_USER_INSTALL, and the module refused both.
n=0
[[ -n ${EESSI_USER_INSTALL:-} ]] && n=$((n + 1))
[[ -n ${EESSI_PROJECT_INSTALL:-} ]] && n=$((n + 1))
[[ -n ${EESSI_SITE_INSTALL:-} ]] && n=$((n + 1))
[[ -n ${EESSI_CVMFS_INSTALL:-} ]] && n=$((n + 1))
if [[ $n -eq 0 ]]; then
export EESSI_USER_INSTALL=${EESSI_USER_INSTALL:-$HOME/EESSI}
mkdir -p "$EESSI_USER_INSTALL"
elif [[ $n -gt 1 ]]; then
[[ -v EESSI_USER_INSTALL ]] && n=$((n + 1))
[[ -v EESSI_PROJECT_INSTALL ]] && n=$((n + 1))
[[ -v EESSI_SITE_INSTALL ]] && n=$((n + 1))
[[ -v EESSI_CVMFS_INSTALL ]] && n=$((n + 1))
if [[ $n -gt 1 ]]; then
echo "eessi-extend-eb: set exactly one of EESSI_USER_INSTALL, EESSI_PROJECT_INSTALL, EESSI_SITE_INSTALL, EESSI_CVMFS_INSTALL" >&2
exit 3
fi
# EESSI-extend refuses a user prefix that does not exist. Project and
# site prefixes need their group and modes set by an owner, so they are
# not created here.
if [[ $n -eq 0 ]]; then
export EESSI_USER_INSTALL=$HOME/EESSI
fi
if [[ -n ${EESSI_USER_INSTALL:-} ]]; then
mkdir -p "$EESSI_USER_INSTALL"
fi

export WORKING_DIR=${WORKING_DIR:-/tmp}
# Host Cargo/CMake wrappers are not in the EESSI module graph. Same
Expand All @@ -34,15 +45,19 @@ unset RUSTC_WRAPPER CARGO_BUILD_RUSTC_WRAPPER RUSTC_WORKSPACE_WRAPPER RUSTFLAGS
CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER CMAKE_Fortran_COMPILER_LAUNCHER || true
eval "$(env | awk -F= '/^CARGO_TARGET_[A-Z0-9_]*_(LINKER|RUSTFLAGS)=/{print "unset "$1}')"
export LINKER=${CC:-gcc}
_triple=$(rustc -vV 2>/dev/null | awk '/^host:/{print $2}')
_triple_env=$(printf %s "${_triple:-}" | tr '[:lower:]-' '[:upper:]_')
# rustc is absent for an ordinary EasyBuild run. A failing command
# substitution under pipefail would exit before module load.
_triple=""
if _host=$(rustc -vV 2>/dev/null); then
_triple=$(printf '%s\n' "$_host" | awk '/^host:/{print $2}')
fi
_triple_env=$(printf %s "${_triple}" | tr '[:lower:]-' '[:upper:]_')
if [[ -n ${_triple_env} ]]; then
eval "export CARGO_TARGET_${_triple_env}_LINKER=\${CC:-gcc}"
fi
# foss wrappers can drop the compat-layer ld that collect2 needs.
# foss wrappers can drop the compat-layer ld that collect2 needs. The
# init above sets EESSI_EPREFIX to the compat layer it loaded.
_arch=$(uname -m)
if [[ -n ${EESSI_VERSION:-} ]]; then
export PATH="/cvmfs/software.eessi.io/versions/${EESSI_VERSION}/compat/linux/${_arch}/usr/bin:${PATH}"
fi
export PATH="${EESSI_EPREFIX:-${repo}/versions/${ver}/compat/linux/${_arch}}/usr/bin:${PATH}"
module load EESSI-extend
exec eb "$@"
14 changes: 11 additions & 3 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ pub fn eessi_cargo_host_isolation() -> &'static str {
r#"eval $(env | awk -F= '/^CARGO_TARGET_[A-Z0-9_]*_(LINKER|RUSTFLAGS)=/{print "unset "$1}') && "#,
"export CARGO_HOME=%(builddir)s/.cargohome && ",
"export LINKER=${CC:-gcc} && ",
r#"_triple=$(rustc -vV 2>/dev/null | awk "/^host:/{print \$2}") && "#,
// An ordinary recipe has no rustc. The host triple is best-effort,
// the same way scripts/eessi-extend-eb.sh discovers it, so a missing
// compiler does not drop the compat-layer linker from PATH.
r#"_triple=""; if _host=$(rustc -vV 2>/dev/null); then _triple=$(printf '%s\n' "$_host" | awk '/^host:/{print $2}'); fi && "#,
r#"_triple_env=$(printf %s "$_triple" | tr "[:lower:]-" "[:upper:]_") && "#,
r#"if [ -n "$_triple_env" ]; then eval export CARGO_TARGET_${_triple_env}_LINKER=${CC:-gcc}; fi && "#,
r#"_arch=$(uname -m) && "#,
r#"_ebld=/cvmfs/software.eessi.io/versions/${EESSI_VERSION:-2025.06}/compat/linux/${_arch}/usr/bin && "#,
r#"_ebld=${EESSI_EPREFIX:-${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}/versions/${EESSI_VERSION:-2026.06}/compat/linux/${_arch}}/usr/bin && "#,
r#"export PATH="$_ebld:$PATH" && "#,
r#"export RUSTFLAGS="-C link-arg=-B$_ebld $(printf -- '-L %s ' $(echo ${LIBRARY_PATH:-} | tr ':' ' '))" && "#,
)
Expand Down Expand Up @@ -508,7 +511,12 @@ pyo3 = "0.22"
let prelude = eessi_cargo_host_isolation();
assert!(prelude.contains("unset RUSTC_WRAPPER"));
assert!(prelude.contains("uname -m"));
assert!(prelude.contains("compat/linux/${_arch}/usr/bin"));
assert!(prelude.contains("_ebld=${EESSI_EPREFIX:-${EESSI_CVMFS_REPO:-"));
assert!(prelude.contains("compat/linux/${_arch}}/usr/bin"));
assert!(
prelude.contains("if _host=$(rustc -vV 2>/dev/null); then"),
"a missing rustc must not abort the prelude"
);
assert!(prelude.contains("link-arg=-B"));
assert!(prelude.contains("LINKER=${CC:-gcc}"));
assert!(
Expand Down
173 changes: 173 additions & 0 deletions tests/eessi_extend_eb_script.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
//! scripts/eessi-extend-eb.sh against a fake EESSI repository: an init
//! that defines `module` and sets EESSI_EPREFIX, and an `eb` that prints
//! the environment it was given.

use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};

fn script() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("scripts/eessi-extend-eb.sh")
}

struct Fake {
dir: tempfile::TempDir,
}

impl Fake {
fn new(version: &str, eprefix: Option<&str>) -> Self {
let dir = tempfile::tempdir().expect("tempdir");
let init = dir
.path()
.join(format!("repo/versions/{version}/init/lmod"));
fs::create_dir_all(&init).expect("init dir");
let mut text = String::from("module() { :; }\n");
if let Some(e) = eprefix {
text.push_str(&format!("export EESSI_EPREFIX={e}\n"));
}
fs::write(init.join("bash"), text).expect("init");
let bin = dir.path().join("bin");
fs::create_dir_all(&bin).expect("bin");
let eb = bin.join("eb");
fs::write(&eb, "#!/bin/sh\nenv\n").expect("eb");
fs::set_permissions(&eb, fs::Permissions::from_mode(0o755)).expect("chmod");
fs::create_dir_all(dir.path().join("home")).expect("home");
Self { dir }
}

fn path(&self, rel: &str) -> PathBuf {
self.dir.path().join(rel)
}

fn run(&self, env: &[(&str, &str)]) -> Output {
let mut cmd = Command::new("bash");
cmd.arg(script())
.env_clear()
.env(
"PATH",
format!("{}:/usr/bin:/bin", self.path("bin").display()),
)
.env("HOME", self.path("home"))
.env("EESSI_CVMFS_REPO", self.path("repo"));
for (k, v) in env {
cmd.env(k, v);
}
cmd.output().expect("run script")
}
}

fn var<'a>(out: &'a Output, name: &str) -> Option<&'a str> {
let text = std::str::from_utf8(&out.stdout).expect("utf8");
let prefix = format!("{name}=");
text.lines().find_map(|l| l.strip_prefix(prefix.as_str()))
}

fn ok(out: &Output) {
assert!(
out.status.success(),
"status {:?}\n{}",
out.status,
String::from_utf8_lossy(&out.stderr)
);
}

#[test]
fn without_a_version_it_loads_the_current_eessi() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[]);
ok(&out);
let arch = String::from_utf8(Command::new("uname").arg("-m").output().unwrap().stdout).unwrap();
let compat = fake.path(&format!(
"repo/versions/2026.06/compat/linux/{}/usr/bin",
arch.trim()
));
let path = var(&out, "PATH").expect("PATH");
assert!(
path.starts_with(&format!("{}:", compat.display())),
"{path}"
);
}

#[test]
fn the_compat_layer_comes_from_the_init() {
let fake = Fake::new("2026.06", Some("/opt/eessi-compat"));
let out = fake.run(&[]);
ok(&out);
let path = var(&out, "PATH").expect("PATH");
assert!(path.starts_with("/opt/eessi-compat/usr/bin:"), "{path}");
}

#[test]
fn a_named_user_prefix_is_created() {
let fake = Fake::new("2026.06", None);
let prefix = fake.path("home/eessi-mine");
let out = fake.run(&[("EESSI_USER_INSTALL", prefix.to_str().unwrap())]);
ok(&out);
assert!(Path::new(&prefix).is_dir());
assert_eq!(var(&out, "EESSI_USER_INSTALL"), prefix.to_str());
}

#[test]
fn the_default_user_prefix_is_home_eessi() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[]);
ok(&out);
assert!(fake.path("home/EESSI").is_dir());
}

#[test]
fn a_project_prefix_is_not_created() {
let fake = Fake::new("2026.06", None);
let project = fake.path("project");
let out = fake.run(&[("EESSI_PROJECT_INSTALL", project.to_str().unwrap())]);
ok(&out);
assert!(!project.exists());
assert_eq!(var(&out, "EESSI_USER_INSTALL"), None);
}

#[test]
fn an_empty_site_install_is_not_a_user_prefix() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[("EESSI_SITE_INSTALL", "")]);
ok(&out);
assert!(!fake.path("home/EESSI").exists());
assert_eq!(var(&out, "EESSI_USER_INSTALL"), None);
assert_eq!(var(&out, "EESSI_SITE_INSTALL"), Some(""));
}

#[test]
fn an_empty_cvmfs_install_is_not_a_user_prefix() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[("EESSI_CVMFS_INSTALL", "")]);
ok(&out);
assert!(!fake.path("home/EESSI").exists());
assert_eq!(var(&out, "EESSI_USER_INSTALL"), None);
assert_eq!(var(&out, "EESSI_CVMFS_INSTALL"), Some(""));
}

#[test]
fn an_empty_site_install_with_a_user_prefix_is_refused() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[("EESSI_SITE_INSTALL", ""), ("EESSI_USER_INSTALL", "/x")]);
assert_eq!(out.status.code(), Some(3));
assert!(!fake.path("home/EESSI").exists());
}

#[test]
fn two_prefixes_are_refused() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[
("EESSI_USER_INSTALL", "/x"),
("EESSI_PROJECT_INSTALL", "/y"),
]);
assert_eq!(out.status.code(), Some(3));
}

#[test]
fn a_missing_version_is_reported() {
let fake = Fake::new("2026.06", None);
let out = fake.run(&[("EESSI_VERSION", "2025.06")]);
assert_eq!(out.status.code(), Some(2));
assert!(String::from_utf8_lossy(&out.stderr).contains("versions/2025.06/init"));
}
3 changes: 2 additions & 1 deletion tests/pypi_cran_extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ fn assert_eessi_cargo_isolation(text: &str) {
assert!(
text.contains("unset RUSTC_WRAPPER")
&& text.contains("uname -m")
&& text.contains("compat/linux/${_arch}/usr/bin")
&& text.contains("${EESSI_EPREFIX:-")
&& text.contains("compat/linux/${_arch}}/usr/bin")
&& text.contains("link-arg=-B")
&& text.contains("LINKER=${CC:-gcc}")
&& !text.contains("X86_64"),
Expand Down
Loading
Loading