about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorAdam C. Stephens <2071575+adamcstephens@users.noreply.github.com>2024-06-18 20:24:37 -0400
committerGitHub <noreply@github.com>2024-06-18 20:24:37 -0400
commit93a574477a6e709455101d256f97f5c1371433c0 (patch)
treebd76c8c738168761c3870ceca35145adb410dd96 /pkgs
parent20997b56bfb1884fb57a3f44711f54ce3acbb64f (diff)
parent010157293b34dd13a9d82e7515389aef93be29cf (diff)
Merge pull request #320085 from emilylange/forgejo-go-tests
forgejo: actually run go tests
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/fo/forgejo/package.nix40
1 files changed, 39 insertions, 1 deletions
diff --git a/pkgs/by-name/fo/forgejo/package.nix b/pkgs/by-name/fo/forgejo/package.nix
index 94e3dc8781993..d084deca1f444 100644
--- a/pkgs/by-name/fo/forgejo/package.nix
+++ b/pkgs/by-name/fo/forgejo/package.nix
@@ -2,6 +2,7 @@
 , brotli
 , buildGoModule
 , forgejo
+, fetchpatch
 , git
 , gzip
 , lib
@@ -55,11 +56,21 @@ buildGoModule rec {
 
   outputs = [ "out" "data" ];
 
-  nativeBuildInputs = [ makeWrapper ];
+  nativeBuildInputs = [
+    makeWrapper
+    git # checkPhase
+    openssh # checkPhase
+  ];
   buildInputs = lib.optional pamSupport pam;
 
   patches = [
     ./static-root-path.patch
+    # Fix TestAddRecursiveExclude go test.
+    # This will be part of the upcoming v7.0.5 release at which point this needs to be removed again.
+    (fetchpatch {
+      url = "https://codeberg.org/forgejo/forgejo/commit/f01dc4b271f54201e60a7c795d784813eac3f7ce.patch";
+      sha256  = "sha256-1lPLVHBad+Fmk+6EFXKuMnmDUl5BkEYJuMkTPfdrCgU=";
+    })
   ];
 
   postPatch = ''
@@ -80,6 +91,33 @@ buildGoModule rec {
     export ldflags+=" -X main.ForgejoVersion=$(GITEA_VERSION=${version} make show-version-api)"
   '';
 
+  preCheck = ''
+    # $HOME is required for ~/.ssh/authorized_keys and such
+    export HOME="$TMPDIR/home"
+
+    # expose and use the GO_TEST_PACKAGES var from the Makefile
+    # instead of manually copying over the entire list:
+    # https://codeberg.org/forgejo/forgejo/src/tag/v7.0.4/Makefile#L124
+    echo -e 'show-backend-tests:\n\t@echo ''${GO_TEST_PACKAGES}' >> Makefile
+    getGoDirs() {
+      make show-backend-tests
+    }
+  '';
+
+  checkFlags =
+    let
+      skippedTests = [
+        "Test_SSHParsePublicKey/dsa-1024/SSHKeygen" # dsa-1024 is deprecated in openssh and requires opting-in at compile time
+        "Test_calcFingerprint/dsa-1024/SSHKeygen" # dsa-1024 is deprecated in openssh and requires opting-in at compile time
+        "TestPamAuth" # we don't have PAM set up in the build sandbox
+        "TestPassword" # requires network: api.pwnedpasswords.com
+        "TestCaptcha" # requires network: hcaptcha.com
+        "TestDNSUpdate" # requires network: release.forgejo.org
+        "TestMigrateWhiteBlocklist" # requires network: gitlab.com (DNS)
+      ];
+    in
+    [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
+
   postInstall = ''
     mkdir $data
     cp -R ./{templates,options} ${frontend}/public $data