#5491 Refactoring: Make current Pagure CI hook / plugin system generic
Merged by ngompa. Opened by wombelix.
wombelix/pagure refactor_make_pagure_ci_plugin_system_more_generic  into  master

Download 5491.patch

First step to support additional CI types other than Jenkins.
This should make it generic enough that adding a new file to pagure/api/ci/ and adjusting PAGURE_CI_SERVICES enables it.
The tests still use Jenkins, it's the currently available CI type and testing the general Pagure CI functionality with it is fine.
New CI type should then define additional tests, specific to themselves, in tests/test_<ci_type>.py.

Problem
Currently pagure supports only Jenkins out-of-the-box.
A plugin system is in place but there is Jenkins specific code in global libraries.

Solution
Refactor the code to move all Jenkins specific parts into pagure/api/ci/jenkins.py

Affected files:
- pagure/lib/tasks_services.py
- pagure/api/init.py
- pagure/hooks/pagure_ci.py
- pagure/lib/lib_ci.py

Goal
Pagure core handles all CI types generic.
Specific code is only located in a single file pagure/api/ci/<ci_type>.py.
They are loaded by adding the name to the config Parameter PAGURE_CI_SERVICES.

Tests failing because of https://pagure.io/pagure/issue/5492 (breaking changes in latest pygit2 release)
Workaround applied via https://pagure.io/pagure/pull-request/5493

rebased onto 0c13cf0d61694e5aa9c76adf7d41fb2aad70255f

pretty please pagure-ci rebuild

Duplicate run manually cancelled:

jenkins
Build #333 aborted (commit: d4ebb632)

Build 332 failed, I never saw AssertionError: datetime.date(2024, 12, 2) != datetime.date(2024, 12, 3) before. Let's run the CI again, I have a theory that it's a problem if we run a job over midnight in UTC.

The py 39 tests started at 01:53:17 CEST, this was 7 minutes before midnight in UTC.
And the test failed around 02:05:00 - 02:06:00 CEST, 5 till 6 minutes after midnight UTC.
Could explain that a datetime assertion for something like "today + x" then fails.

py39:

02:09:12  =========================== short test summary info ============================
02:09:12  FAILED tests/test_pagure_flask_ui_repo.py::PagureFlaskRepotests::test_renew_api_token - AssertionError: datetime.date(2024, 12, 2) != datetime.date(2024, 12, 3)
02:09:12  FAILED tests/test_pagure_flask_ui_repo.py::PagureFlaskRepotests::test_revoke_api_token - AssertionError: datetime.date(2024, 12, 2) != datetime.date(2024, 12, 3)
02:09:12  ===== 2 failed, 1664 passed, 3 skipped, 8413 warnings in 917.67s (0:15:17) =====

Anything else was fine, which makes me think that it was just an edge case.

02:58:07  py312: exit 0 (959.51 seconds) /pagure> pytest -n auto tests/ pid=50577
02:58:07    py39: FAIL code 1 (955.61=setup[37.39]+cmd[918.22] seconds)
02:58:07    py310: OK (955.28=setup[35.05]+cmd[920.23] seconds)
02:58:07    py311: OK (928.84=setup[37.55]+cmd[891.29] seconds)
02:58:07    py312: OK (1050.32=setup[90.82]+cmd[959.51] seconds)
02:58:07    evaluation failed :( (3890.13 seconds)

pretty please pagure-ci rebuild

Failures are not related to the PR. AssertionError: unexpectedly None is a problem that randomly happens sometimes and should get better when https://pagure.io/pagure/issue/5466 is implemented.

10:40:41  =========================== short test summary info ============================
10:40:41  FAILED tests/test_pagure_flask_ui_fork.py::PagureFlaskForktests::test_merge_request_pull_merge - AssertionError: unexpectedly None
10:40:41  FAILED tests/test_pagure_flask_ui_fork.py::PagureFlaskForktests::test_merge_request_pull_merge_with_comment - AssertionError: unexpectedly None
10:40:41  === 2 failed, 1664 passed, 3 skipped, 136245 warnings in 1743.65s (0:29:03) ====
10:40:42  py312: exit 1 (1745.37 seconds) /pagure> pytest -n auto tests/ pid=50566
10:40:42    py39: OK (924.98=setup[35.95]+cmd[889.03] seconds)
10:40:42    py310: OK (917.41=setup[33.36]+cmd[884.06] seconds)
10:40:42    py311: OK (893.40=setup[35.37]+cmd[858.03] seconds)
10:40:42    py312: FAIL code 1 (1832.53=setup[87.16]+cmd[1745.37] seconds)
10:40:42    evaluation failed :( (4568.39 seconds)

Can you please fix your commit message in cb11d4f? It's too long in the first line.

rebased onto 0c13cf0d61694e5aa9c76adf7d41fb2aad70255f

rebased onto 0c13cf0d61694e5aa9c76adf7d41fb2aad70255f

Can you please fix your commit message in cb11d4f? It's too long in the first line.

done.

Tests are fine, just the know flappy behavior.

15:14:13  =========================== short test summary info ============================
15:14:13  FAILED tests/test_pagure_flask_ui_fork.py::PagureFlaskForktests::test_merge_request_pull_nochange - AssertionError: unexpectedly None
15:14:13  FAILED tests/test_pagure_flask_ui_fork.py::PagureFlaskForktests::test_merge_request_pull_FF - AssertionError: unexpectedly None
15:14:13  FAILED tests/test_pagure_flask_ui_fork.py::PagureFlaskForktests::test_request_pull_patch_close - AssertionError: unexpectedly None
15:14:13  === 3 failed, 1663 passed, 3 skipped, 136260 warnings in 2651.19s (0:44:11) ====
15:14:14  py312: exit 1 (2653.10 seconds) /pagure> pytest -n auto tests/ pid=50566
15:14:14    py39: OK (933.26=setup[36.68]+cmd[896.58] seconds)
15:14:14    py310: OK (932.82=setup[33.78]+cmd[899.04] seconds)
15:14:14    py311: OK (907.32=setup[36.51]+cmd[870.81] seconds)
15:14:14    py312: FAIL code 1 (2741.26=setup[88.16]+cmd[2653.10] seconds)
15:14:14    evaluation failed :( (5514.74 seconds)
14:46:20  ========= 1666 passed, 3 skipped, 136245 warnings in 941.36s (0:15:41) =========
14:46:20  py312: exit 0 (942.84 seconds) /pagure> pytest -n auto tests/ pid=50553
14:46:20    py39: OK (941.40=setup[37.75]+cmd[903.66] seconds)
14:46:20    py310: OK (933.39=setup[34.19]+cmd[899.20] seconds)
14:46:20    py311: OK (910.65=setup[36.35]+cmd[874.30] seconds)
14:46:20    py312: OK (1031.96=setup[89.12]+cmd[942.84] seconds)
14:46:20    congratulations :) (3817.48 seconds)

:thumbsup:

Pull-Request has been merged by ngompa

Metadata