From 241985fb2d1b8338396067063b4902ae996b3141 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 19 Aug 2021 16:13:45 -0400 Subject: [PATCH] Start checking PRs with perlcritic --- .perlcriticrc | 4 ++++ README.md | 24 ++++++++++++++++++++---- t/Makefile.am | 1 + t/perlcritic.pl | 13 +++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 .perlcriticrc create mode 100755 t/perlcritic.pl diff --git a/.perlcriticrc b/.perlcriticrc new file mode 100644 index 00000000..ddddcada --- /dev/null +++ b/.perlcriticrc @@ -0,0 +1,4 @@ +theme = community + +# 5 is the least complainy, 1 is the most complainy +severity = 5 diff --git a/README.md b/README.md index 8156f22f..e1c2725c 100644 --- a/README.md +++ b/README.md @@ -106,17 +106,33 @@ conflicts with services that might be running on your host, hydra and postgress Note that this is only ever meant as an ad-hoc way of executing Hydra during development. Please make use of the NixOS module for actually running Hydra in production. -### Running Tests +### Checking your patches -After making your changes, verify the test suite still passes. After following the steps in [Development Environment](#development-environment), run: +After making your changes, verify the test suite passes and perlcritic is still happy. + +Start by following the steps in [Development Environment](#development-environment). + +Then, you can run the tests and the perlcritic linter together with: + +```console +$ nix-shell +$ make check +``` + +You can run a single test with: ``` $ nix-shell -$ make check -$ # Or, to run a single test, use: $ yath test ./t/foo/bar.t ``` +And you can run just perlcritic with: + +``` +$ nix-shell +$ make perlcritic +``` + ### JSON API You can also interface with Hydra through a JSON API. The API is defined in [hydra-api.yaml](./hydra-api.yaml) and you can test and explore via the [swagger editor](https://editor.swagger.io/?url=https://raw.githubusercontent.com/NixOS/hydra/master/hydra-api.yaml) diff --git a/t/Makefile.am b/t/Makefile.am index b8448fe8..9c14c1e3 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -23,6 +23,7 @@ EXTRA_DIST = \ $(TESTS) TESTS = \ + perlcritic.pl \ test.pl check_SCRIPTS = repos diff --git a/t/perlcritic.pl b/t/perlcritic.pl new file mode 100755 index 00000000..2477fe21 --- /dev/null +++ b/t/perlcritic.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Cwd 'abs_path'; +use File::Basename; + +my $dirname = abs_path(dirname(__FILE__) . "/.."); + +print STDERR "Executing perlcritic against $dirname\n"; +chdir($dirname) or die "Failed to enter $dirname\n"; + +exec("perlcritic", ".") or die "Failed to execute perlcritic.";