Merge pull request #300981 from emilylange/forgejo-ldflags

forgejo: add missing internal version ldflags, nixosTests.forgejo: test /api/forgejo/v1/version

Emily 053ab7f5 436699df

Changed files
+27 -1
nixos
tests
pkgs
applications
version-management
forgejo
+6
nixos/tests/forgejo.nix
···
assert "BEGIN PGP PUBLIC KEY BLOCK" in server.succeed("curl http://localhost:3000/api/v1/signing-key.gpg")
+
api_version = json.loads(server.succeed("curl http://localhost:3000/api/forgejo/v1/version")).get("version")
+
assert "development" != api_version and "-gitea-" in api_version, (
+
"/api/forgejo/v1/version should not return 'development' "
+
+ f"but should contain a gitea compatibility version string. Got '{api_version}' instead."
+
)
+
server.succeed(
"curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. "
+ "Please contact your site administrator.'"
+21 -1
pkgs/applications/version-management/forgejo/default.nix
···
owner = "forgejo";
repo = "forgejo";
rev = "v${version}";
-
hash = "sha256-nufhGsibpPrGWpVg75Z6qdzlc1K+p36mMjlS2MtsuAI=";
+
hash = "sha256-eIxITMvb1q4L2lejbmuPPQ8XG5YYjTo+9RosPEJgZ3g=";
+
# Forgejo has multiple different version strings that need to be provided
+
# via ldflags. main.ForgejoVersion for example is a combination of a
+
# hardcoded gitea compatibility version string (in the Makefile) and
+
# git describe and is easiest to get by invoking the Makefile.
+
# So we do that, store it the src FOD to then extend the ldflags array
+
# in preConfigure.
+
# The `echo -e >> Makefile` is temporary and already part of the next
+
# major release. Furthermore, the ldflags will change next major release
+
# and need to be updated accordingly.
+
leaveDotGit = true;
+
postFetch = ''
+
cd "$out"
+
echo -e 'show-version-full:\n\t@echo ''${FORGEJO_VERSION}' >> Makefile
+
make show-version-full > FULL_VERSION
+
find "$out" -name .git -print0 | xargs -0 rm -rf
+
'';
};
vendorHash = "sha256-+1apPnqbIfp2Nu1ieI2DdHo4gndZObmcq/Td+ZtkILM=";
···
"-X main.Version=${version}"
"-X 'main.Tags=${lib.concatStringsSep " " tags}'"
];
+
+
preConfigure = ''
+
export ldflags+=" -X code.gitea.io/gitea/routers/api/forgejo/v1.ForgejoVersion=$(cat FULL_VERSION) -X main.ForgejoVersion=$(cat FULL_VERSION)"
+
'';
preBuild = ''
go run build/merge-forgejo-locales.go