Compare commits

...

3 commits

Author SHA1 Message Date
524bdf9cdc
chore: bump version 2025-11-13 21:44:28 +01:00
f5181b7b61
fix(sandbox_helper): fix comparisons, rename TMPDIR variable, add help
1. fixes comparisons with true for flag variables
2. renames TMPDIR to NGCI_TMPDIR so it doesn't interfere with the
   standardized TMPDIR var (and at some point accidentally deleting /tmp)
3. add small help message when invalid arg/param is passed
4. run `git add .` on copied git repo in /tmp so staged files stay
   staged there aswell
2025-11-13 21:40:24 +01:00
afe1e02310
fix(job): use unmodified job for mkJobRun
otherwise it tries to run "setup_nix_ci" etc. when running locally,
which doesn't make sense here
2025-11-13 21:39:38 +01:00
3 changed files with 15 additions and 13 deletions

View file

@ -1 +1 @@
3.0.0 3.0.1

View file

@ -637,12 +637,12 @@ in rec {
// gitlabOptions; // gitlabOptions;
config = let config = let
attrsToKeep = builtins.attrNames gitlabOptions; attrsToKeep = builtins.attrNames gitlabOptions;
job = filterUnset (filterAttrs (n: _v: builtins.elem n attrsToKeep) config);
in { in {
finalConfig = cilib.mkJobPatched { finalConfig = cilib.mkJobPatched {
key = name; key = name;
job = filterUnset (filterAttrs (n: _v: builtins.elem n attrsToKeep) config);
nixConfig = config.nix; nixConfig = config.nix;
inherit pipelineName; inherit job pipelineName;
}; };
depsDrv = cilib.mkJobDeps { depsDrv = cilib.mkJobDeps {
key = name; key = name;
@ -651,8 +651,8 @@ in rec {
}; };
runnerDrv = cilib.mkJobRun { runnerDrv = cilib.mkJobRun {
key = name; key = name;
job = config.finalConfig;
jobDeps = config.depsDrv; jobDeps = config.depsDrv;
inherit job;
}; };
packages = { packages = {
"gitlab-ci:pipeline:${pipelineName}:job-deps:${name}" = config.depsDrv; "gitlab-ci:pipeline:${pipelineName}:job-deps:${name}" = config.depsDrv;

View file

@ -28,18 +28,19 @@ while [[ $# -gt 0 ]]; do
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2
echo "use --include-dirty, --no-sandbox, --keep-tmp and --keep-env <ENV>" >&2
exit 1 exit 1
;; ;;
esac esac
done done
if [ "$NO_SANDBOX" = false ]; then if [ $NO_SANDBOX = false ]; then
echo "Running with simple sandboxing" echo "Running with simple sandboxing"
TMPDIR=$(mktemp -dt "nix-gitlab-ci.XXX") NGCI_TMPDIR=$(mktemp -dt "nix-gitlab-ci.XXX")
if [ "$KEEP_TMP" = false ]; then if [ $KEEP_TMP = false ]; then
trap "rm -rf '$TMPDIR'" EXIT trap "rm -rf '$NGCI_TMPDIR'" EXIT
else else
echo "Temp dir will be preserved at: $TMPDIR" echo "Temp dir will be preserved at: $NGCI_TMPDIR"
fi fi
# check if dirty # check if dirty
@ -50,14 +51,15 @@ if [ "$NO_SANDBOX" = false ]; then
git diff --staged > "$DIRTY_PATCH" git diff --staged > "$DIRTY_PATCH"
trap "rm -f '$DIRTY_PATCH'" EXIT trap "rm -f '$DIRTY_PATCH'" EXIT
fi fi
git clone . $TMPDIR git clone . $NGCI_TMPDIR
pushd $TMPDIR >/dev/null pushd $NGCI_TMPDIR >/dev/null
if [[ ! -z "$DIRTY_PATCH" && "$INCLUDE_DIRTY" = true ]]; then if [[ ! -z "$DIRTY_PATCH" && $INCLUDE_DIRTY = true ]]; then
echo "Copying dirty changes..." echo "Copying dirty changes..."
git apply "$DIRTY_PATCH" 2>/dev/null || echo "Failed to copy dirty changes" git apply "$DIRTY_PATCH" 2>/dev/null || echo "Failed to copy dirty changes"
git add . # required so the files are staged again
fi fi
echo "Running job in $TMPDIR" echo "Running job in $NGCI_TMPDIR"
env -i $( env -i $(
if [[ -n "$KEEP_ENV" ]]; then if [[ -n "$KEEP_ENV" ]]; then
IFS=',' read -ra VARS <<< "$KEEP_ENV" IFS=',' read -ra VARS <<< "$KEEP_ENV"