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

[pull] V3/develop from Cog-Creators:V3/develop #27

Merged
merged 16 commits into from
Dec 11, 2022
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
14 changes: 7 additions & 7 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Cogs
/redbot/cogs/audio/** @aikaterna @PredaaA
/redbot/cogs/downloader/* @jack1142
/redbot/cogs/downloader/* @Jackenmen
/redbot/cogs/streams/* @palmtree5
/redbot/cogs/mutes/* @TrustyJAID

# Docs - Install and update guides
/docs/install_guides/** @jack1142
/docs/update_red.rst @jack1142
/docs/install_guides/** @Jackenmen
/docs/update_red.rst @Jackenmen

# Docs - Version guarantees
/docs/version_guarantees.rst @jack1142
/docs/version_guarantees.rst @Jackenmen

# Trivia Lists
/redbot/cogs/trivia/data/lists/whosthatpokemon*.yaml @aikaterna

# Tests
/redbot/pytest/downloader* @jack1142
/tests/cogs/downloader/* @jack1142
/redbot/pytest/downloader* @Jackenmen
/tests/cogs/downloader/* @Jackenmen

# Schemas
/schema/* @jack1142
/schema/* @Jackenmen

# CI
/.travis.yml @Kowlin
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U pip wheel
python -m pip install -e .[all]
# Set the `CODEQL-PYTHON` environment variable to the Python executable
# that includes the dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- run: "python -m pip install git+https://github.com/pycqa/pyflakes@1911c20#egg=pyflakes git+https://github.com/pycqa/pycodestyle@d219c68#egg=pycodestyle git+https://gitlab.com/pycqa/[email protected]#egg=flake8"
- run: "python -m pip install git+https://github.com/pycqa/pyflakes@1911c20#egg=pyflakes git+https://github.com/pycqa/pycodestyle@d219c68#egg=pycodestyle git+https://github.com/pycqa/[email protected]#egg=flake8"
name: Install Flake8
- run: "python -m flake8 . --count --select=E9,F7,F82 --show-source"
name: Flake8 Linting
84 changes: 84 additions & 0 deletions .github/workflows/run_pip_compile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Generate requirements files with pip-compile.

on:
workflow_dispatch:

jobs:
generate_requirements:
name: Generate requirements files for ${{ matrix.os }} platform.
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Checkout the repository.
uses: actions/checkout@v3

- name: Set up Python 3.8.
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U pip-tools

- name: Generate requirements files.
id: compile_requirements
run: |
python .github/workflows/scripts/compile_requirements.py

- name: Upload requirements files.
uses: actions/upload-artifact@v3
with:
name: ${{ steps.compile_requirements.outputs.sys_platform }}
path: requirements/${{ steps.compile_requirements.outputs.sys_platform }}-*.txt

merge_requirements:
name: Merge requirements files.
needs: generate_requirements
runs-on: ubuntu-latest
steps:
- name: Checkout the repository.
uses: actions/checkout@v3

- name: Set up Python 3.8.
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install -U "packaging>=22.0"

- name: Download Windows requirements.
uses: actions/download-artifact@v3
with:
name: win32
path: requirements
- name: Download Linux requirements.
uses: actions/download-artifact@v3
with:
name: linux
path: requirements
- name: Download macOS requirements.
uses: actions/download-artifact@v3
with:
name: darwin
path: requirements

- name: Merge requirements files.
run: |
python .github/workflows/scripts/merge_requirements.py

- name: Upload merged requirements files.
uses: actions/upload-artifact@v3
with:
name: merged
path: |
requirements/base.txt
requirements/extra-*.txt
15 changes: 11 additions & 4 deletions .github/workflows/scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import os
import re
import sys
from typing import Match
from typing import Any, Match

import redbot

GITHUB_OUTPUT = os.environ["GITHUB_OUTPUT"]


def set_output(name: str, value: Any) -> None:
with open(GITHUB_OUTPUT, "a", encoding="utf-8") as fp:
fp.write(f"{name}={value}\n")


if int(os.environ.get("JUST_RETURN_VERSION", 0)):
print(f"::set-output name=version::{redbot._VERSION}")
set_output("version", redbot._VERSION)
sys.exit(0)


Expand All @@ -17,7 +24,7 @@
def repl(match: Match[str]) -> str:
global version_info

print(f"::set-output name=old_version::{match.group('version')}")
set_output("old_version", match.group("version"))

new_stable_version = os.environ.get("NEW_STABLE_VERSION", "auto")
if new_stable_version == "auto":
Expand Down Expand Up @@ -49,4 +56,4 @@ def repl(match: Match[str]) -> str:
with open("redbot/__init__.py", "w", encoding="utf-8", newline="\n") as fp:
fp.write(new_contents)

print(f"::set-output name=new_version::{version_info}")
set_output("new_version", version_info)
35 changes: 35 additions & 0 deletions .github/workflows/scripts/compile_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
import shutil
import subprocess
import sys
from pathlib import Path


GITHUB_OUTPUT = os.environ["GITHUB_OUTPUT"]
REQUIREMENTS_FOLDER = Path(__file__).parents[3].absolute() / "requirements"
os.chdir(REQUIREMENTS_FOLDER)


def pip_compile(name: str) -> None:
subprocess.check_call(
(
sys.executable,
"-m",
"piptools",
"compile",
"--upgrade",
"--verbose",
f"{name}.in",
"--output-file",
f"{sys.platform}-{name}.txt",
)
)


pip_compile("base")
shutil.copyfile(f"{sys.platform}-base.txt", "base.txt")
for file in REQUIREMENTS_FOLDER.glob("extra-*.in"):
pip_compile(file.stem)

with open(GITHUB_OUTPUT, "a", encoding="utf-8") as fp:
fp.write(f"sys_platform={sys.platform}\n")
134 changes: 134 additions & 0 deletions .github/workflows/scripts/merge_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import os
from pathlib import Path
from typing import List, TextIO

from packaging.markers import Marker
from packaging.requirements import Requirement


REQUIREMENTS_FOLDER = Path(__file__).parents[3].absolute() / "requirements"
os.chdir(REQUIREMENTS_FOLDER)


class RequirementData:
def __init__(self, requirement_string: str) -> None:
self.req = Requirement(requirement_string)
self.comments = set()

@property
def name(self) -> str:
return self.req.name

@property
def marker(self) -> Marker:
return self.req.marker

@marker.setter
def marker(self, value: Marker) -> None:
self.req.marker = value


def get_requirements(fp: TextIO) -> List[RequirementData]:
requirements = []

current = None
for line in fp.read().splitlines():
annotation_prefix = " # "
if line.startswith(annotation_prefix) and current is not None:
source = line[len(annotation_prefix) :].strip()
if source == "via":
continue
via_prefix = "via "
if source.startswith(via_prefix):
source = source[len(via_prefix) :]
current.comments.add(source)
elif line and not line.startswith(("#", " ")):
current = RequirementData(line)
requirements.append(current)

return requirements


names = ["base"]
names.extend(file.stem for file in REQUIREMENTS_FOLDER.glob("extra-*.in"))
base_requirements = []

for name in names:
# {req_name: {sys_platform: RequirementData}
input_data = {}
all_platforms = set()
for file in REQUIREMENTS_FOLDER.glob(f"*-{name}.txt"):
platform_name = file.stem.split("-", maxsplit=1)[0]
all_platforms.add(platform_name)
with file.open(encoding="utf-8") as fp:
requirements = get_requirements(fp)

for req in requirements:
platforms = input_data.setdefault(req.name, {})
platforms[platform_name] = req

output = base_requirements if name == "base" else []
for req_name, platforms in input_data.items():
req = next(iter(platforms.values()))
for other_req in platforms.values():
if req.req != other_req.req:
raise RuntimeError(f"Incompatible requirements for {req_name}.")

req.comments.update(other_req.comments)

base_req = next(
(base_req for base_req in base_requirements if base_req.name == req.name), None
)
if base_req is not None:
old_base_marker = base_req.marker
old_req_marker = req.marker
req.marker = base_req.marker = None
if base_req.req != req.req:
raise RuntimeError(f"Incompatible requirements for {req_name}.")

base_req.marker = old_base_marker
req.marker = old_req_marker
if base_req.marker is None or base_req.marker == req.marker:
continue

if len(platforms) == len(all_platforms):
output.append(req)
continue
elif len(platforms) < len(all_platforms - platforms.keys()):
platform_marker = " or ".join(
f"sys_platform == '{platform}'" for platform in platforms
)
else:
platform_marker = " and ".join(
f"sys_platform != '{platform}'" for platform in all_platforms - platforms.keys()
)

new_marker = (
f"({req.marker}) and ({platform_marker})"
if req.marker is not None
else platform_marker
)
req.marker = Marker(new_marker)
if base_req is not None and base_req.marker == req.marker:
continue

output.append(req)

output.sort(key=lambda req: (req.marker is not None, req.name))
with open(f"{name}.txt", "w+", encoding="utf-8") as fp:
for req in output:
fp.write(str(req.req))
fp.write("\n")
comments = sorted(req.comments)

if len(comments) == 1:
source = comments[0]
fp.write(" # via ")
fp.write(source)
fp.write("\n")
else:
fp.write(" # via\n")
for source in comments:
fp.write(" # ")
fp.write(source)
fp.write("\n")
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
pip install 'tox<4'
- name: Tox test
env:
TOXENV: ${{ matrix.tox_env }}
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
pip install 'tox<4'
- name: Tox test
env:
TOXENV: postgres
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ python:
- method: pip
path: .
extra_requirements:
- docs
- doc
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
include LICENSE
recursive-include redbot *.LICENSE

# include requirements files
include requirements/base.in
include requirements/base.txt
include requirements/extra-*.in
include requirements/extra-*.txt

# include locale files
recursive-include redbot locales/*.po

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bumpdeps:
# Development environment
newenv:
$(PYTHON) -m venv --clear .venv
.venv/bin/pip install -U pip setuptools wheel
.venv/bin/pip install -U pip wheel
$(MAKE) syncenv
syncenv:
.venv/bin/pip install -Ur ./tools/dev-requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog_3_4_0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1580,5 +1580,5 @@ Miscellaneous
- Updated features list in ``[p]serverinfo`` with the latest changes from Discord (:issue:`4116`)
- Simple version of ``[p]serverinfo`` now shows info about more detailed ``[p]serverinfo 1`` (:issue:`4121`)
- ``[p]set nickname``, ``[p]set serverprefix``, ``[p]streamalert``, and ``[p]streamset`` commands now can be run by users with permissions related to the actions they're making (:issue:`4109`)
- `bordered()` now uses ``+`` for corners if keyword argument ``ascii_border`` is set to `True` (:issue:`4097`)
- ``bordered()`` now uses ``+`` for corners if keyword argument ``ascii_border`` is set to `True` (:issue:`4097`)
- Fixed timestamp storage in few places in Red (:issue:`4017`)
Loading