Changes
8 changed files (+213/-0)
-
DEVELOPMENT.md (new)
-
@@ -0,0 +1,25 @@<!-- Copyright 2026 Shota FUJI <pockawoooh@gmail.com> SPDX-License-Identifier: MIT --> # Development Commands and tips for developing legit. ## Load Testing `tests/k6` directory contains `*.js` for [k6](https://grafana.com/oss/k6/), an OSS load testing tool. These test files access a test server on localhost:8080. Run `nix run .#testing` (you need Nix Flakes) or follow steps described in `tests/k6/.gitignore` manually (you need bash, git, and built `legit` binary) to launch the test server. Once the test server is ready, pass your desired test file to `k6 run` command. Nix user can use `nix run .#k6 -- run` without installing k6 manually. ## Code Formatting This project use [dprint](https://dprint.dev/). You have to install [`nixfmt`](https://github.com/NixOS/nixfmt) and Go toolchain as well. Nix user can run `nix fmt` without installing or configuring anything.
-
-
-
@@ -47,6 +47,25 @@default = legit; testing = let repos = pkgs.callPackage ./tests/k6/repos.nix { }; in pkgs.writeShellApplication { name = "legit-testing"; text = '' ${pkgs.lib.getExe legit} -config ${repos}/tests/k6/config.yaml ''; runtimeInputs = with pkgs; [ git legit repos ]; }; docker = pkgs.dockerTools.buildLayeredImage { name = "sini:5000/legit"; tag = "latest";
-
@@ -65,6 +84,15 @@} ); apps = forAllSystems ( { system, pkgs }: { k6 = { type = "app"; program = pkgs.lib.getExe pkgs.k6; }; } ); formatter = forAllSystems ( { system, pkgs }: pkgs.buildFHSEnv {
-
-
tests/k6/.gitignore (new)
-
@@ -0,0 +1,10 @@# Copyright 2026 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: MIT # Test repositories. To manually run test server, run below: # mkdir repos # cd repos # bash ../create_repos.bash # cd .. # ../../legit -config config.yaml /repos
-
-
tests/k6/config.yaml (new)
-
@@ -0,0 +1,22 @@# Copyright 2026 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: MIT repo: scanPath: repos readme: - README.md mainBranch: - trunk dirs: templates: ../../templates static: ../../static meta: title: Legit Load Testing syntaxHighlight: true server: name: example.com host: localhost port: 8080
-
-
-
@@ -0,0 +1,68 @@# create_repos.bash # Bash script to create sample repos in the current directory. # # Copyright 2026 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: MIT # Usage # cd test_dir # bash /path/to/create_repos.bash set -e # To get deterministic output. export GIT_CONFIG_GLOBAL=/dev/null export GIT_CONFIG_SYSTEM=/dev/null export GIT_COMMITTER_DATE="2026-06-30T09:00:00+09:00" GIT_FLAGS=( "-c" "user.name=Alice" "-c" "user.email=alice@example.com" "-c" "init.defaultBranch=trunk" ) # foo - basic sample git ${GIT_FLAGS[@]} init foo cat <<EOF > foo/README.md # Foo This is foo. I'm [Markdown](https://commonmark.org/) file for *load* **testing**. ``` This file is to test Markdown rendering performance of summary page. ``` * longer * the * contents * and * more + readable + comparable * output EOF git ${GIT_FLAGS[@]} -C foo add README.md git ${GIT_FLAGS[@]} -C foo commit \ -m "Add README" \ --date "2026-06-06T12:00:00+09:00" cat <<EOF > foo/main.go package main import ( "fmt" ) func main() { fmt.Println("Hello, World!") } EOF git ${GIT_FLAGS[@]} -C foo add main.go git ${GIT_FLAGS[@]} -C foo commit \ -m "Create Go application entrypoint" \ --date "2026-06-06T12:01:00+09:00" git clone --bare foo foo.git rm -rf foo
-
-
tests/k6/repos.nix (new)
-
@@ -0,0 +1,36 @@# Copyright 2026 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: MIT { lib, stdenv, bash, git, }: stdenv.mkDerivation { name = "legit-test-repos"; src = lib.fileset.toSource { root = ../../.; fileset = lib.fileset.unions [ ./create_repos.bash ./config.yaml ../../static ../../templates ]; }; postInstall = '' mkdir -p $out/tests/k6/repos cd $out/tests/k6/repos bash $src/tests/k6/create_repos.bash ln -s $src/tests/k6/config.yaml $out/tests/k6/config.yaml ln -s $src/static $out/static ln -s $src/templates $out/templates ''; nativeBuildInputs = [ bash git ]; }
-
-
-
@@ -0,0 +1,12 @@// Copyright 2026 Shota FUJI <pockawoooh@gmail.com> // SPDX-License-Identifier: MIT import http from "k6/http"; export const options = { iterations: 10, }; export default function() { http.get("http://localhost:8080"); }
-
-
-
@@ -0,0 +1,12 @@// Copyright 2026 Shota FUJI <pockawoooh@gmail.com> // SPDX-License-Identifier: MIT import http from "k6/http"; export const options = { iterations: 10, }; export default function() { http.get("http://localhost:8080/foo.git"); }
-