ci: move CI scripting into Nushell scripts with separate dependency steps
Replace the shell wrappers build-and-push-to-cachix, check-conventional-commits and the release-plz apps with Nushell scripts in ci/, and move the git commands out of the workflow YAML, so that every workflow command is a plain nix call. Build the workspace dependencies in their own step, skipped when already in Cachix. Later steps import the exported paths and also run after an earlier failure. A separate step alone holds the Cachix token and uploads on main. Pull requests run the same steps without the upload. Wrap the recording tasks with makeBinaryWrapper instead of shell, and run the CI task tests in a step of their own.
This commit is contained in:
8 files changed
+338
-84
No files matched your search
@@ -60,7 +60,12 @@
|
||||
{ pkgs, builds, ... }:
|
||||
{
|
||||
default = builds.bootvine;
|
||||
inherit (builds) bootvine scripted-demos repo-tasks;
|
||||
inherit (builds)
|
||||
bootvine
|
||||
scripted-demos
|
||||
repo-tasks
|
||||
workspace-dependencies
|
||||
;
|
||||
sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix {
|
||||
inherit (vmTests) sampleUnits;
|
||||
};
|
||||
@@ -86,12 +91,6 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
shellScriptApp = name: description: scriptArgs: {
|
||||
type = "app";
|
||||
meta.description = description;
|
||||
program = lib.getExe (pkgs.writeShellApplication ({ inherit name; } // scriptArgs));
|
||||
};
|
||||
|
||||
sampleMachineApps = lib.mapAttrs' (
|
||||
machineName: machineDescription:
|
||||
lib.nameValuePair "sample-vm-${machineName}" {
|
||||
@@ -101,9 +100,80 @@
|
||||
}
|
||||
) vmTests.machineDescriptions;
|
||||
|
||||
releasePlzOnCodeberg =
|
||||
subcommand: description:
|
||||
shellScriptApp "release-plz-${subcommand}" description {
|
||||
wrappedProgramTool =
|
||||
{
|
||||
toolName,
|
||||
wrappedProgram,
|
||||
addedFlags,
|
||||
runtimeInputs ? [ ],
|
||||
wrapperArguments ? [ ],
|
||||
}:
|
||||
pkgs.runCommand toolName
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
|
||||
meta.mainProgram = toolName;
|
||||
}
|
||||
''
|
||||
makeWrapper ${wrappedProgram} $out/bin/${toolName} \
|
||||
${
|
||||
lib.escapeShellArgs (
|
||||
lib.concatMap (addedFlag: [
|
||||
"--add-flags"
|
||||
addedFlag
|
||||
]) addedFlags
|
||||
)
|
||||
} \
|
||||
${lib.optionalString (runtimeInputs != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeInputs}"} \
|
||||
${lib.escapeShellArgs wrapperArguments}
|
||||
'';
|
||||
|
||||
nuScriptTool =
|
||||
{
|
||||
scriptPath,
|
||||
toolName,
|
||||
runtimeInputs ? [ ],
|
||||
wrapperArguments ? [ ],
|
||||
}:
|
||||
wrappedProgramTool {
|
||||
inherit toolName runtimeInputs wrapperArguments;
|
||||
wrappedProgram = lib.getExe pkgs.nushell;
|
||||
addedFlags = [
|
||||
"${scriptPath}"
|
||||
toolName
|
||||
];
|
||||
};
|
||||
|
||||
describedApp = appDescription: appTool: {
|
||||
type = "app";
|
||||
meta.description = appDescription;
|
||||
program = lib.getExe appTool;
|
||||
};
|
||||
|
||||
nixBuiltPathsTool =
|
||||
toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/nix-built-paths.nu; });
|
||||
|
||||
releaseTaskTool =
|
||||
toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/release-tasks.nu; });
|
||||
|
||||
exportBuiltPathsHook = nixBuiltPathsTool { toolName = "export-built-paths-hook"; };
|
||||
|
||||
exportingBuildTool =
|
||||
toolArguments:
|
||||
nixBuiltPathsTool (
|
||||
toolArguments
|
||||
// {
|
||||
wrapperArguments = [
|
||||
"--set"
|
||||
"EXPORT_HOOK_PROGRAM"
|
||||
(lib.getExe exportBuiltPathsHook)
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
releasePlzTool =
|
||||
toolName:
|
||||
releaseTaskTool {
|
||||
inherit toolName;
|
||||
runtimeInputs = [
|
||||
pkgs.release-plz
|
||||
pkgs.gitMinimal
|
||||
@@ -111,63 +181,96 @@
|
||||
pkgs.stdenv.cc
|
||||
rustToolchain
|
||||
];
|
||||
runtimeEnv.PKG_CONFIG_PATH =
|
||||
lib.makeSearchPathOutput "dev" "lib/pkgconfig"
|
||||
builds.bootvine.buildInputs;
|
||||
text = ''exec release-plz ${subcommand} --forge gitea --git-token "$CODEBERG_TOKEN"'';
|
||||
wrapperArguments = [
|
||||
"--set"
|
||||
"PKG_CONFIG_PATH"
|
||||
(lib.makeSearchPathOutput "dev" "lib/pkgconfig" builds.bootvine.buildInputs)
|
||||
];
|
||||
};
|
||||
|
||||
repoTaskTool =
|
||||
toolArguments:
|
||||
wrappedProgramTool (
|
||||
toolArguments
|
||||
// {
|
||||
wrappedProgram = lib.getExe builds.repo-tasks;
|
||||
}
|
||||
);
|
||||
in
|
||||
sampleMachineApps
|
||||
// {
|
||||
release-plz-release = releasePlzOnCodeberg "release" "Publish unpublished versions to crates.io and tag them with a Codeberg release";
|
||||
release-plz-release-pr = releasePlzOnCodeberg "release-pr" "Open or update the Codeberg pull request that bumps the version and changelog";
|
||||
release-plz-release = describedApp "Publish unpublished versions to crates.io and tag them with a Codeberg release" (
|
||||
releasePlzTool "release-plz-release"
|
||||
);
|
||||
release-plz-release-pr = describedApp "Open or update the Codeberg pull request that bumps the version and changelog" (
|
||||
releasePlzTool "release-plz-release-pr"
|
||||
);
|
||||
|
||||
record-screencasts =
|
||||
shellScriptApp "record-screencasts"
|
||||
describedApp
|
||||
"Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings"
|
||||
{
|
||||
(repoTaskTool {
|
||||
toolName = "record-screencasts";
|
||||
addedFlags = [
|
||||
"record-screencasts"
|
||||
"--vm-check-outputs"
|
||||
"${pkgs.linkFarm "vm-check-outputs" (
|
||||
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
|
||||
)}"
|
||||
];
|
||||
runtimeInputs = [
|
||||
pkgs.vhs
|
||||
pkgs.libwebp
|
||||
builds.scripted-demos
|
||||
builds.repo-tasks
|
||||
];
|
||||
text = "exec xtask record-screencasts --vm-check-outputs ${
|
||||
pkgs.linkFarm "vm-check-outputs" (
|
||||
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
|
||||
)
|
||||
}";
|
||||
};
|
||||
});
|
||||
|
||||
publish-recordings =
|
||||
shellScriptApp "publish-recordings"
|
||||
"Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
{
|
||||
describedApp "Replace the recordings branch on origin with a single commit holding recordings/"
|
||||
(repoTaskTool {
|
||||
toolName = "publish-recordings";
|
||||
addedFlags = [ "publish-recordings" ];
|
||||
runtimeInputs = [
|
||||
pkgs.gitMinimal
|
||||
builds.repo-tasks
|
||||
];
|
||||
text = "exec xtask publish-recordings";
|
||||
};
|
||||
});
|
||||
|
||||
build-and-push-to-cachix =
|
||||
shellScriptApp "build-and-push-to-cachix"
|
||||
"Build flake outputs and push everything built to the wvhulle Cachix cache"
|
||||
{
|
||||
build-unless-cached =
|
||||
describedApp "Build a flake output and export it to the CI workspace unless it is already in Cachix"
|
||||
(exportingBuildTool {
|
||||
toolName = "build-unless-cached";
|
||||
});
|
||||
|
||||
build-and-export-paths =
|
||||
describedApp "Build flake outputs and export newly built paths to the CI workspace"
|
||||
(exportingBuildTool {
|
||||
toolName = "build-and-export-paths";
|
||||
});
|
||||
|
||||
import-exported-paths =
|
||||
describedApp "Import paths exported to the CI workspace by an earlier step"
|
||||
(nixBuiltPathsTool {
|
||||
toolName = "import-exported-paths";
|
||||
});
|
||||
|
||||
upload-exported-paths =
|
||||
describedApp "Push paths exported to the CI workspace to the wvhulle Cachix cache"
|
||||
(nixBuiltPathsTool {
|
||||
toolName = "upload-exported-paths";
|
||||
runtimeInputs = [ pkgs.cachix ];
|
||||
text = ''exec cachix watch-exec wvhulle -- nix build --print-build-logs "$@"'';
|
||||
};
|
||||
});
|
||||
|
||||
check-conventional-commits =
|
||||
shellScriptApp "check-conventional-commits"
|
||||
"Check that the commit messages in a git revision range are conventional commits"
|
||||
{
|
||||
describedApp "Check that the commit messages in a git revision range are conventional commits"
|
||||
(releaseTaskTool {
|
||||
toolName = "check-conventional-commits";
|
||||
runtimeInputs = [
|
||||
pkgs.convco
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
text = ''exec convco check "$@"'';
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -177,6 +280,12 @@
|
||||
inherit (builds) rustfmt-formatting clippy-lints;
|
||||
bootvine-build = builds.bootvine;
|
||||
repo-tasks-build = builds.repo-tasks;
|
||||
ci-task-tests =
|
||||
pkgs.runCommand "bootvine-ci-task-tests" { nativeBuildInputs = [ pkgs.nushell ]; }
|
||||
''
|
||||
nu ${./ci}/test-ci-tasks.nu
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
// lib.mapAttrs' (machineName: check: lib.nameValuePair "vm-${machineName}" check) (
|
||||
vmTests.checksFor pkgs
|
||||
|
||||
Reference in new issue
Block a user