Skip to content

Commit 439f88c

Browse files
authored
Merge pull request #2 from vcmi/develop
Update branch
2 parents ef8fda3 + 6e8df03 commit 439f88c

File tree

6 files changed

+360
-245
lines changed

6 files changed

+360
-245
lines changed

.github/validate_json.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import json
1+
import jstyleson
22
import glob
33
import os
44
import sys
5-
import urllib.request
65

76
from ignore_json import ignore
87

@@ -11,14 +10,16 @@
1110
for filename in glob.glob(os.path.join('.', '*.json')):
1211
if filename not in ignore:
1312
print(f"Opening: {filename}")
14-
filecontent = open(filename, "r").read()
13+
14+
with open(filename, "r") as file:
15+
filecontent = file.read()
1516

1617
try:
17-
json.loads(filecontent)
18+
jstyleson.loads(filecontent)
1819
print(f"✅ JSON valid")
1920
except Exception as err:
2021
error = True
21-
print(f"❌ JSON invalid:")
22+
print(f"❌ JSON invalid in {filename}:")
2223
print(str(err))
2324

2425
if error:

.github/validate_mod_json.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import json
1+
import jstyleson
22
import glob
33
import os
44
import sys
55
import urllib.request
6+
from io import StringIO
67

78
from ignore_json import ignore
89

@@ -11,28 +12,39 @@
1112
for filename in glob.glob(os.path.join('.', '*.json')):
1213
if filename not in ignore:
1314
print(f"Opening: {filename}")
14-
filecontent = open(filename, "r").read()
15-
modlist = json.loads(filecontent)
15+
16+
with open(filename, "r") as file:
17+
filecontent = file.read()
18+
19+
try:
20+
modlist = jstyleson.loads(filecontent)
21+
except Exception as err:
22+
error = True
23+
print(f"❌ Error reading JSON file {filename}: {err}")
24+
continue
25+
1626
for mod, data in modlist.items():
1727
url = data["mod"].replace(" ", "%20")
1828
print(f"{mod}: {url}")
29+
1930
try:
2031
response = urllib.request.urlopen(url)
2132
print(f"✅ Download successful")
22-
except:
33+
except Exception as err:
2334
error = True
24-
print("❌ Download failed")
35+
print(f"❌ Download failed: {err}")
2536
continue
26-
filecontent = response.read()
27-
37+
2838
try:
29-
json.loads(filecontent)
39+
filecontent = response.read().decode("utf-8")
40+
jstyleson.load(StringIO(filecontent))
3041
print(f"✅ JSON valid")
3142
except Exception as err:
3243
error = True
3344
print(f"❌ JSON invalid:")
3445
print(str(err))
3546
continue
47+
3648
if error:
3749
sys.exit(os.EX_SOFTWARE)
3850
else:

.github/workflows/main.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,66 @@ on:
1313

1414
jobs:
1515
validate_json:
16+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
1617
runs-on: ubuntu-latest
1718
defaults:
1819
run:
1920
shell: bash
2021
steps:
2122
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
- name: Set up Python environment
26+
run: sudo apt update && sudo apt install -y python3 python3-pip
27+
- name: Install jstyleson
28+
run: pip3 install jstyleson
2229
- name: Validate json
23-
run: |
24-
python3 .github/validate_json.py
30+
run: python3 .github/validate_json.py
31+
2532
validate_mod_json:
33+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
2634
needs: validate_json
2735
runs-on: ubuntu-latest
2836
defaults:
2937
run:
3038
shell: bash
3139
steps:
3240
- uses: actions/checkout@v3
41+
- name: Install jstyleson
42+
run: pip3 install jstyleson
3343
- name: Validate mod json
34-
run: |
35-
python3 .github/validate_mod_json.py
44+
run: python3 .github/validate_mod_json.py
45+
3646
update_size:
37-
needs: validate_json
47+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
3848
runs-on: ubuntu-latest
3949
defaults:
4050
run:
4151
shell: bash
4252
steps:
4353
- uses: actions/checkout@v3
54+
with:
55+
fetch-depth: 0
56+
- name: Install jstyleson
57+
run: pip3 install jstyleson
58+
4459
- name: Update size
60+
run: python3 .github/update_size.py
61+
62+
- name: Determine branch and switch
63+
id: branch_info
4564
run: |
46-
python3 .github/update_size.py
47-
- name: Commit changes
65+
branch_name=$(git symbolic-ref --short HEAD)
66+
echo "branch_name=$branch_name" >> $GITHUB_ENV
67+
echo "Checked out branch: $branch_name"
68+
69+
- name: Set upstream for branch
70+
run: git push --set-upstream origin $branch_name
71+
72+
- name: Commit changes to the correct branch
4873
uses: EndBug/add-and-commit@v9
4974
with:
5075
default_author: github_actions
5176
message: Update sizes
5277
add: '*.json'
78+
push: --force

