From 11a986ae11d25614819adbf9aa64c6b7839efbbf Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrai Date: Tue, 4 Sep 2018 11:11:40 +0300 Subject: [PATCH] Fix #32: include the git revision in the Hydra build (#33) --- README.md | 11 +++++++++-- docs/README.md.dhall | 11 +++++++++-- release.nix | 10 ++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index df3052f0..b059648c 100644 --- a/README.md +++ b/README.md @@ -274,8 +274,15 @@ metadata: ### Tests All tests are defined in `release.nix`. We run these tests in CI in a [Hydra -project][hydra-project]. You can run the tests locally with `nix build --no-link -release.nix`. +project][hydra-project]. + +You can run the tests locally with the following somewhat magic command: +```bash +nix-build --no-link -E 'with import {}; callPackage ./release.nix { src.rev = ""; }' +``` + +It is so because `release.nix` expects Hydra to provide the git revision in `src.rev`, +but locally we don't have/want that, so we just call the function with an empty string. ### Changing the README diff --git a/docs/README.md.dhall b/docs/README.md.dhall index fa1fa1c7..fece2c7e 100644 --- a/docs/README.md.dhall +++ b/docs/README.md.dhall @@ -90,8 +90,15 @@ ${../examples/out/ingress.yaml as Text} ### Tests All tests are defined in `release.nix`. We run these tests in CI in a [Hydra -project][hydra-project]. You can run the tests locally with `nix build --no-link -release.nix`. +project][hydra-project]. + +You can run the tests locally with the following somewhat magic command: +```bash +nix-build --no-link -E 'with import {}; callPackage ./release.nix { src.rev = ""; }' +``` + +It is so because `release.nix` expects Hydra to provide the git revision in `src.rev`, +but locally we don't have/want that, so we just call the function with an empty string. ### Changing the README diff --git a/release.nix b/release.nix index c34c9fe2..9b9308f1 100644 --- a/release.nix +++ b/release.nix @@ -1,3 +1,4 @@ +{ src, ... }: let pkgs = import ./nixpkgs.nix; @@ -43,6 +44,14 @@ let LC_ALL=en_US.UTF-8 ./scripts/build-examples.py $out ''; + # Derivation that trivially depends on the input source code revision. + # As this is included in the "dhall-lang" aggregate, it forces every + # commit to have a corresponding GitHub status check, even if the + # commit doesn't make any changes (which can happen when merging + # master in). + rev = pkgs.runCommand "rev" {} ''echo "${src.rev}" > $out''; + + in { dhall-kubernetes = pkgs.releaseTools.aggregate { name = "dhall-kubernetes"; @@ -50,6 +59,7 @@ in { generatedFilesCompile validateExamples buildReadme + rev ]; }; }