Skip to content

Commit

Permalink
feat: added detailed commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Sep 18, 2024
1 parent 882dee9 commit 9b180e7
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
75 changes: 75 additions & 0 deletions .github/compare
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3

import json
import sys


def load(filename):
file = open(filename)
data = {}
for ext in json.load(file):
if not "repo" in ext:
ext["repo"] = {}
data[ext["module"]] = ext
file.close()
return data


def keys(a, b):
return sorted(list(set(a.keys()) | set(b.keys())))


def compare(prev_registry, next_registry):
canceled_registrations = []
new_registrations = []
updated_registrations = []

for module, next in prev_registry.items():
if not module in next_registry:
canceled_registrations.append(module)

for module, next in next_registry.items():
if not module in prev_registry:
new_registrations.append(module)
continue
if next != prev_registry[module]:
updated_registrations.append((module, prev_registry[module], next))

if len(new_registrations) > 0:
print("new registrations")
print("-----------------")
for module in new_registrations:
print(" - %s" % module)
print()

if len(canceled_registrations) > 0:
print("canceled registrations")
print("----------------------")
for module in canceled_registrations:
print(" - %s" % module)
print()

if len(updated_registrations) > 0:
print("updated registrations")
print("---------------------")
for module, prev, next in updated_registrations:
print(" - %s" % module)
for key in keys(next, prev):
if prev[key] != next[key]:
print(" - %s" % key)
if key == "repo":
for rkey in keys(next["repo"], prev["repo"]):
if next["repo"][rkey] != prev["repo"][rkey]:
print(" - %s" % rkey)
print()


def main(argv):
if len(argv) != 2:
print("usage: compare <prev-file> <next-file>")
sys.exit(2)

compare(load(argv[0]), load(argv[1]))


main(sys.argv[1:])
9 changes: 8 additions & 1 deletion .github/workflows/extension-registry-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Preserve
run: |
mkdir build
cp -p registry.json build/
- name: Download
run: curl -sL -o registry.json https://registry.k6.io/registry.json

- name: Update
run: |
if ! git diff -s --exit-code registry.json; then
echo "Automatic update\n" > build/msg.txt
${{ github.workspace }}/.github/compare build/registry.json registry.json >> build/msg.txt
git config --local user.email 'wayback[bot]@users.noreply.github.com'
git config --local user.name 'wayback[bot]'
git add registry.json
git commit -a -m "Automatic update"
git commit -a -F build/msg.txt
git push
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build

0 comments on commit 9b180e7

Please sign in to comment.