runbot/runbot_merge/tests
Xavier Morel c8a06601a7 [FIX] *: unstage on status going from success to failure
And unconditionally unstage when the HEAD of a PR is synchronised.

While a rebuild on a PR which was previously staged can be a false
positive (e.g. because it hit a non-derministic test the second time
around) it can also be legitimate e.g. auto-rebase of an old PR to
check it out. In that case the PR should be unstaged.

Furthermore, as soon as the PR gets rebuilt it goes back into
`approved` (because the status goes to pending and currently there's
no great way to suppress that in the rebuild case without also fucking
it up for the sync case). This would cause a sync on the PR to be
missed (in that it would not unstage the PR), which is broken. Fix
that by not checking the state of the PR beforehand, it seems to be an
unnecessary remnant of older code, and not really an optimisation (or
at least one likely not worth bothering with, especially as we then
proceed to perform a full PR validation anyway).

Fixes #950
2024-09-18 15:19:13 +02:00
..
conftest.py [REM] *: default_crons fixture 2024-08-02 15:14:50 +02:00
README.rst [IMP] runbot_merge: test readme & remove leftover pass 2018-09-03 13:16:36 +02:00
test_basic.py [CHG] runbot_merge: deskill mergebot feedback 2024-08-05 09:09:23 +02:00
test_batch_consistency.py [FIX] runbot_merge: flaky test 2024-08-05 08:58:05 +02:00
test_by_branch.py [IMP] *: rely only on triggers to run statuses propagation 2024-08-02 12:12:20 +02:00
test_dfm.py [ADD] runbot_merge: rendering of PR descriptions 2024-07-15 10:28:28 +02:00
test_disabled_branch.py [IMP] *: crons tests running for better triggered compatibility 2024-08-02 09:00:34 +02:00
test_multirepo.py [IMP] *: trigger-ify staging cron 2024-08-02 15:14:50 +02:00
test_oddities.py [FIX] *: UX around fw=no 2024-09-17 11:31:20 +02:00
test_project_toggles.py [IMP] *: trigger-ify staging cron 2024-08-02 15:14:50 +02:00
test_provisioning.py [IMP] runbot_merge, forwardport: minor cleanups 2023-08-10 13:33:16 +02:00
test_staging.py [FIX] *: unstage on status going from success to failure 2024-09-18 15:19:13 +02:00
test_status_overrides.py [ADD] *: per-repository webhook secret 2024-06-06 11:07:57 +02:00

Execute this test suite using pytest.

The default mode is to run tests locally using a mock github.com.

See the docstring of remote.py for instructions to run against github "actual"
(including remote-specific options) and the end of this file for a sample.

Shared properties running tests, regardless of the github implementation:

* test should be run from the root of the runbot repository providing the
  name of this module aka ``pytest runbot_merge`` or
  ``python -mpytest runbot_merge``
* a database name to use must be provided using ``--db``, the database should
  not exist beforehand
* the addons path must be specified using ``--addons-path``, both "runbot" and
  the standard addons (odoo/addons) must be provided explicitly

See pytest's documentation for other options, I would recommend ``-rXs``,
``-v`` and ``--showlocals``.

When running "remote" tests as they take a very long time (hours) ``-x``
(aka ``--maxfail=1``) and ``--ff`` (run previously failed first) is also
recommended unless e.g. you run the tests overnight.

``pytest.ini`` sample
---------------------

.. code:: ini

    [github]
    owner = test-org
    token = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

    [role_reviewer]
    name = Dick Bong
    user = loginb
    token = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

    [role_self_reviewer]
    name = Fanny Chmelar
    user = loginc
    token = cccccccccccccccccccccccccccccccccccccccc

    [role_other]
    name = Harry Baals
    user = logind
    token = dddddddddddddddddddddddddddddddddddddddd