Skip to content
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

Bsweger/add repo utilities #4

Merged
merged 10 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
rev: 'v1.10.1' # Use the sha / tag you want to point at
hooks:
- id: mypy
additional_dependencies: [types-all]
additional_dependencies: [types-requests]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,56 @@

Tools to standardize repository settings in a specific GitHub organization.

For the Reich Lab repos, we've decided to:
For the Reich Lab repos, we've decided to apply the following settings to the default
branches (e.g., `main`) of our repos:

* Disallow direct pushes to the main branch
* Allow repo write access to all members of the Reich Lab organization
* Require code reviews before merging to the main branch
* Branch cannot be deleted
* Disallow direct pushes (must open a pull request instead)
* Require at least one reviewer approval before merging a pull request
* Require re-approval when changes are made to a pull request

## Setup for local development

# Usage

## Prerequisites

* Write access to all repos in the reichlab GitHub organization
* A `GITHUB_TOKEN` environment variable that contains a [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

## Running the code

1. Install this Python package via pip:

```bash
pip install git+https://github.com/reichlab/standardize-repo-settings.git
```

2. To apply the Reichlab's default branch rulesets to all repos in the Reichlab GitHub organization:
```bash
add_default_rulesets
```

# Setup for local development

The steps below are for setting up a local development environment. This process entails more than just installing the package,
because we need to ensure that all developers have a consistent, reproducible environment.

### Assumptions
## Assumptions

Developers will be using a Python virtual environment that:

- is based on the Python version specified in [.python-version](.python-version).
- contains the dependency versions specified in the "lockfile" (in this case [requirements/requirements-dev.txt](requirements/requirements-dev.txt)).
- contains the package installed in ["editable" mode](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#working-in-development-mode).

### Setup steps
## Setup steps

1. Clone this repository

2. Change to the repo's root directory:

```bash
cd standardize-repo-settings
cd reichlab-repo-utils
```

3. Make sure the correct version of Python is currently active, and create a Python virtual environment:
Expand Down Expand Up @@ -61,12 +84,12 @@ Developers will be using a Python virtual environment that:
python -m pytest
```

## Development workflow
# Development workflow

Because the package is installed in "editable" mode, you can run the code as though it were a normal Python package, while also
being able to make changes and see them immediately.

### Updating dependencies
## Updating dependencies

Prerequisites:
- [`uv`](https://github.com/astral-sh/uv?tab=readme-ov-file#getting-started)
Expand Down
26 changes: 16 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "standardize-repo-settings"
name = "reichlab-repo-utils"
description = "Standardize GitHub repository settings"
license = {text = "MIT License"}
readme = "README.md"
Expand All @@ -11,9 +11,9 @@ classifiers = [
dynamic = ["version"]

dependencies = [
"freezegun",
"structlog",
"requests",
"rich",
"structlog",
]

[project.optional-dependencies]
Expand All @@ -22,21 +22,20 @@ dev = [
"pre-commit",
"pytest",
"ruff",
"types-requests",
]

[project.entry-points."console_scripts"]
standardize_repo_settings = "standardize_repo_settings.app:main"
add_default_rulesets = "reichlab_repo_utils.add_repo_rulesets:main"
archive_repos = "reichlab_repo_utils.archive_repos:main"
list_repos = "reichlab_repo_utils.list_repos:main"

[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"]

[tools.setuptools]
packages = ["standardize_repo_settings"]

[tool.standardize_repo_settings]
# to write json-formatted logs to disk, uncomment the following line specify the file location
# log_file = "/path/to/log/files/rechlab_python_template.log"
packages = ["reichlab_repo_utils"]

[tool.ruff]
line-length = 120
Expand All @@ -49,4 +48,11 @@ inline-quotes = "double"
quote-style = "double"

[tool.setuptools.dynamic]
version = {attr = "standardize_repo_settings.__version__"}
version = {attr = "reichlab_repo_utils.__version__"}

[tool.mypy]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["rich.*"]
follow_imports = "skip"
32 changes: 20 additions & 12 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml --extra dev -o requirements/requirements-dev.txt
certifi==2024.7.4
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
distlib==0.3.8
# via virtualenv
filelock==3.14.0
# via virtualenv
freezegun==1.5.1
# via standardize-repo-settings (pyproject.toml)
identify==2.5.36
# via pre-commit
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.10.0
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
nodeenv==1.8.0
Expand All @@ -29,26 +33,30 @@ platformdirs==4.2.1
pluggy==1.5.0
# via pytest
pre-commit==3.7.0
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
pygments==2.18.0
# via rich
pytest==8.2.0
# via standardize-repo-settings (pyproject.toml)
python-dateutil==2.9.0.post0
# via freezegun
# via reichlab-repo-utils (pyproject.toml)
pyyaml==6.0.1
# via pre-commit
requests==2.32.3
# via reichlab-repo-utils (pyproject.toml)
rich==13.7.1
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
ruff==0.4.3
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
setuptools==72.1.0
# via nodeenv
six==1.16.0
# via python-dateutil
structlog==24.1.0
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
types-requests==2.32.0.20240712
# via reichlab-repo-utils (pyproject.toml)
typing-extensions==4.11.0
# via mypy
urllib3==2.2.2
# via
# requests
# types-requests
virtualenv==20.26.1
# via pre-commit
20 changes: 12 additions & 8 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml -o requirements/requirements.txt
freezegun==1.5.1
# via standardize-repo-settings (pyproject.toml)
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
idna==3.7
# via requests
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
pygments==2.18.0
# via rich
python-dateutil==2.9.0.post0
# via freezegun
requests==2.32.3
# via reichlab-repo-utils (pyproject.toml)
rich==13.7.1
# via standardize-repo-settings (pyproject.toml)
six==1.16.0
# via python-dateutil
# via reichlab-repo-utils (pyproject.toml)
structlog==24.1.0
# via standardize-repo-settings (pyproject.toml)
# via reichlab-repo-utils (pyproject.toml)
urllib3==2.2.2
# via requests
Loading