Skip to content

Commit

Permalink
Recursive fork (#106)
Browse files Browse the repository at this point in the history
* add recurse_fork script

* remove kurono badges submodule

* add devcontainer

* add setup script

* create run script

* move config command to folder

* fix relative paths and use python 3.12

* simplify forking

* simplify script

* Fix clone path

* setup git

* remove unnecessary escape

* simplify

* print before command
  • Loading branch information
SKairinos committed May 16, 2024
1 parent 937a60d commit c127001
Show file tree
Hide file tree
Showing 16 changed files with 507 additions and 29 deletions.
42 changes: 42 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"customizations": {
"vscode": {
"extensions": [
"visualstudioexptteam.vscodeintellicode",
"github.vscode-pull-request-github",
"redhat.vscode-yaml",
"davidanson.vscode-markdownlint",
"bierner.markdown-mermaid",
"streetsidesoftware.code-spell-checker",
"ms-python.python",
"ms-python.debugpy",
"ms-python.pylint",
"ms-python.isort",
"ms-python.vscode-pylance",
"ms-python.mypy-type-checker",
"ms-python.black-formatter",
"njpwerner.autodocstring",
"tamasfe.even-better-toml",
]
}
},
"dockerComposeFile": [
"./docker-compose.yml"
],
"features": {
"ghcr.io/devcontainers-contrib/features/pipenv:2": {
"version": "2023.11.15"
},
"ghcr.io/devcontainers/features/python:1": {
"installTools": false,
"version": "3.12"
},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"name": "workspace",
"postCreateCommand": ".submodules/recurse-fork/run",
"remoteUser": "root",
"service": "base-service",
"shutdownAction": "none",
"workspaceFolder": "/workspace"
}
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
[submodule "codeforlife-portal-react"]
path = codeforlife-portal-react
url = https://github.com/ocadotechnology/codeforlife-portal-react.git
[submodule "codeforlife-kurono-badges"]
path = codeforlife-kurono-badges
url = https://github.com/ocadotechnology/codeforlife-kurono-badges.git
[submodule "codeforlife-sso"]
path = codeforlife-sso
url = https://github.com/ocadotechnology/codeforlife-sso.git
File renamed without changes.
2 changes: 1 addition & 1 deletion .submodules/Pipfile → .submodules/config/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ mypy = "==1.6.1"
pylint = "==3.0.2"

[requires]
python_version = "3.11"
python_version = "3.12"
34 changes: 17 additions & 17 deletions .submodules/Pipfile.lock → .submodules/config/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .submodules/__main__.py → .submodules/config/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from configs import GlobalSubmoduleConfig, JsonDict, JsonValue, load_global_configs
from helpers import (
DOT_SUBMODULES_DIR,
CONFIG_DIR,
GIT_PUSH_CHANGES,
git_commit_and_push,
merge_json_dicts,
Expand Down Expand Up @@ -145,7 +145,7 @@ def main() -> None:
# Merge inherited configs and config into submodule in order.
for submodule in global_config.submodules:
# Change directory to submodule's directory.
os.chdir(f"{DOT_SUBMODULES_DIR}/../{submodule}")
os.chdir(f"{CONFIG_DIR}/../../{submodule}")

for inheritance in inheritances[key]:
merge_global_config(global_configs[inheritance])
Expand All @@ -154,7 +154,7 @@ def main() -> None:

if GIT_PUSH_CHANGES:
git_commit_and_push(message="Configured submodule [skip ci]")
os.chdir(f"{DOT_SUBMODULES_DIR}/..")
os.chdir(f"{CONFIG_DIR}/../..")
subprocess.run(["git", "add", submodule], check=True)

print("---")
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions .submodules/configs.py → .submodules/config/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from collections import Counter
from dataclasses import dataclass

from helpers import DOT_SUBMODULES_DIR, load_jsonc
from helpers import CONFIG_DIR, load_jsonc

# JSON type hints.
JsonList = t.List["JsonValue"]
Expand Down Expand Up @@ -61,7 +61,7 @@ class GlobalSubmoduleConfig:

def load_global_configs() -> t.Tuple[GlobalConfigDict, InheritanceDict]:
# Change directory to .submodules.
os.chdir(DOT_SUBMODULES_DIR)
os.chdir(CONFIG_DIR)

# Load the configs file.
with open("configs.jsonc", "r", encoding="utf-8") as configs_file:
Expand Down
5 changes: 3 additions & 2 deletions .submodules/helpers.py → .submodules/config/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import subprocess
import typing as t
from io import TextIOWrapper
from pathlib import Path

if t.TYPE_CHECKING:
from configs import AnyJsonValue, JsonDict, JsonList, JsonValue

# Path to the .submodules directory.
DOT_SUBMODULES_DIR = os.path.dirname(os.path.realpath(__file__))
# Path to the .submodules/config directory.
CONFIG_DIR = Path(__file__).resolve().parent
# Whether or not to git-push the changes.
GIT_PUSH_CHANGES = bool(int(os.getenv("GIT_PUSH_CHANGES", "0")))

Expand Down
8 changes: 8 additions & 0 deletions .submodules/config/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

cd "${BASH_SOURCE%/*}"

pipenv install --dev

pipenv run python .
Empty file.
17 changes: 17 additions & 0 deletions .submodules/recurse-fork/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
colorama = "==0.4.6"

[dev-packages]
black = "==23.1.0"
pytest = "==7.2.1"
mypy = "==1.6.1"
pylint = "==3.0.2"
types-colorama = "==0.4.15.20240311"

[requires]
python_version = "3.12"
Loading

0 comments on commit c127001

Please sign in to comment.