Conversation
50f6d81 to
3d3132e
Compare
1b86870 to
6b5fb45
Compare
pyproject.toml
Outdated
| dev = [ | ||
| "pip-tools", | ||
| "pytest", | ||
| "pytest-ruff", |
There was a problem hiding this comment.
pytest-ruff looks like a small, mostly unmaintained project (last activity 9 months ago, adding Python 3.13 support). We should roll our own formatting tests as we do in other projects.
There was a problem hiding this comment.
Maybe it's just feature complete? 😆
There was a problem hiding this comment.
Lando uses both Black and Ruff. Why do we use both and not just one?
| "rs_parsepatch", | ||
| ] | ||
| description = "Select reviewers based on a diff and a set of rules" | ||
| dynamic = ["version"] |
There was a problem hiding this comment.
I think this field only needs to be set when using setuptools-scm. Perhaps we could add that now.
There was a problem hiding this comment.
I thought it would, and was surprised that it... just worked? (TBF, I haven't checked the version anywhere, but it just didn't choke on it).
I'm not sure we need setuptools at all considering we don't build sdist-type files.
OTOH, I have just tried adding a tag now, and the version is still 0.0.0 with or without setuptools-scm.
There was a problem hiding this comment.
As this package is intended to be a library/client-side CLI tool (as opposed to server-side software) I don't think we need a requirements.txt. Specifying the requirements in pyproject.toml will allow the build to find packages that work for the client given other venv conflicts, as long as we ensure we specify any incompatible versions.
requirements-dev.txt is still valid for running local tests and builds against a known-good version.
There was a problem hiding this comment.
I think it's gonna be server-side: we build a docker container that will be used in response to hooks. If anything, as we refine the reviewer selection, this will be used as the shell to potentially bring in other libraries, but not the other way round.
It is, however, designed as a CLI for ease of testing in isolation, but I think having the requirements.txt here helps too, to recreate a known-good environment for the CLI.
tests/test_reviewer_selector.py
Outdated
| resolve_reviewers, | ||
| ) | ||
|
|
||
| MAIN_SCRIPT = "src/reviewer_selector.py" |
There was a problem hiding this comment.
If you want to test the script end-to-end, we should simply execute the name as defined in pyproject.toml:project.scripts (ie subprocess.run(["reviewer-selector"... in this case). Alternatively we could run the main() method directly. Executing the script in this way is brittle as changing the project structure will cause unrelated test failures. It also doesn't reflect any changes to the environment that may happen as part of the build/install.
There was a problem hiding this comment.
I'll go with the installed script name, rather than the main, to be sure to test the whole flow (including correct installation of the script).
There was a problem hiding this comment.
If this Docker container is used for running tests, perhaps we should use it in the GHA workflow instead of installing requirements-dev.txt and running pytest directly.
There was a problem hiding this comment.
This container is the main artifact that gets run by the TC hook. It's very very lean at the moment, but yeah... I'll see if I can keep the test dependencies out of the container.
* REPO_URL allows to fetch rules from the target repo * ORG_NAME allows to prefix review groups correctly
docker/Dockerfile
Outdated
| COPY . /app | ||
| RUN pip install -r requirements.txt \ | ||
| && pip install /app |
There was a problem hiding this comment.
Nit: it would be better to COPY the requirements file in and build the venv first, then copy the app code. That way we only re-build the container when the requirements.txt file changes, instead of each time the app code changes.
This is a nit as it's not super important for an MVP project. :)
There was a problem hiding this comment.
Ah, I didn't think of that. In a previous installment I had a RUN --mount, but I removed it when I ended up COPYing everything. I'll restore that!
| @@ -0,0 +1,73 @@ | |||
| #!/bin/sh -eu | |||
There was a problem hiding this comment.
Small non-blocking request: could I trouble you to convert this into an entrypoint.py instead? As our team's stack is Python, it seems it would be easier to maintain. I can generally follow what's happening in this script, but if there was a subtle shell-script bug here I would have a hard time spotting it. :)
There was a problem hiding this comment.
Ah, yeah. That shell script kinda grew a bit in size. I think the rewrite will happen naturally in the next few PR as I integrate TC and GitHub, and Python code ultimately becomes a shell around mots.
README.md
Outdated
| to set the reviewers on the target PR. | ||
| * If `DIFF_URL` is given, it will be fetched and passed into the selector's | ||
| stdin. | ||
| * If `GITHUB_TOKEN` and `PR_URL` are provided, the container will attempt |
There was a problem hiding this comment.
| * If `GITHUB_TOKEN` and `PR_URL` are provided, the container will attempt | |
| * If `GITHUB_TOKEN` and `PR_URL` are provided, the container will attempt to set the reviewers on the target PR. |
There was a problem hiding this comment.
Ah! This one travelled all the way to the bottom of the file!
| "black", | ||
| "pip-tools", | ||
| "pytest", | ||
| "ruff", |
There was a problem hiding this comment.
Nit: it might be worth pinning these to specific versions.
There was a problem hiding this comment.
What would be the rationale here? We are hard-pinned by the requirements.txt, so my instinct would be to have nothing more than a loose pinning here, likely if we encounter incompatibility with newer versions that we can't fix immediately.
Uh oh!
There was an error while loading. Please reload this page.