Skip to content

Commit

Permalink
fix: readme fixed width; always run a few migrators (#140)
Browse files Browse the repository at this point in the history
* fix: use nbsp

* fix: only in entries, not headers

* fix: use in percents too

* fix: make sure nas work

* fix: try right justify

* fix: use reg for percent

* fix: try using backticks

* fix: bigger bar

* fix: try this

* use plain text here

* fix: these are never done

* fix: still need to make a commit

* always runs text

* fix: italic

* fix: use dash

* center it
  • Loading branch information
beckermr authored Nov 14, 2024
1 parent 6e9730c commit 0ef3045
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 15,948 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Items 1-3 are taken care of by the migrations code.

## Migration Progress

| migrator | progress | percent |
| -------------------- | ---------------------------------------- | ------- |
| CondaForgeYAMLTest | ## | 7% |
| RAutomerge | ##### | 14% |
| RotateFeedstockToken | ### | 9% |
| TeamsCleanup | n/a | n/a |
| migrator | progress | percent |
| -------------------- | ---------------------------------------------------- | :-----------------------: |
| CondaForgeYAMLTest | *always runs* | - |
| RAutomerge | *always runs* | - |
| RotateFeedstockToken | `#### ` | 9% (2214/23382) |
| TeamsCleanup | *always runs* | - |
22 changes: 13 additions & 9 deletions admin_migrations/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,30 +356,34 @@ def _render_readme():
mg_col_name = mg_col_name + " " * (mg_col_name_len - len(mg_col_name))

bar_name = "progress"
bar_seg = 40
bar_seg = 50
bar_len = bar_seg
bar_name = bar_name + " " * (bar_len - len(bar_name))
table = f"| {mg_col_name} | {bar_name} | percent |\n"
table += f"| {'-' * mg_col_name_len} | {'-' * bar_len} | ------- |\n"
bar_name = bar_name + " " * (bar_len - len(bar_name) + 2)
pname = "percent" + " " * 18
table = f"| {mg_col_name} | {bar_name} | {pname} |\n"
table += f"| {'-' * mg_col_name_len} | {'-' * (bar_len+2)} | :{'-' * 23}: |\n"

always_runs = "*always runs*"
for m in sorted(MIGRATORS, key=lambda x: x.__class__.__name__):
name = m.__class__.__name__
done = len(m._done_table)
frac = done / total
if frac > 1:
frac = 1
percent = f"{int(frac * 100):-3d}%"
percent = f"{int(frac * 100):-3d}%" + f" ({done}/{total})"

progress = int(frac * bar_seg)
if name in ["TeamsCleanup"]:
if name in ["TeamsCleanup", "CondaForgeYAMLTest", "RAutomerge"]:
table += (
f"| {name}{' ' * (mg_col_name_len - len(name))} "
f"| n/a{' ' * (bar_len - 3)} | n/a |\n"
f"| {always_runs}{' ' * (bar_len - len(always_runs) + 2)} | "
f"{' ' * 24}- |\n"
)
else:
table += (
f"| {name}{' ' * (mg_col_name_len - len(name))} "
f"| {'#' * progress}{' ' * (bar_seg - progress)} | "
f" {percent} |\n"
f"| `{'#' * progress}{' ' * (bar_seg - progress)}` | "
f"{' ' * (25 - len(percent))}{percent} |\n"
)

with open("README.md.template") as fp:
Expand Down
10 changes: 7 additions & 3 deletions admin_migrations/migrators/automerge_and_botrerun_labels.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import functools
import os

import github

from .base import Migrator

GH = github.Github(os.environ["GITHUB_TOKEN"])

BOT_RERUN = (
"bot-rerun",
"191970",
Expand All @@ -19,12 +18,17 @@
)


@functools.lru_cache(maxsize=1)
def _gh():
return github.Github(os.environ["GITHUB_TOKEN"])


class AutomergeAndBotRerunLabels(Migrator):
main_branch_only = True

def migrate(self, feedstock, branch):
try:
repo = GH.get_repo("conda-forge/%s-feedstock" % feedstock)
repo = _gh().get_repo("conda-forge/%s-feedstock" % feedstock)
if repo.archived:
return True, False, True

Expand Down
7 changes: 5 additions & 2 deletions admin_migrations/migrators/branch_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

from .base import Migrator

GH = github.Github(os.environ["GITHUB_TOKEN"])

@functools.lru_cache(maxsize=1)
def _gh():
return github.Github(os.environ["GITHUB_TOKEN"])


@functools.lru_cache(maxsize=1)
def get_org():
return GH.get_organization("conda-forge")
return _gh().get_organization("conda-forge")


def _add_branch_protection_ruleset(gh_repo):
Expand Down
4 changes: 3 additions & 1 deletion admin_migrations/migrators/conda_forge_yml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ def migrate(self, feedstock, branch):
)

