Skip to content

Commit

Permalink
Add a jobset for doing SDK releases (#164)
Browse files Browse the repository at this point in the history
ci/release.nix is called by the sdk-release jobset on hydra. It calls
release-jobset.nix which returns the dfx-release and
install-sh-release derivations but only when the git revision has been
tagged with a release tag (v0.1.2). In that case the version in those
derivations is set to the version in the tag ensuring that they get
rebuild.
  • Loading branch information
basvandijk authored and mergify[bot] committed Nov 12, 2019
1 parent da99215 commit 8ad3376
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
5 changes: 5 additions & 0 deletions ci/release.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
, scrubJobs ? true
, src ? null
}:
(import ../nix {}).ci ../release-jobset.nix { inherit supportedSystems scrubJobs src; }
1 change: 1 addition & 0 deletions jobset.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, crossSystem ? null
, config ? {}
, overlays ? []
, src ? null
}: {
inherit (import ./nix { inherit system crossSystem config overlays; }) dfinity-sdk;
}
5 changes: 3 additions & 2 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, crossSystem ? null
, config ? {}
, overlays ? []
, releaseVersion ? "latest"
}:
let
# The `common` repo provides code (mostly Nix) that is used in the
Expand All @@ -20,9 +21,9 @@ let
else builtins.fetchGit {
name = "common-sources";
url = "ssh://[email protected]/dfinity-lab/common";
rev = "d5af3fda55af07de25f06fc46a2bf5f83424f02b";
rev = "bbf39c31e08b4ab7db82f799a3e3c693a0fdced6";
};
in import commonSrc {
inherit system crossSystem config;
overlays = import ./overlays ++ overlays;
overlays = import ./overlays ++ [ (_self: _super: { inherit releaseVersion; }) ] ++ overlays;
}
8 changes: 2 additions & 6 deletions nix/overlays/dfinity-sdk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@ in {
public-folder = super.callPackage ../public.nix {};
};

dfx-release = mkRelease "dfx"
# This is not the tagged version, but something afterwards
"latest" # once INF-495 is in, we will use: packages.rust-workspace.version
packages.rust-workspace-standalone
"dfx";
dfx-release = mkRelease "dfx" self.releaseVersion packages.rust-workspace-standalone "dfx";

# The following prepares a manifest for copying install.sh
# The release part also checks if the install.sh script is well formatted and has no shellcheck issues.
# We ignore 'local' warning by shellcheck, because any existing sh implementation supports it.
# TODO: streamline mkRelease and this
install-sh-release =
let
version = "latest";
version = self.releaseVersion;
shfmtOpts = "-p -i 4 -ci -bn -s";
shellcheckOpts = "-s sh -S warning";
# We want to include the last revision of the install script into
Expand Down
41 changes: 41 additions & 0 deletions release-jobset.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}
, overlays ? []

# Hydra will pass an argument to this jobset expression for every
# input of the jobset. In our case we only have a single `src` input
# representing the git checkout of the SDK repo:
#
# https://hydra.dfinity.systems/jobset/dfinity-ci-build/sdk#tabs-configuration
#
# This `src` argument contains information about the input for example:
#
# { outPath = builtins.storePath /nix/store/ma2dfyfyxdi6idbza6dyp34zhxh12nmm-source;
# inputType = "git";
# uri = "[email protected]:dfinity-lab/sdk.git";
# rev = "8882d8c97decbb3c33923ca9e8ab785621a61207";
# revCount = 2514;
# gitTag = "8882d8c9"; # This defaults to the rev when there's no git tag.
# shortRev = "8882d8c9";
# }
#
# See: https://github.com/NixOS/hydra/blob/037f6488f633dbf15ca2d93a0c117f6738c707fe/src/lib/Hydra/Plugin/GitInput.pm#L241:L248
#
# We're primarily interested in the `src.gitTag` since that should trigger a release.
, src ? null
}:
let
# doRelease is true when the git tag is of the right release format like `0.1.2`.
doRelease = src != null && versionMatches != null;

# versionMatch is `null` if `src.gitTag` is not of the right format like "1.23.456"
# and it's a list of matches like [ "1.23.456" ] when it is.
versionMatches = builtins.match "([0-9]+\.[0-9]+\.[0-9]+)" src.gitTag;
releaseVersion = if versionMatches == null then "latest" else builtins.head versionMatches;

pkgs = import ./nix { inherit system config overlays releaseVersion; };

in pkgs.lib.optionalAttrs doRelease {
inherit (pkgs.dfinity-sdk) dfx-release install-sh-release;
}

0 comments on commit 8ad3376

Please sign in to comment.