canonical / discourse-gatekeeper

Experimental GitHub Action to upload charm documentation to charmhub
Apache License 2.0
7 stars 7 forks source link

Upgrade project structure so a package can be build #244

Closed javierdelapuente closed 3 months ago

javierdelapuente commented 3 months ago

Applicable spec:

Overview

Currently, the repo https://github.com/canonical/gatekeeper-repo-test has a copy of all the code of this (discourse-gatekeeper) repo.

This is problematic, as it has to be updated from time to time. This PR prepares discourse-gatekeeper to be used as a package, so it can be easily included in https://github.com/canonical/gatekeeper-repo-test (see https://github.com/canonical/gatekeeper-repo-test/pull/466 for a working example).

The main change of this PR is to put all the code under the gatekeeper module (instead of just under src) and preparing pyproject.toml for the building.

Rationale

Module Changes

Checklist

deusebio commented 3 months ago

Actually, one thought: maybe it would make things a bit more structured (and it should be rather straightforward) if when we merge to main, we also release the python package with github releases. Then one can simply install this using

pip install https://github.com/canonical/discourse-gatekkeeper/releases/download/vX.Y.Z/gatekeeper-X.Y.Z-py3-none-any.whl

Eventually we could publish this to pypi, but it is probably not needed right now, and I believe github releases would be good enough. This would however provide a bit of better versioning of this and allow version pinning. I would really not use

git+https://github.com/canonical/discourse-gatekeeper.git@main

We have done these things above in this repository: here is the CI and here are the releases.

jdkandersson commented 3 months ago

Actually, one thought: maybe it would make things a bit more structured (and it should be rather straightforward) if when we merge to main, we also release the python package with github releases. Then one can simply install this using

pip install https://github.com/canonical/discourse-gatekkeeper/releases/download/vX.Y.Z/gatekeeper-X.Y.Z-py3-none-any.whl

Eventually we could publish this to pypi, but it is probably not needed right now, and I believe github releases would be good enough. This would however provide a bit of better versioning of this and allow version pinning. I would really not use

git+https://github.com/canonical/discourse-gatekeeper.git@main

We have done these things above in this repository: here is the CI and here are the releases.

I agree with this, probably we should do it as well :)

javierdelapuente commented 3 months ago

Actually, one thought: maybe it would make things a bit more structured (and it should be rather straightforward) if when we merge to main, we also release the python package with github releases. Then one can simply install this using

pip install https://github.com/canonical/discourse-gatekkeeper/releases/download/vX.Y.Z/gatekeeper-X.Y.Z-py3-none-any.whl

Eventually we could publish this to pypi, but it is probably not needed right now, and I believe github releases would be good enough. This would however provide a bit of better versioning of this and allow version pinning. I would really not use

git+https://github.com/canonical/discourse-gatekeeper.git@main

We have done these things above in this repository: here is the CI and here are the releases.

I agree with this, probably we should do it as well :)

Do you mind to leave it for a following PR? Its first use is just for the e2e tests, which will use branches (and using main and failing is also good, as it is a test). Clearly publishing is better for the main case if the library is used outside the e2e use.

deusebio commented 3 months ago

Do you mind to leave it for a following PR? Its first use is just for the e2e tests, which will use branches (and using main and failing is also good, as it is a test). Clearly publishing is better for the main case if the library is used outside the e2e use.

It was not a blocking comment on my side (actually I had already approved I believe). Up to you guys

github-actions[bot] commented 3 months ago

Test coverage for 856e1bc20c48c1b564c8f2fb5ad19031c1db4536

Name                                 Stmts   Miss Branch BrPart  Cover   Missing
--------------------------------------------------------------------------------
src/gatekeeper/__init__.py              97      0     42      0   100%
src/gatekeeper/action.py               159      0     48      0   100%
src/gatekeeper/check.py                 63      0     25      0   100%
src/gatekeeper/clients.py               12      0      0      0   100%
src/gatekeeper/commit.py                42      0     12      0   100%
src/gatekeeper/constants.py              9      0      0      0   100%
src/gatekeeper/content.py               50      0     10      0   100%
src/gatekeeper/discourse.py            159      0     34      0   100%
src/gatekeeper/docs_directory.py        33      0      8      0   100%
src/gatekeeper/download.py              22      0      2      0   100%
src/gatekeeper/exceptions.py            15      0      0      0   100%
src/gatekeeper/index.py                142      0     56      0   100%
src/gatekeeper/metadata.py              59      0     28      0   100%
src/gatekeeper/migration.py            102      0     33      0   100%
src/gatekeeper/navigation_table.py      65      0     20      0   100%
src/gatekeeper/reconcile.py            123      0     60      0   100%
src/gatekeeper/repository.py           293      0     88      0   100%
src/gatekeeper/sort.py                  43      0     26      0   100%
src/gatekeeper/types_.py               202      0     54      0   100%
--------------------------------------------------------------------------------
TOTAL                                 1690      0    546      0   100%

Static code analysis report

Working... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
Run started:2024-04-10 13:14:14.292121

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 17878
    Total lines skipped (#nosec): 3
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
Files skipped (0):