Skip to content

Commit

Permalink
Re-write GitHub action to improve reliability
Browse files Browse the repository at this point in the history
Re-write the GitHub action to work more like Hydra

* Packages are evaluated and then built in topological order
* Each build failure is added as a separate cache entry. Makes it work
  even if the action times out, and makes it easier to retry individual
  packages.
* Dependency failures are reported accurately
  • Loading branch information
lopsided98 committed Nov 21, 2024
1 parent 89a4655 commit a94ed52
Show file tree
Hide file tree
Showing 11 changed files with 68,382 additions and 22,199 deletions.
3 changes: 3 additions & 0 deletions .github/actions/nix-ros-build-action/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*

# Output directory
build/
12 changes: 6 additions & 6 deletions .github/actions/nix-ros-build-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ inputs:
description: Root attribute to begin evaluation
required: true
default: rosPackages
nixpkgs:
description: URL used to download nixpkgs
required: true
default: https://github.com/lopsided98/nixpkgs/archive/nix-ros.tar.gz
system:
description: Host system name (e.g. x86_64-linux). If different from the runner architecture, binfmt/qemu must be configured.
required: false
parallelism:
eval-jobs:
description: Number of evaluations to run in parallel
required: true
default: "4"
build-jobs:
description: Number of builds to run in parallel
required: true
default: "20"
default: "2"
cachix-cache:
description: Name of the Cachix cache to use
required: true
Expand Down
89,182 changes: 67,220 additions & 21,962 deletions .github/actions/nix-ros-build-action/dist/index.js

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions .github/actions/nix-ros-build-action/eval.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
{ lib, pkgs }: let
validDrv = (n: v: (builtins.tryEval v).success);
listDrvs = prefix:
in lib.attrNames (lib.filterAttrs validDrv pkgs)
# Evaluate `release.nix' like Hydra would. Too bad nix-instantiate can't to do this.
{ lib ? pkgs.lib, pkgs }:

let
trace = if builtins.getEnv "VERBOSE" == "1" then builtins.trace else (x: y: y);

# Add the ‘recurseForDerivations’ attribute to ensure that
# nix-instantiate recurses into nested attribute sets.
recurse = path: attrs:
if (builtins.tryEval attrs).success then
if lib.isDerivation attrs
then
if (builtins.tryEval attrs.drvPath).success
then { inherit (attrs) name drvPath; }
else { failed = true; }
else if lib.isAttrs attrs && (attrs.recurseForDerivations or false) then
{ recurseForDerivations = true; } //
lib.mapAttrs (n: v: let path' = path ++ [n]; in trace path' (recurse path' v)) attrs
else { }
else { };

in recurse [] pkgs
Loading

0 comments on commit a94ed52

Please sign in to comment.