CI: Update CI workflows to use Citron-specific naming and paths

This commit is contained in:
Zephyron 2025-04-30 16:50:39 +10:00
parent 257aad2431
commit eec0f34204
65 changed files with 2596 additions and 10 deletions

View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2019 citron Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# Apply patches that are tagged with a specific label
# Current labels include:
# "canary merge benefit"
import os
import sys
org = os.getenv("PRIVATEMERGEORG", "Citron-Project")
base = os.getenv("PRIVATEMERGEBASE", "Cit")
head = os.getenv("PRIVATEMERGEBASE", "Cit-canary")
# We use different files for the 3 PR checkers.
check_label_presence_file = ".ci/scripts/merge/check-label-presence.py"
check_reviews_file = ".ci/scripts/merge/check-reviews-private.py"
# python3 python_file org repo pr# label
os.system(f"python3 .ci/scripts/merge/apply-patches-by-label.py {sys.argv[1]} {org} {base} {head} {check_label_presence_file} {check_reviews_file}")

View file

@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2019 citron Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# Apply patches that are tagged with a specific label
# Current labels include:
# "canary merge benefit"
import json
import os
import sys
import subprocess
import re
from urllib import request
def get_pull_request_list(page=1):
url = f"https://api.github.com/repos/Citron-Project/Cit/pulls?page={page}"
headers = {'Accept': 'application/vnd.github.v3+json'}
token = os.environ.get('EARLY_ACCESS_TOKEN')
if token:
headers['Authorization'] = f'token {token}'
req = request.Request(url, headers=headers)
response = request.urlopen(req)
result = json.loads(response.read().decode('utf-8'))
if len(result) > 0:
return result + get_pull_request_list(page + 1)
return []
seen = {}
for pr in get_pull_request_list():
pn = pr['number']
if pn in seen:
continue
seen[pn] = True
print(subprocess.check_output(["git", "fetch", "https://github.com/Citron-Project/Cit.git", f"pull/{pn}/head:pr-{pn}", "-f", "--no-recurse-submodules"]))
out = subprocess.check_output(["python3", ".ci/scripts/merge/check-label-presence.py", str(pn), sys.argv[1]])
if b'true' in out:
print(f'Applying PR #{pn} matching label {sys.argv[1]}...')
try:
if b'changes requested' in subprocess.check_output(["python3", ".ci/scripts/merge/check-reviews.py", str(pn)]):
print(f'PR #{pn} has requested changes, skipping')
continue
else:
print(f'PR #{pn} has approving reviews, applying')
except:
print('Could not find any valid reviews, applying anyway')
try:
print(subprocess.check_output(["git", "merge", "--squash", f"pr-{pn}", "-m", f"Merge PR #{pn} tagged with: {sys.argv[1]}"]))
except:
print("Failed to merge cleanly, are there conflicts?")
exit(0)
# Apply a tag to the EA release
try:
print(subprocess.check_output(["git", "tag", "-f", f"canary/{sys.argv[1]}"]))
except:
print("Failed to apply canary tag")
exit(0)

View file

@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2019 citron Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# Check if a pull request has a specific label
# Usage: python3 check-label-presence.py <PR Number> <Label Text>
import json, sys
from urllib import request
import os
url = 'https://api.github.com/repos/Citron-Project/Cit/issues/%s' % sys.argv[1]
headers = {'Accept': 'application/vnd.github.v3+json'}
token = os.environ.get('EARLY_ACCESS_TOKEN')
if token:
headers['Authorization'] = f'token {token}'
req = request.Request(url, headers=headers)
try:
response = request.urlopen(req)
j = json.loads(response.read().decode('utf-8'))
for label in j['labels']:
if label['name'] == sys.argv[2]:
print('true')
sys.exit(0)
except Exception as e:
print(f'Error: {e}')
print('false')
sys.exit(1)

View file

@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2019 citron Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
git config --global user.email "zephyron@citron-emu.org"
git config --global user.name "Zephyron"