vcmi-1.4-archive.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@
4343
"golemcraft" : {
4444
"mod" : "https://raw.githubusercontent.com/misiokles/golemcraft/vcmi-1.4/golemcraft/mod.json",
4545
"download" : "https://github.com/misiokles/golemcraft/archive/refs/heads/vcmi-1.4.zip",
46-
"downloadSize" : 0.073
47-
},
48-
"ballista-bank" : {
49-
"mod" : "https://raw.githubusercontent.com/misiokles/ballista-bank/vcmi-1.4/ballista-bank/mod.json",
50-
"download" : "https://github.com/misiokles/ballista-bank/archive/refs/heads/vcmi-1.4.zip",
51-
"downloadSize" : 0.164
46+
"downloadSize" : 0.075
5247
},
5348
"slothlux-town" : {
5449
"mod" : "https://raw.githubusercontent.com/misiokles/slothlux-town/vcmi-1.4/slothlux-town/mod.json",
@@ -68,18 +63,13 @@
6863
"h4-arts-hero" : {
6964
"mod" : "https://raw.githubusercontent.com/misiokles/h4-arts-hero/vcmi-1.4/h4-arts-hero/mod.json",
7065
"download" : "https://github.com/misiokles/h4-arts-hero/archive/refs/heads/vcmi-1.4.zip",
71-
"downloadSize" : 0.203
66+
"downloadSize" : 0.206
7267
},
7368
"h2-artifacts" : {
7469
"mod" : "https://raw.githubusercontent.com/misiokles/h2-artifacts/vcmi-1.4/h2-artifacts/mod.json",
7570
"download" : "https://github.com/misiokles/h2-artifacts/archive/refs/heads/vcmi-1.4.zip",
7671
"downloadSize" : 0.173
7772
},
78-
"abaddon-column" : {
79-
"mod" : "https://raw.githubusercontent.com/misiokles/abaddon-column/vcmi-1.4/abaddon-column/mod.json",
80-
"download" : "https://github.com/misiokles/abaddon-column/archive/refs/heads/vcmi-1.4.zip",
81-
"downloadSize" : 0.033
82-
},
8373
"alpha-mod" : {
8474
"mod" : "https://raw.githubusercontent.com/misiokles/alpha-mod/vcmi-1.4/alpha-mod/mod.json",
8575
"download" : "https://github.com/misiokles/alpha-mod/archive/refs/heads/vcmi-1.4.zip",
@@ -145,7 +135,7 @@
145135
"https://raw.githubusercontent.com/misiokles/fiorin-heroes/vcmi-1.5/screenshots/screen2.png",
146136
"https://raw.githubusercontent.com/misiokles/fiorin-heroes/vcmi-1.5/screenshots/screen3.png"
147137
],
148-
"downloadSize" : 2.521
138+
"downloadSize" : 2.525
149139
},
150140
"plane-of-earth-town" : {
151141
"mod" : "https://raw.githubusercontent.com/misiokles/plane-of-earth-town/vcmi-1.5/plane-of-earth-town/mod.json",
@@ -156,7 +146,7 @@
156146
"https://raw.githubusercontent.com/misiokles/plane-of-earth-town/vcmi-1.5/screenshots/screen3.png",
157147
"https://raw.githubusercontent.com/misiokles/plane-of-earth-town/vcmi-1.5/screenshots/screen4.png"
158148
],
159-
"downloadSize" : 14.412
149+
"downloadSize" : 14.417
160150
},
161151
"might-town" : {
162152
"mod" : "https://raw.githubusercontent.com/misiokles/might-town/vcmi-1.5/might-town/mod.json",
@@ -167,7 +157,7 @@
167157
"https://raw.githubusercontent.com/misiokles/might-town/vcmi-1.5/screenshots/screen3.png",
168158
"https://raw.githubusercontent.com/misiokles/might-town/vcmi-1.5/screenshots/screen4.png"
169159
],
170-
"downloadSize" : 16.609
160+
"downloadSize" : 16.616
171161
},
172162
"covenant-town" : {
173163
"mod" : "https://raw.githubusercontent.com/misiokles/covenant-town/vcmi-1.5/covenant-town/mod.json",
@@ -247,5 +237,15 @@
247237
"https://raw.githubusercontent.com/misiokles/abode-town/vcmi-1.5/screenshots/screen3.png"
248238
],
249239
"downloadSize" : 21.218
240+
},
241+
"kremlin-town" : {
242+
"mod" : "https://raw.githubusercontent.com/misiokles/kremlin-town/vcmi-1.5/kremlin-town/mod.json",
243+
"download" : "https://github.com/misiokles/kremlin-town/archive/refs/heads/vcmi-1.5.zip",
244+
"downloadSize" : 16.382
245+
},
246+
"pah3-singleplayer-tournament" : {
247+
"mod" : "https://raw.githubusercontent.com/vcmi-mods/pah3-singleplayer-tournament/vcmi-1.6/pah3-singleplayer-tournament/mod.json",
248+
"download" : "https://github.com/vcmi-mods/pah3-singleplayer-tournament/archive/refs/heads/vcmi-1.6.zip",
249+
"downloadSize" : 10.305
250250
}
251251
}

