Koha-clms/xt
Jonathan Druart 9f32eea89f
Bug 39877: Incremental test runs
The idea of this patchset is to allow increment runs for some of our
tests.
The current (full) test suite runs in 2h20 (Koha_Main/3253 on Docker_15).

One of the main reason is the recent introduction of new xt tests that are run on all files (valid, tidy, pod, codespell, etc).

From a previous run (last week) I noted this top 5:

xt/vue_tidy.t          105446 ms
xt/perltidy.t          175970 ms
xt/js_tidy.t           239615 ms
xt/author/codespell.t  467041 ms
xt/pl_valid.t          2502354 ms

We are going to merge js_tidy.t and vue_tidy.t as it does no longer make
sense to have a difference between them (we had at the beginning of the
vue work, because of differences in the options, now everything is
handled in the .prettierrc config file)

Once this is pushed, we will be able to create a new project on gitlab
and pass some env variables from Jenkins.
Suggestion: project would be named https://gitlab.com/koha-community/koha-ci-results
When everything will be setup, jenkins will run the tests one the whole
test suite, then the next run will be "incremental": we are going to run
the tests on the files that were failing and the files modified by the
last push.
Example:
 * "commit abc": all the files are tested, xt/perltidy.t is failing on Koha.pm
 * koha-ci-results/perltidy/abc is created and contains ['Koha.pm']
 * "commit def" has a modification on about.pl
 * xt/perltidy.t is checking tidy on Koha.pm and about.pl, both are tidy
 * koha-ci-results/perltidy/def is created and contains []

Test plan:
* Create an empty project on gitlab (keep the default readme)
  eg. https://gitlab.com/me/koha-ci-results
* Generate an access token with the developer role
  (https://gitlab.com/me/koha-ci-results/-/settings/access_tokens)
  Copy the token (in the following noted as TOKEN_REPLACE_ME)
* Unprotect the "main" branch
* Run the following prove command:
```
KOHA_CI_INCREMENTAL_RUN_REPO_URL=https://gitlab.com/me/koha-ci-results.git \
KOHA_CI_INCREMENTAL_RUNS=1 \
KOHA_CI_INCREMENTAL_RUNS_REPORT=1 \
KOHA_CI_INCREMENTAL_RUNS_TOKEN=TOKEN_REPLACE_ME \
prove xt/perltidy.t
```
=> a new commit is created on your repo
* Add some mess in one of your perl file, commit using `--no-verify` to
  bypass the git hook
* Run the prove command again
=> only the file you have modified is tested
=> a new commit is created and the file is reported as failing
* Add another commit, fix the failure, add other mess
=> confirm that what you are seeing makes sense :)

* Ideally redo with the different tests modified by this patchset

* Note that you can use the incremental run without the report (the report will
be only for Jenkins).
It will help RM as xt tests will run (way) faster.

Note that you can also export the following env vars to set git author
detail:
 * GIT_COMMITTER_NAME
 * GIT_COMMITTER_EMAIL
 * GIT_AUTHOR_NAME
 * GIT_AUTHOR_EMAIL

Question: What are we going to use on Jenkins?

Discussion for QA: How should we handle concurrency?
It's crucial to prevent multiple tests from pushing simultaneously.
To minimize the risk of the repository becoming outdated, we might need to perform
a pull right before each push. Is that enough? Keep in mind that only one job will
be run at the same time (Koha_Main).
Maybe later we will also use it for stable branches.

Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-10-10 06:20:16 -06:00
..
author Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
api.t Bug 40512: (follow-up) Fix api.t 2025-10-02 09:38:19 -06:00
check_makefile.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-license-problems.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-misplaced-executables.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-missing-auth_checks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-missing-csrf.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-missing-filters.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
find-missing-new-lines-at-the-end-of-file.t Bug 40858: Rename context 'all' with 'core' 2025-09-24 09:24:55 -06:00
find-missing-op-in-forms.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
js_tidy.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
perltidy.t Bug 40444: Add Test::NoWarnings to xt tests 2025-07-28 16:26:37 -06:00
pl_valid.t Bug 39877: Incremental test runs 2025-10-10 06:20:16 -06:00
single_quotes.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
tt_tidy.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
use-test-no-warnings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
verify-debian-docbook.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
verify-yarnlock.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
verify_bib1.att.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
vue_tidy.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
yaml_valid.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
yaml_valid.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00