Skip to content

Commit

Permalink
Merge pull request #74 from Mic92/joerg-ci
Browse files Browse the repository at this point in the history
Add junit result and json output
  • Loading branch information
Mic92 authored Oct 7, 2024
2 parents 2ba025e + 9f45b87 commit 1775c73
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 198 deletions.
74 changes: 63 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,90 @@ set. These environment variables are currently not propagated to ssh when using
the `--remote` flag, instead the user is expected that cachix credentials are
configured on the remote machine.

## Machine-readable builds results

nix-fast-build supports both its own json format and junit:

Example for json output:

```console
nix-fast-build --result-file result.json
cat ./result.json
{
"results": [
{
"attr": "riscv64-linux.package-default",
"duration": 0.0,
"error": null,
"success": true,
"type": "EVAL"
},
# ...
```

Example for junit result output:

```console
nix-fast-build --result-format junit --result-file result.xml
```

```console
nix-shell -p python3Packages.junit2html --run 'junit2html result.xml result.html'
```

## Reference

```console
usage: nix-fast-build [-h] [-f FLAKE] [-j MAX_JOBS] [--option name value] [--remote-ssh-option name value] [--no-nom]
[--systems SYSTEMS] [--retries RETRIES] [--no-link] [--out-link OUT_LINK] [--remote REMOTE]
[--always-upload-source] [--no-download] [--skip-cached] [--copy-to COPY_TO] [--debug]
[--eval-max-memory-size EVAL_MAX_MEMORY_SIZE] [--eval-workers EVAL_WORKERS]
usage: nix-fast-build [-h] [-f FLAKE] [-j MAX_JOBS] [--option name value]
[--remote-ssh-option name value]
[--cachix-cache CACHIX_CACHE] [--no-nom]
[--systems SYSTEMS] [--retries RETRIES] [--no-link]
[--out-link OUT_LINK] [--remote REMOTE]
[--always-upload-source] [--no-download] [--skip-cached]
[--copy-to COPY_TO] [--debug]
[--eval-max-memory-size EVAL_MAX_MEMORY_SIZE]
[--eval-workers EVAL_WORKERS]
[--result-file RESULT_FILE]
[--result-format {json,junit}]

options:
-h, --help show this help message and exit
-f FLAKE, --flake FLAKE
Flake url to evaluate/build (default: .#checks
-j MAX_JOBS, --max-jobs MAX_JOBS
Maximum number of build jobs to run in parallel (0 for unlimited)
Maximum number of build jobs to run in parallel (0 for
unlimited)
--option name value Nix option to set
--remote-ssh-option name value
ssh option when accessing remote
--no-nom Don't use nix-output-monitor to print build output (default: false)
--systems SYSTEMS Space-separated list of systems to build for (default: current system)
--cachix-cache CACHIX_CACHE
Cachix cache to upload to
--no-nom Don't use nix-output-monitor to print build output
(default: false)
--systems SYSTEMS Space-separated list of systems to build for (default:
current system)
--retries RETRIES Number of times to retry failed builds
--no-link Do not create an out-link for builds (default: false)
--out-link OUT_LINK Name of the out-link for builds (default: result)
--remote REMOTE Remote machine to build on
--always-upload-source
Always upload sources to remote machine. This is needed if the remote machine cannot access all sources
Always upload sources to remote machine. This is
needed if the remote machine cannot access all sources
(default: false)
--no-download Do not download build results from remote machine
--skip-cached Skip builds that are already present in the binary cache (default: false)
--copy-to COPY_TO Copy build results to the given path (passed to nix copy, i.e. file:///tmp/cache?compression=none)
--skip-cached Skip builds that are already present in the binary
cache (default: false)
--copy-to COPY_TO Copy build results to the given path (passed to nix
copy, i.e. file:///tmp/cache?compression=none)
--debug debug logging output
--eval-max-memory-size EVAL_MAX_MEMORY_SIZE
Maximum memory size for nix-eval-jobs (in MiB) per worker. After the limit is reached, the worker is restarted.
Maximum memory size for nix-eval-jobs (in MiB) per
worker. After the limit is reached, the worker is
restarted.
--eval-workers EVAL_WORKERS
Number of evaluation threads spawned
--result-file RESULT_FILE
File to write build results to
--result-format {json,junit}
Format of the build result file
```
15 changes: 13 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{ python311, makeWrapper, nix-eval-jobs, nix-output-monitor, lib, bashInteractive }:
{
python311,
makeWrapper,
nix-eval-jobs,
nix-output-monitor,
lib,
bashInteractive,
}:
let
path = lib.makeBinPath [ nix-eval-jobs nix-eval-jobs.nix nix-output-monitor ];
path = lib.makeBinPath [
nix-eval-jobs
nix-eval-jobs.nix
nix-output-monitor
];
in
python311.pkgs.buildPythonApplication {
pname = "nix-fast-build";
Expand Down
34 changes: 12 additions & 22 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 28 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";

treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }:
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ lib, ... }:
let
officialPlatforms = [
"aarch64-linux"
Expand All @@ -23,28 +26,28 @@
{
imports = [ ./treefmt.nix ];
systems = officialPlatforms ++ [ "riscv64-linux" ];
perSystem = { pkgs, self', ... }: {
packages.nix-fast-build = pkgs.callPackage ./default.nix {
# we don't want to compile ghc otherwise
nix-output-monitor =
if lib.elem pkgs.hostPlatform.system officialPlatforms then
pkgs.nix-output-monitor
else
null;
};
legacyPackages = {
hello-broken = pkgs.hello.overrideAttrs (_old: {
meta.broken = true;
});
};
packages.default = self'.packages.nix-fast-build;
perSystem =
{ pkgs, self', ... }:
{
packages.nix-fast-build = pkgs.callPackage ./default.nix {
# we don't want to compile ghc otherwise
nix-output-monitor =
if lib.elem pkgs.hostPlatform.system officialPlatforms then pkgs.nix-output-monitor else null;
};
legacyPackages = {
hello-broken = pkgs.hello.overrideAttrs (_old: {
meta.broken = true;
});
};
packages.default = self'.packages.nix-fast-build;

checks =
let
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
packages // devShells;
};
});
checks =
let
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
packages // devShells;
};
}
);
}
Loading

0 comments on commit 1775c73

Please sign in to comment.