Skip to content

Add a collectoss selftest report command to the CLI#287

Draft
MoralCode wants to merge 15 commits intomainfrom
feat/selfcheck
Draft

Add a collectoss selftest report command to the CLI#287
MoralCode wants to merge 15 commits intomainfrom
feat/selfcheck

Conversation

@MoralCode
Copy link
Copy Markdown
Contributor

@MoralCode MoralCode commented May 4, 2026

Description
This feature adds a new subcommand to the collectOSS CLI that performs a self-test of Augur

This PR is the first phase of implementing #159

Currently this checks for:

  • commits (commit changes) with an empty string for the author name (indicator that cleanup is needed after bug Facade not correctly populating author name in commits table #233 on older instances)
  • alembic database synchronization - CollectOSS Databases should align with the current schema. This uses the built in check feature of alembic (our database versioning tool) to compare what is in the database and what the model says should be there. (This includes a translation layer to make the output a little clearer to instance admins who arent as familiar with collectoss internals or alembic)

Sample output:

$ uv run collectoss selftest report
      Built collectoss @ file:///home/adredwar/Desktop/Projects/CollectOSS/collectoss
Uninstalled 1 package in 2ms
Installed 1 package in 8ms
Generating CollectOSS selftest report....
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
/home/adredwar/Desktop/Projects/CollectOSS/collectoss/collectoss/application/schema/alembic/env.py:107: SAWarning: Cannot correctly sort tables; there are unresolvable cycles between tables "spdx.packages, spdx.packages_files", which is usually caused by mutually dependent foreign key constraints.  Foreign key constraints involving these tables will not be considered; this warning may raise an error in a future release.
  context.run_migrations()
INFO  [alembic.ddl.postgresql] Detected sequence named 'dei_badging_id_seq' as owned by integer column 'dei_badging(id)', assuming SERIAL and omitting
INFO  [alembic.ddl.postgresql] Detected sequence named 'chaoss_user_chaoss_id_seq' as owned by integer column 'chaoss_user(chaoss_id)', assuming SERIAL and omitting
INFO  [alembic.ddl.postgresql] Detected sequence named 'topic_model_event_event_id_seq' as owned by integer column 'topic_model_event(event_id)', assuming SERIAL and omitting
INFO  [alembic.ddl.postgresql] Detected sequence named 'subscription_types_id_seq' as owned by integer column 'subscription_types(id)', assuming SERIAL and omitting
INFO  [alembic.autogenerate.compare] Detected added foreign key (cmt_author_platform_username)(cntrb_login) on table augur_data.commits
INFO  [alembic.autogenerate.compare] Detected added unique constraint 'GH-UNIQUE-C' on '('gh_login',)'
INFO  [alembic.autogenerate.compare] Detected added unique constraint 'GL-cntrb-LOGIN-UNIQUE' on '('cntrb_login',)'
Issue 233 count: 0 commit changes in the `commits` table contain authors with an empty string as their name
❌ Database drift detected:
Foreign Key called 'fk_commits_contributors_3' on `commits.cmt_author_platform_username` linking to `augur_data.commits`
        Rules: ON UPDATE CASCADE | ON DELETE CASCADE | DEFERRABLE | INITIALLY DEFERRED
        found in models but not database
UniqueConstraint called 'GH-UNIQUE-C' covering gh_login
        found in models but not database
UniqueConstraint called 'GL-cntrb-LOGIN-UNIQUE' covering cntrb_login
        found in models but not database

Note: This is more likely to be run with docker exec in production, rather than uv run

Notes for Reviewers

Still to do:

Signed commits

  • Yes, I signed my commits.

MoralCode added 14 commits May 1, 2026 21:04
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…the code

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…umption

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Suggestion from Gemini

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
process_repo_group_csv,
)

from ._cli_util import get_db_version
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused get_db_version imported from _cli_util (unused-import)

Comment thread collectoss/application/cli/selftest.py Outdated
import sqlalchemy as s
from sqlalchemy import Constraint, ForeignKeyConstraint, Index, select, func, Table

from collectoss.application.cli import (
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused test_connection imported from collectoss.application.cli (unused-import)

Comment thread collectoss/application/cli/selftest.py Outdated
Comment thread collectoss/application/cli/selftest.py Outdated
Comment thread collectoss/application/cli/selftest.py Outdated
Comment thread collectoss/application/cli/selftest.py Outdated
Comment thread collectoss/application/cli/selftest.py Outdated
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
@MoralCode MoralCode linked an issue May 5, 2026 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a system verification/diagnostic/self test script

1 participant