From 1c846765273018ff9b97edbfcaf9e5884fd9e140 Mon Sep 17 00:00:00 2001 From: ajs124 Date: Mon, 10 May 2021 14:32:24 +0200 Subject: [PATCH 1/5] Fit more content on screen --- src/root/static/css/hydra.css | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/root/static/css/hydra.css b/src/root/static/css/hydra.css index 475d61c2..53304b19 100644 --- a/src/root/static/css/hydra.css +++ b/src/root/static/css/hydra.css @@ -1,5 +1,5 @@ div.skip-topbar { - padding-top: 40px; + padding-top: 20px; margin-bottom: 1.5em; } @@ -146,6 +146,26 @@ td.step-status span.warn { padding-top: 1.5rem; } +.container { + max-width: 80%; +} + +.tab-content { + margin-right: 0 !important; +} + +body { + line-height: 1; +} + +.navbar-nav { + line-height: 1.5; +} + +.dropdown-item { + line-height: 1.5; +} + @media (prefers-color-scheme: dark) { /* Prevent some flickering */ html { From 9656f16509665a2d49ff7de2905d7115b5fe4440 Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Fri, 22 Jul 2022 10:35:38 -0400 Subject: [PATCH 2/5] Update hydra-module.nix to use newer nixos options nix.trustedUsers is deprecated as of 22.05, and since the nix.extraOptions config is just doing something similar, I moved that to the new nix.settings as well --- hydra-module.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hydra-module.nix b/hydra-module.nix index 0df5e690..1f46a3ca 100644 --- a/hydra-module.nix +++ b/hydra-module.nix @@ -228,8 +228,12 @@ in useDefaultShell = true; }; - nix.trustedUsers = [ "hydra-queue-runner" ]; - + nix.settings = { + trusted-users = [ "hydra-queue-runner" ]; + gc-keep-outputs = true; + gc-keep-derivations = true; + }; + services.hydra-dev.extraConfig = '' using_frontend_proxy = 1 @@ -256,11 +260,6 @@ in environment.variables = hydraEnv; - nix.extraOptions = '' - gc-keep-outputs = true - gc-keep-derivations = true - ''; - systemd.services.hydra-init = { wantedBy = [ "multi-user.target" ]; requires = optional haveLocalDB "postgresql.service"; From a58e2f1a642233672f9941a77c0f4bd5c3597878 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Thu, 4 Aug 2022 21:18:55 +0200 Subject: [PATCH 3/5] Use libmagic for better output MIME detection --- flake.nix | 1 + src/lib/Hydra/Controller/Build.pm | 39 ++++++------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/flake.nix b/flake.nix index 2e891364..93186ee0 100644 --- a/flake.nix +++ b/flake.nix @@ -503,6 +503,7 @@ DigestSHA1 EmailMIME EmailSender + FileLibMagic FileSlurper FileWhich final.nix.perl-bindings diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index c7811c62..18a0eba3 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -7,15 +7,16 @@ use base 'Hydra::Base::Controller::NixChannel'; use Hydra::Helper::Nix; use Hydra::Helper::CatalystUtils; use File::Basename; +use File::LibMagic; use File::stat; use Data::Dump qw(dump); use Nix::Store; use Nix::Config; use List::SomeUtils qw(all); use Encode; -use MIME::Types; use JSON::PP; +use feature 'state'; sub buildChain :Chained('/') :PathPart('build') :CaptureArgs(1) { my ($self, $c, $id) = @_; @@ -236,14 +237,10 @@ sub serveFile { $c->stash->{'plain'} = { data => grab(cmd => ["nix", "--experimental-features", "nix-command", "store", "cat", "--store", getStoreUri(), "$path"]) }; - # Detect MIME type. Borrowed from Catalyst::Plugin::Static::Simple. - my $type = "text/plain"; - if ($path =~ /.*\.(\S{1,})$/xms) { - my $ext = $1; - my $mimeTypes = MIME::Types->new(only_complete => 1); - my $t = $mimeTypes->mimeTypeOf($ext); - $type = ref $t ? $t->type : $t if $t; - } + # Detect MIME type. + state $magic = File::LibMagic->new(follow_symlinks => 1); + my $info = $magic->info_from_filename($path); + my $type = $info->{mime_with_encoding}; $c->response->content_type($type); $c->forward('Hydra::View::Plain'); } @@ -288,29 +285,7 @@ sub download : Chained('buildChain') PathPart { my $path = $product->path; $path .= "/" . join("/", @path) if scalar @path > 0; - if (isLocalStore) { - - notFound($c, "File '" . $product->path . "' does not exist.") unless -e $product->path; - - # Make sure the file is in the Nix store. - $path = checkPath($self, $c, $path); - - # If this is a directory but no "/" is attached, then redirect. - if (-d $path && substr($c->request->uri, -1) ne "/") { - return $c->res->redirect($c->request->uri . "/"); - } - - $path = "$path/index.html" if -d $path && -e "$path/index.html"; - - notFound($c, "File '$path' does not exist.") if !-e $path; - - notFound($c, "Path '$path' is a directory.") if -d $path; - - $c->serve_static_file($path); - - } else { - serveFile($c, $path); - } + serveFile($c, $path); $c->response->headers->last_modified($c->stash->{build}->stoptime); } From f6d45b0f0cdedf940df67a935f4eb337b43300e7 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Mon, 8 Aug 2022 13:35:56 +0200 Subject: [PATCH 4/5] doc/configuration: fix ldap role mapping example To group is called `cancel-build`, not `cancel-builds` (note the trailing `s`). --- doc/manual/src/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/src/configuration.md b/doc/manual/src/configuration.md index 2700625d..ab68df43 100644 --- a/doc/manual/src/configuration.md +++ b/doc/manual/src/configuration.md @@ -185,7 +185,7 @@ Example configuration: hydra_admin = admin # Allow all users in the dev group to restart jobs and cancel builds dev = restart-jobs - dev = cancel-builds + dev = cancel-build ``` From 371402c3c1d76a7d4e2e1691fda3d90397c8929f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Wed, 17 Aug 2022 11:41:37 +0200 Subject: [PATCH 5/5] Drop the HipChat plugin https://en.wikipedia.org/wiki/HipChat says: > Following this, HipChat and Stride customers were migrated to the > Slack group collaboration platform in a transition that was completed by > February 2019. --- doc/manual/src/plugins/README.md | 11 --- src/lib/Hydra/Plugin/HipChatNotification.pm | 89 --------------------- 2 files changed, 100 deletions(-) delete mode 100644 src/lib/Hydra/Plugin/HipChatNotification.pm diff --git a/doc/manual/src/plugins/README.md b/doc/manual/src/plugins/README.md index 26ee2649..6e46224f 100644 --- a/doc/manual/src/plugins/README.md +++ b/doc/manual/src/plugins/README.md @@ -172,17 +172,6 @@ Sets Gitlab CI status. - `gitlab_authorization.` -## HipChat notification - -Sends hipchat chat notifications when a build finish. - -### Configuration options - -- `hipchat.[].jobs` -- `hipchat.[].builds` -- `hipchat.[].token` -- `hipchat.[].notify` - ## InfluxDB notification Writes InfluxDB events when a builds finished. diff --git a/src/lib/Hydra/Plugin/HipChatNotification.pm b/src/lib/Hydra/Plugin/HipChatNotification.pm deleted file mode 100644 index 61cea57a..00000000 --- a/src/lib/Hydra/Plugin/HipChatNotification.pm +++ /dev/null @@ -1,89 +0,0 @@ -package Hydra::Plugin::HipChatNotification; - -use strict; -use warnings; -use parent 'Hydra::Plugin'; -use LWP::UserAgent; -use Hydra::Helper::CatalystUtils; - -sub isEnabled { - my ($self) = @_; - return defined $self->{config}->{hipchat}; -} - -sub buildFinished { - my ($self, $topbuild, $dependents) = @_; - - my $cfg = $self->{config}->{hipchat}; - my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : (); - - my $baseurl = $self->{config}->{'base_uri'} || "http://localhost:3000"; - - # Figure out to which rooms to send notification. For each email - # room, we send one aggregate message. - my %rooms; - foreach my $build ($topbuild, @{$dependents}) { - my $prevBuild = getPreviousBuild($build); - my $jobName = showJobName $build; - - foreach my $room (@config) { - my $force = $room->{force}; - next unless $jobName =~ /^$room->{jobs}$/; - - # If build is cancelled or aborted, do not send email. - next if ! $force && ($build->buildstatus == 4 || $build->buildstatus == 3); - - # If there is a previous (that is not cancelled or aborted) build - # with same buildstatus, do not send email. - next if ! $force && defined $prevBuild && ($build->buildstatus == $prevBuild->buildstatus); - - $rooms{$room->{room}} //= { room => $room, builds => [] }; - push @{$rooms{$room->{room}}->{builds}}, $build; - } - } - - return if scalar keys %rooms == 0; - - my ($authors, $nrCommits) = getResponsibleAuthors($topbuild, $self->{plugins}); - - # Send a message to each room. - foreach my $roomId (keys %rooms) { - my $room = $rooms{$roomId}; - my @deps = grep { $_->id != $topbuild->id } @{$room->{builds}}; - - my $img = - $topbuild->buildstatus == 0 ? "$baseurl/static/images/checkmark_16.png" : - $topbuild->buildstatus == 2 ? "$baseurl/static/images/dependency_16.png" : - $topbuild->buildstatus == 4 ? "$baseurl/static/images/cancelled_16.png" : - "$baseurl/static/images/error_16.png"; - - my $msg = ""; - $msg .= " "; - $msg .= "Job jobset->get_column('name')}/${\$topbuild->get_column('job')}'>${\showJobName($topbuild)}"; - $msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0; - $msg .= ": " . showStatus($topbuild) . ""; - - if (scalar keys %{$authors} > 0) { - # FIXME: HTML escaping - my @x = map { "$_" } (sort keys %{$authors}); - $msg .= ", likely due to "; - $msg .= "$nrCommits commits by " if $nrCommits > 1; - $msg .= join(" or ", scalar @x > 1 ? join(", ", @x[0..scalar @x - 2]) : (), $x[-1]); - } - - print STDERR "sending hipchat notification to room $roomId: $msg\n"; - - my $ua = LWP::UserAgent->new(); - my $resp = $ua->post('https://api.hipchat.com/v1/rooms/message?format=json&auth_token=' . $room->{room}->{token}, { - room_id => $roomId, - from => 'Hydra', - message => $msg, - message_format => 'html', - notify => $room->{room}->{notify} || 0, - color => $topbuild->buildstatus == 0 ? 'green' : 'red' }); - - print STDERR $resp->status_line, ": ", $resp->decoded_content,"\n" if !$resp->is_success; - } -} - -1;