vcmi-1.5.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"https://raw.githubusercontent.com/vcmi-mods/horn-of-the-abyss/vcmi-1.4/screenshots/08.png",
1919
"https://raw.githubusercontent.com/vcmi-mods/horn-of-the-abyss/vcmi-1.4/screenshots/09.png"
2020
],
21-
"downloadSize" : 109.688
21+
"downloadSize" : 109.689
2222
},
2323
"wake-of-gods" : {
2424
"mod" : "https://raw.githubusercontent.com/vcmi-mods/wake-of-gods/vcmi-1.5/mod.json",
@@ -150,7 +150,7 @@
150150
"swedish-translation" : {
151151
"mod" : "https://raw.githubusercontent.com/vcmi-mods/swedish-translation/vcmi-1.4/swedish-translation/mod.json",
152152
"download" : "https://github.com/vcmi-mods/swedish-translation/archive/refs/heads/vcmi-1.4.zip",
153-
"downloadSize" : 0.399
153+
"downloadSize" : 0.402
154154
},
155155
"turkish-translation" : {
156156
"mod" : "https://raw.githubusercontent.com/vcmi-mods/turkish-translation/vcmi-1.4/turkish-translation/mod.json",
@@ -427,7 +427,7 @@
427427
"https://raw.githubusercontent.com/vcmi-mods/portraits-packs/main/screenshots/screen3.png",
428428
"https://raw.githubusercontent.com/vcmi-mods/portraits-packs/main/screenshots/screen4.png"
429429
],
430-
"downloadSize" : 18.422
430+
"downloadSize" : 18.48
431431
},
432432
"heroes-iii-orchestra" : {
433433
"mod" : "https://raw.githubusercontent.com/vcmi-mods/heroes-iii-orchestra/vcmi-1.4/Heroes%20III%20Orchestra/mod.json",
@@ -447,7 +447,7 @@
447447
"https://raw.githubusercontent.com/vcmi-mods/mega-pack-rus/vcmi-1.4/screenshots/sc-6.png",
448448
"https://raw.githubusercontent.com/vcmi-mods/mega-pack-rus/vcmi-1.4/screenshots/sc-7.png"
449449
],
450-
"downloadSize" : 38.764
450+
"downloadSize" : 38.779
451451
},
452452
"new-interface-mod" : {
453453
"mod" : "https://raw.githubusercontent.com/vcmi-mods/new-interface-mod/vcmi-1.4/New%20Interface%20Mod/mod.json",
@@ -461,7 +461,7 @@
461461
"https://raw.githubusercontent.com/vcmi-mods/new-interface-mod/vcmi-1.4/screenshots/screen6.png",
462462
"https://raw.githubusercontent.com/vcmi-mods/new-interface-mod/vcmi-1.4/screenshots/screen7.png"
463463
],
464-
"downloadSize" : 46.551
464+
"downloadSize" : 46.53
465465
},
466466
"hi-rez-menu" : {
467467
"mod" : "https://raw.githubusercontent.com/vcmi-mods/hi-rez-menu/vcmi-1.4/new-menu/mod.json",
@@ -559,7 +559,7 @@
559559
"an-expansion" : {
560560
"mod" : "https://raw.githubusercontent.com/vdhan/an-expansion/master/mod.json",
561561
"download" : "https://github.com/vdhan/an-expansion/archive/refs/heads/master.zip",
562-
"downloadSize" : 6.722
562+
"downloadSize" : 6.774
563563
},
564564
"refugee-town" : {
565565
"mod" : "https://raw.githubusercontent.com/vcmi-mods/refugee-town/vcmi-1.4/refugee-town/mod.json",
@@ -625,7 +625,7 @@
625625
"warzyw-templates" : {
626626
"mod" : "https://raw.githubusercontent.com/vcmi-mods/warzyw-templates/vcmi-1.4/warzyw-templates/mod.json",
627627
"download" : "https://github.com/vcmi-mods/warzyw-templates/archive/refs/heads/vcmi-1.4.zip",
628-
"downloadSize" : 0.122
628+
"downloadSize" : 0.127
629629
},
630630
"wyrmsun-boats" : {
631631
"mod" : "https://raw.githubusercontent.com/vcmi-mods/wyrmsun-boats/vcmi-1.4/wyrmsun-boats/mod.json",
@@ -708,7 +708,7 @@
708708
"https://raw.githubusercontent.com/vcmi-mods/test-map-spells-mod/vcmi-1.3/screenshots/screen02.png",
709709
"https://raw.githubusercontent.com/vcmi-mods/test-map-spells-mod/vcmi-1.3/screenshots/screen03.png"
710710
],
711-
"downloadSize" : 2.119
711+
"downloadSize" : 2.12
712712
},
713713
"third-upgrades" : {
714714
"mod" : "https://raw.githubusercontent.com/vcmi-mods/third-upgrades/vcmi-1.5/third-upgrades/mod.json",
@@ -913,7 +913,7 @@
913913
"https://raw.githubusercontent.com/vcmi-mods/factory-creatures/vcmi-1.5/screenshots/screen3.png",
914914
"https://raw.githubusercontent.com/vcmi-mods/factory-creatures/vcmi-1.5/screenshots/screen4.png"
915915
],
916-
"downloadSize" : 38.216
916+
"downloadSize" : 38.259
917917
},
918918
"luk3Z-templates-pack" : {
919919
"mod" : "https://raw.githubusercontent.com/vcmi-mods/luk3Z-templates-pack/vcmi-1.5/luk3Z-templates-pack/mod.json",

0 commit comments

Comments
 (0)