hercules-ci-effects icon indicating copy to clipboard operation
hercules-ci-effects copied to clipboard

Documentation for 'Hello World' effect

Open srid opened this issue 3 years ago • 6 comments

I'm unable to adapt https://docs.hercules-ci.com/hercules-ci-effects/guide/write-a-custom-effect/ for flake.nix

Could we have docs on adding the simplest effect?

Here's what I tried:

https://github.com/srid/haskell.page/commit/0e08e8f0e9eb84c3c6555991a65315925fbb7f29#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0R13

image

(I assumed that the agent would iterate all top-level attres looking for 'effect' objects)

But, the agent doesn't seem to recognize any effects?

https://hercules-ci.com/github/srid/haskell.page/jobs/8

image

srid avatar Dec 06 '21 00:12 srid

The problem is with the traversal. It follows the rules of nix-build and nix-env -q regarding recurseForDerivations aka recurseIntoAttrs. This will be fixed in the 0.9 release, which can perform a simpler traversal, but until then, you could re-expose the relevant flake attrs with recurseIntoAttrs calls in default.nix.

roberth avatar Dec 06 '21 01:12 roberth

Or you could use https://github.com/hercules-ci/flake-compat-ci, even if it's a stop-gap solution.

roberth avatar Dec 06 '21 01:12 roberth

Or you could use https://github.com/hercules-ci/flake-compat-ci, even if it's a stop-gap solution.

Okay, trying that:

https://github.com/srid/haskell.page/commit/81568655b33c3673c29ac2784a01f4d2de61ae2c

Still the same issue:

https://hercules-ci.com/github/srid/haskell.page/jobs/12

srid avatar Dec 06 '21 01:12 srid

I've updated flake-compat-ci to expose effects. It expects the flake output:

outputs = { self, ..... }: {
  effects.helloWorld = ....;
} // yourExistingOutputsIncludingFlakeCompatCi;

ie not per system. Generally you want to run effects once per real-world object rather than for all each possible system.

roberth avatar Dec 06 '21 01:12 roberth

diff --git a/flake.lock b/flake.lock
index 6eba55d..3f7512d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -40,11 +40,11 @@
     },
     "flake-compat-ci": {
       "locked": {
-        "lastModified": 1629629549,
-        "narHash": "sha256-c6Hipyp52MZ2pTFXEIRdcLK2rtKt9jggCQ7ZOgBS44k=",
+        "lastModified": 1638753619,
+        "narHash": "sha256-uJoNBfbXkn17W5PIrtQDPEk+zfN91oOB9I9XF9pOTmo=",
         "owner": "hercules-ci",
         "repo": "flake-compat-ci",
-        "rev": "ef10daf1cb1823086ed547d39806aaca4c53cc17",
+        "rev": "e950b4e71c711f3311cbf6323394c0aff7b7e4ec",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 0a95f27..0618268 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,9 @@
         # Example: [ "x86_64-darwin" "aarch64-linux" ];
         systems = [ "x86_64-linux" ];
       };
+
+      effects.helloEffect = self.helloEffect.x86_64-linux;
+
     } //
     flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system:
       let

roberth avatar Dec 06 '21 01:12 roberth

I applied this in https://github.com/srid/haskell.page/commit/7a105d260227129f68f87f00051a61b686375b7a

Result: https://hercules-ci.com/github/srid/haskell.page/jobs/15

Effects still not showing up, and there is also:

image

srid avatar Dec 06 '21 02:12 srid