-
Notifications
You must be signed in to change notification settings - Fork 0
pyproject: standardise project layout #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
d2d3a4d
6c359a0
e17b19e
4b27a91
33271e5
1a81f99
f6e6589
8067586
958eebb
9a571c9
8c87df5
8511c40
cc9693c
99bd08d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| __pycache__ | ||
| mise.toml | ||
| herald_rules.json | ||
| build/ | ||
| *.egg-info |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this Docker container is used for running tests, perhaps we should use it in the GHA workflow instead of installing
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,13 @@ RUN apt-get -y update \ | |
| RUN mkdir /app | ||
| WORKDIR /app | ||
|
|
||
| RUN --mount=type=bind,src=requirements.txt,target=/app/requirements.txt pip install -r requirements.txt | ||
| COPY . /app | ||
| RUN pip install -r requirements.txt \ | ||
| && pip install /app | ||
|
||
|
|
||
| COPY reviewer_selector.py entrypoint.sh /app/ | ||
| COPY ../src/reviewer_selector.py ../docker/entrypoint.sh /app/ | ||
| # Example for self-contained quick tests. | ||
| COPY herald_rules.sample.json /app/herald_rules.json | ||
| COPY ../samples/herald_rules.sample.json /app/herald_rules.json | ||
|
|
||
| CMD [ "herald_rules.json" ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/bin/sh -eu | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small non-blocking request: could I trouble you to convert this into an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| # Variables expected in environment: | ||
| # * DIFF_URL (optional, will read stdin otherwise) | ||
| # * GITHUB_TOKEN (optional, will output reviewers to stdout otherwise) | ||
| # * PR_URL (optional, will output reviewers to stdout otherwise) | ||
| # * ORG_NAME (optional, will use # as a group prefix otherwise) | ||
| # * REPO_NAME (optional, for more rule matching with TARGET_BRANCH_NAME) | ||
| # * TARGET_BRANCH_NAME (optional, for more rule matching with REPO_NAME) | ||
| # * REPO_URL (optional, to fetch specific rules) | ||
|
|
||
| CURL="curl --fail --show-error --silent --location" | ||
|
|
||
| if [ -n "${REPO_URL:-}" ]; then | ||
| HERALD_RULES_JSON=$(mktemp) | ||
| # We always fetch the rules from the main branch. | ||
| RULES_URL="${REPO_URL}/refs/heads/main/herald_rules.json" | ||
|
|
||
| if ! ${CURL} "${RULES_URL}" --output "${HERALD_RULES_JSON}"; then | ||
| echo "Failed to fetch rules from ${RULES_URL}, using built-in rules ..." >&2 | ||
| HERALD_RULES_JSON="" | ||
|
|
||
| fi | ||
|
|
||
| else | ||
| echo "No REPO_URL in environment, using built-in rules ..." >&2 | ||
|
|
||
| fi | ||
|
|
||
| if [ -z "${HERALD_RULES_JSON:-}" ]; then | ||
| HERALD_RULES_JSON="${1}" | ||
| fi | ||
|
|
||
| DIFF=$(mktemp) | ||
| if [ -n "${DIFF_URL:-}" ]; then | ||
| ${CURL} "${DIFF_URL}" --output "${DIFF}" | ||
|
|
||
| else | ||
| echo "No DIFF_URL in environment, reading from stdin ..." >&2 | ||
| cat > "${DIFF}" | ||
|
|
||
| fi | ||
|
|
||
| if [ -n "${ORG_NAME:-}" ]; then | ||
| GROUP_PREFIX="${ORG_NAME}/" | ||
|
|
||
| else | ||
| GROUP_PREFIX="#" | ||
| echo "No ORG_NAME in environment, using ${GROUP_PREFIX} as group prefix ..." >&2 | ||
|
|
||
| fi | ||
|
|
||
| if [ -n "${REPO_NAME:-}" ] && [ -n "${TARGET_BRANCH_NAME:-}" ]; then | ||
| REPO_BRANCH=${REPO_NAME}-${TARGET_BRANCH_NAME} | ||
|
|
||
| else | ||
| echo "No REPO_NAME or TARGET_BRANCH_NAME in environment, not matching repository-based rules ..." >&2 | ||
| fi | ||
|
|
||
| REVIEWERS=$(cat "${DIFF}" \ | ||
| | /app/reviewer_selector.py \ | ||
| ${REPO_BRANCH:+--repo "${REPO_BRANCH}"} \ | ||
| --group-prefix "${GROUP_PREFIX}" --reviewer-separator , \ | ||
| "${HERALD_RULES_JSON}" \ | ||
| ) | ||
|
|
||
| if [ -n "${GITHUB_TOKEN:-}" ] && [ -n "${PR_URL:-}" ]; then | ||
| echo "Adding reviewers to ${PR_URL} ..." >&2 | ||
| gh pr edit "${PR_URL}" --add-reviewer "${REVIEWERS}" | ||
|
|
||
| else | ||
| echo "No PR_URL or GITHUB_TOKEN in environment, outputing to stdout ..." >&2 | ||
| echo "${REVIEWERS}" | ||
| fi | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,33 @@ | ||
| [tool.pytest] | ||
| addopts = ["--ruff", "--ruff-format" ] | ||
| [build-system] | ||
| requires = ["setuptools>=80", "setuptools-scm>=8"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| classifiers = [ | ||
| "Development Status :: 3 - Alpha", | ||
| "Intended Audience :: Developers", | ||
| "Operating System :: OS Independent", | ||
| "Programming Language :: Python :: 3", | ||
| ] | ||
| dependencies= [ | ||
| "rs_parsepatch", | ||
| ] | ||
| description = "Select reviewers based on a diff and a set of rules" | ||
| dynamic = ["version"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this field only needs to be set when using
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 |
||
| license = "MPL-2.0" | ||
| maintainers = [ | ||
| {name = "Mozilla Conduit", email = "conduit-team@mozilla.com"}, | ||
| ] | ||
| name = "reviewer-selector" | ||
| requires-python = ">=3.12" | ||
|
|
||
| [project.optional-dependencies] | ||
| dev = [ | ||
| "black", | ||
| "pip-tools", | ||
| "pytest", | ||
| "ruff", | ||
|
Comment on lines
+26
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: it might be worth pinning these to specific versions.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the rationale here? We are hard-pinned by the |
||
| ] | ||
|
|
||
| [project.scripts] | ||
| reviewer-selector = "reviewer_selector:main" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! This one travelled all the way to the bottom of the file!