-
-
Notifications
You must be signed in to change notification settings - Fork 215
feat: add older versions of the wrappers extension
#1748
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
Open
yvan-sraka
wants to merge
16
commits into
custom-github-runners
Choose a base branch
from
multi-version-ext/wrappers-v0.2.0
base: custom-github-runners
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67,276
−32
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bfbc8b4
feat: add an utility script to generate nix/ext/versions.json
yvan-sraka 75f050d
feat(wrappers): move patch(s) and lock file of every version into its…
yvan-sraka c449282
feat(wrappers): temporarily remove some versions to please the CI
yvan-sraka 4f2067d
feat(wrappers): add versions 0.5.4 and 0.5.5
yvan-sraka 16c3dd9
feat(wrappers): add versions 0.5.2 and 0.5.3
yvan-sraka fad1dab
feat(wrappers): add versions 0.5.0 and 0.5.1
yvan-sraka d1d99b5
feat(wrappers): add versions 0.4.5 and 0.4.6
yvan-sraka 4fa2f3c
feat(wrappers): add versions 0.4.3 and 0.4.4
yvan-sraka 4d31ff1
feat(wrappers): add versions 0.4.1 and 0.4.2
yvan-sraka a15ecc1
feat(wrappers): add versions 0.2.0 and 0.3.0
yvan-sraka ef7c0f8
feat(wrappers): add versions 0.1.18 and 0.1.19
yvan-sraka 3c63bdb
feat(wrappers): add versions 0.1.16 and 0.1.17
yvan-sraka 711f9ef
feat(wrappers): add versions 0.1.14 and 0.1.15
yvan-sraka e49151b
feat(wrappers): add versions 0.1.11 and 0.1.12
yvan-sraka 45df1e1
feat(wrappers): add versions 0.1.9 and 0.1.10
yvan-sraka 22449cb
feat(wrappers): add versions 0.1.7 and 0.1.8
yvan-sraka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #! /usr/bin/env nix-shell | ||
| #! nix-shell -i python3 -p python3 git nix-prefetch-git python3Packages.packaging | ||
|
|
||
yvan-sraka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import subprocess | ||
| import json | ||
| import argparse | ||
| from pathlib import Path | ||
| from typing import Dict, List, Union | ||
| from packaging.version import parse as parse_version, InvalidVersion | ||
|
|
||
| Schema = Dict[str, Dict[str, Dict[str, Union[List[str], str, bool]]]] | ||
|
|
||
| POSTGRES_VERSIONS: List[str] = ["15", "17"] | ||
| VERSIONS_JSON_PATH = "versions.json" | ||
|
|
||
|
|
||
| def run(cmd: List[str]) -> str: | ||
| result = subprocess.run(cmd, capture_output=True, text=True, check=True) | ||
| return result.stdout.strip() | ||
|
|
||
|
|
||
| def get_tags(url: str) -> Dict[str, str]: | ||
| output = run(["git", "ls-remote", "--tags", url]) | ||
| tags: Dict[str, str] = {} | ||
| for line in output.splitlines(): | ||
| if "^{}" not in line: | ||
| parts = line.split("\t") | ||
| if len(parts) == 2: | ||
| commit_hash, ref = parts | ||
| if ref.startswith("refs/tags/"): | ||
| tag = ref.removeprefix("refs/tags/") | ||
| try: | ||
| parse_version(tag) | ||
| except InvalidVersion: | ||
| continue | ||
| tags[tag] = commit_hash | ||
| return tags | ||
|
|
||
|
|
||
| def get_sri_hash(url: str, commit_hash: str) -> str: | ||
| output = run(["nix-prefetch-git", "--quiet", "--url", url, "--rev", commit_hash]) | ||
| nix_hash = json.loads(output)["sha256"] | ||
| return "sha256-" + run(["nix", "hash", "to-base64", "--type", "sha256", nix_hash]) | ||
|
|
||
|
|
||
| def load() -> Schema: | ||
| if not Path(VERSIONS_JSON_PATH).exists(): | ||
| return {} | ||
| with open(VERSIONS_JSON_PATH, "r", encoding="utf-8") as f: | ||
| return json.load(f) | ||
|
|
||
|
|
||
| def build(name: str, url: str, data: Schema, ignore: bool = False) -> Schema: | ||
| tags = get_tags(url) | ||
| versions = data.get(name, {}) | ||
| for tag, commit_hash in tags.items(): | ||
| if tag in versions: | ||
| continue | ||
| if ignore: | ||
| versions[tag] = {"ignore": True} | ||
| else: | ||
| sri_hash = get_sri_hash(url, commit_hash) | ||
| versions[tag] = {"postgresql": POSTGRES_VERSIONS, "hash": sri_hash} | ||
| data[name] = versions | ||
| return data | ||
|
|
||
|
|
||
| def save(data: Schema) -> None: | ||
| sorted_data = {} | ||
| for name, versions in data.items(): | ||
| sorted_data[name] = dict( | ||
| sorted(versions.items(), key=lambda item: parse_version(item[0])) | ||
| ) | ||
| with open(VERSIONS_JSON_PATH, "w", encoding="utf-8") as f: | ||
| json.dump(sorted_data, f, indent=2) | ||
| f.write("\n") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("extension_name") | ||
| parser.add_argument("git_repo_url") | ||
| parser.add_argument("--ignore", action="store_true") | ||
| args = parser.parse_args() | ||
|
|
||
| save(build(args.extension_name, args.git_repo_url, load(), ignore=args.ignore)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.