# did migration, make a commit, no api calls
return True, True, False
# return True, True, False
# this migrator is never done
return False, True, False
8 changes: 6 additions & 2 deletions admin_migrations/migrators/dot_conda.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import os
import subprocess

Expand All @@ -6,7 +7,10 @@

from .base import Migrator

GH = github.Github(os.environ["GITHUB_TOKEN"])

@functools.lru_cache(maxsize=1)
def _gh():
return github.Github(os.environ["GITHUB_TOKEN"])


def _read_conda_forge_yaml(yaml):
Expand All @@ -33,7 +37,7 @@ def _read_conda_forge_yaml(yaml):

class DotConda(Migrator):
def migrate(self, feedstock, branch):
repo = GH.get_repo("conda-forge/%s-feedstock" % feedstock)
repo = _gh().get_repo("conda-forge/%s-feedstock" % feedstock)
if repo.archived:
# migration done, make a commit, lots of API calls
return True, False, False
Expand Down
10 changes: 7 additions & 3 deletions admin_migrations/migrators/main_default_branch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import os
import subprocess
import time
Expand All @@ -9,8 +10,6 @@

from .base import Migrator

GH = github.Github(os.environ["GITHUB_TOKEN"])

CIRCLECI_BLANK = """
# This file was generated automatically from conda-smithy. To update this configuration,
# update the conda-forge.yml and/or the recipe/meta.yaml.
Expand Down Expand Up @@ -116,6 +115,11 @@
"""


@functools.lru_cache(maxsize=1)
def _gh():
return github.Github(os.environ["GITHUB_TOKEN"])


def _run_git_command(args, check=True):
s = subprocess.run(
["git"] + args,
Expand Down Expand Up @@ -317,7 +321,7 @@ def _master_to_main(repo):

class CondaForgeMasterToMain(Migrator):
def migrate(self, feedstock, branch):
repo = GH.get_repo("conda-forge/%s-feedstock" % feedstock)
repo = _gh().get_repo("conda-forge/%s-feedstock" % feedstock)
if repo.archived:
# migration done, make a commit, lots of API calls
return True, False, False
Expand Down
8 changes: 6 additions & 2 deletions admin_migrations/migrators/r_automerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def migrate(self, feedstock, branch):
cfg["bot"]["automerge"],
flush=True,
)
return True, False, False
# return True, False, False
# this migrator is never done
return False, False, False

cfg["bot"] = {"automerge": True}

Expand All @@ -189,7 +191,9 @@ def migrate(self, feedstock, branch):
)

# did migration, make a commit, no api calls
return True, True, False
# return True, True, False
# this migrator is never done
return False, True, False
else:
# no migration, no commit needs to be made, no api calls
return False, False, False
7 changes: 5 additions & 2 deletions admin_migrations/migrators/remove_automerge_and_rerender.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

from .base import Migrator

GH = github.Github(os.environ["GITHUB_TOKEN"])

@functools.lru_cache(maxsize=1)
def _gh():
return github.Github(os.environ["GITHUB_TOKEN"])


@functools.lru_cache(maxsize=1)
def get_org():
return GH.get_organization("conda-forge")
return _gh().get_organization("conda-forge")


class RemoveAutomergeAndRerender(Migrator):
Expand Down
Loading

0 comments on commit 0ef3045

Please sign in to comment.