Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions .github/scripts/test_release_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ def validate(self, minecraft, names=None, mutation=None, release_exists=False, w
'1.19.4': ('119041', 'master-1.19.4', '45.4.5'),
'1.20.1': ('120011', 'master-1.20.1', '47.4.28'),
'1.20.6': ('120061', 'master-1.20.6', '50.2.14'),
'1.21.1': ('121011', 'master-1.21.1', '52.1.20')}[minecraft]
'1.21.1': ('121011', 'master-1.21.1', '52.1.20'),
'1.21.11': ('121111', 'master-1.21.11', '61.2.4')}[minecraft]
version = '2.4.2.' + suffix
files={name:'C'*64 for name in ['main.jar','sources.jar','javadoc.jar','release.pom','CHANGELOG.txt','SHA256SUMS']}
receipt={'schema':1,'source':SHA,'version':version,'files':files,'evidence_sha256':'F'*64,'qualified_locally':True,'manual_accepted':True}
if local_receipt is not None:receipt=local_receipt
values = dict(minecraft_version=minecraft, forge_version=forge, loader_name='forge', loader_code='1',
java_version='21' if minecraft in ('1.20.6','1.21.1') else '17' if minecraft in ('1.18.2','1.19.4','1.20.1') else '16' if minecraft=='1.17.1' else '8', java_toolchain_version='21.0.7+6' if minecraft in ('1.20.6','1.21.1') else '17.0.20.1+1' if minecraft in ('1.18.2','1.19.4','1.20.1') else '16.0.2+7' if minecraft=='1.17.1' else '8.0.502+7', gradle_java_version='21' if minecraft in ('1.20.6','1.21.1') else '17', mod_id='lootablebodies',
java_version='21' if minecraft in ('1.20.6','1.21.1','1.21.11') else '17' if minecraft in ('1.18.2','1.19.4','1.20.1') else '16' if minecraft=='1.17.1' else '8', java_toolchain_version='21.0.7+6' if minecraft in ('1.20.6','1.21.1','1.21.11') else '17.0.20.1+1' if minecraft in ('1.18.2','1.19.4','1.20.1') else '16.0.2+7' if minecraft=='1.17.1' else '8.0.502+7', gradle_java_version='21' if minecraft in ('1.20.6','1.21.1','1.21.11') else '17', mod_id='lootablebodies',
mod_artifact='LootableBodies', mod_group='zone.moddev.mc.lootablebodies', mod_license='LGPL-2.1-only',
curseforge_project_id='240968', mod_version=version)
if mutation:
Expand All @@ -89,13 +90,13 @@ def validate(self, minecraft, names=None, mutation=None, release_exists=False, w
'1.14.4': MATRIX114 + ['Validate release workflow'],
'1.15.2': MATRIX115, '1.16.5': MATRIX116}.get(minecraft, []) if names is None else names
if minecraft=='1.17.1' and names is None:checks=CORE117+MATRIX117
if minecraft in ('1.18.2','1.19.4','1.20.1','1.20.6','1.21.1') and names is None:checks=CORE118
if minecraft in ('1.18.2','1.19.4','1.20.1','1.20.6','1.21.1','1.21.11') and names is None:checks=CORE118

def command(args, **options):
if args[0] == 'git':
return SHA + '\n'
if any('/actions/workflows/native'+code+'.yml/' in args[-1] for code in ['117','118','119','120']):
code={'1.17.1':'117','1.18.2':'118','1.19.4':'119','1.20.1':'120','1.20.6':'120','1.21.1':'120'}[minecraft]
code={'1.17.1':'117','1.18.2':'118','1.19.4':'119','1.20.1':'120','1.20.6':'120','1.21.1':'120','1.21.11':'120'}[minecraft]
row=dict(id=int(code),head_sha=SHA,head_branch=branch,event='push',path='.github/workflows/native'+code+'.yml',conclusion='success')
if qualification:row.update(qualification)
return json.dumps({'workflow_runs':[row]})
Expand Down Expand Up @@ -134,8 +135,8 @@ def test_1206_requires_exact_archives_and_java_21(self):
{'local_receipt': {'manual_accepted': False}}):
with self.subTest(options=options), self.assertRaises(SystemExit):
self.validate('1.20.6', **options)
self.assertIn("(needs.preflight.outputs.minecraft_version == '1.20.6' || needs.preflight.outputs.minecraft_version == '1.21.1') && 'Java 21'", WORKFLOW.read_text())
self.assertEqual(2, WORKFLOW.read_text().count("(needs.preflight.outputs.minecraft_version == '1.20.6' || needs.preflight.outputs.minecraft_version == '1.21.1') && '21.0.7+6.0.LTS'"))
self.assertIn("(needs.preflight.outputs.minecraft_version == '1.20.6' || needs.preflight.outputs.minecraft_version == '1.21.1' || needs.preflight.outputs.minecraft_version == '1.21.11') && 'Java 21'", WORKFLOW.read_text())
self.assertEqual(2, WORKFLOW.read_text().count("(needs.preflight.outputs.minecraft_version == '1.20.6' || needs.preflight.outputs.minecraft_version == '1.21.1' || needs.preflight.outputs.minecraft_version == '1.21.11') && '21.0.7+6.0.LTS'"))

def test_1211_requires_exact_archives_and_java_21(self):
code, values = self.select('2.4.13.121011')
Expand Down Expand Up @@ -169,20 +170,24 @@ def test_1211_audit_requires_the_successful_current_source_push(self):
'head_branch': 'master-1.21.1', 'head_sha': SHA, 'path': '.github/workflows/native120.yml',
'status': 'completed', 'conclusion': 'success'}

def resolve(run, branch=SHA, run_id='25', source=SHA):
def resolve(run, branch=SHA, run_id='25', source=SHA, target='1.21.1'):
def api(args):
if args[-1].endswith('/actions/runs/25'):
return json.dumps(run)
if args[-1].endswith('/git/ref/heads/master-1.21.1'):
if args[-1].endswith('/git/ref/heads/master-' + target):
return json.dumps({'object': {'sha': branch}})
raise AssertionError(args)
with tempfile.TemporaryDirectory() as folder, patch('subprocess.check_output', side_effect=api):
output = Path(folder) / 'output'
with patch.dict(os.environ, SOURCE_RUN=run_id, SOURCE_SHA=source, GITHUB_OUTPUT=str(output)):
with patch.dict(os.environ, SOURCE_RUN=run_id, SOURCE_SHA=source, TARGET_VERSION=target, GITHUB_OUTPUT=str(output)):
exec(compile(code, 'audit-source', 'exec'), {})
return output.read_text()

self.assertEqual('run=25\nsha=' + SHA + '\n', resolve(good))
self.assertEqual('run=25\nsha=' + SHA + '\nversion=1.21.1\n', resolve(good))
self.assertEqual('run=25\nsha=' + SHA + '\nversion=1.21.11\n',
resolve(dict(good, head_branch='master-1.21.11'), target='1.21.11'))
with self.assertRaises(SystemExit):
resolve(good, target='1.21.11')
for changes in ({'event': 'pull_request'}, {'head_sha': 'b' * 40}, {'head_branch': 'master-1.20.6'},
{'head_repository': {'full_name': 'SkyBlade1978/LootableBodies'}},
{'path': '.github/workflows/native119.yml'}, {'conclusion': 'failure'}, {'id': 26}):
Expand All @@ -193,8 +198,16 @@ def api(args):
with self.assertRaises(SystemExit):
resolve(good, run_id='25;false')

def test_future_12111_candidate_cannot_dispatch_publication(self):
self.assertNotEqual(0, self.select('2.4.14.121111')[0])
def test_12111_requires_the_exact_archive_and_dispatcher(self):
self.assertEqual((0, {'minecraft_version': '1.21.11', 'source_branch': 'master-1.21.11'}),
self.select('2.4.14.121111'))
self.validate('1.21.11', audit_run={'event': 'workflow_dispatch'})
for options in ({'audit_success': False}, {'qualification': {'head_branch': 'master-1.21.1'}},
{'audit_run': {'head_sha': 'd' * 40}}, {'mutation': {'java_version': '17'}},
{'local_receipt': {'manual_accepted': False}}):
with self.subTest(options=options), self.assertRaises(SystemExit):
self.validate('1.21.11', **options)
self.assertNotEqual(0, self.select('2.4.15.261021')[0])

def test_routes_all_supported_versions(self):
for suffix, minecraft, branch in [('110021', '1.10.2', '1.10.2'), ('111021', '1.11.2', '1.11.2-dev'), ('112021', '1.12.2', 'master-1.12'), ('113021', '1.13.2', 'master-1.13.2'), ('114041', '1.14.4', 'master-1.14.4')]:
Expand Down
29 changes: 20 additions & 9 deletions .github/workflows/artifact-audit-1.21.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Audit LootableBodies 1.21 artifacts
run-name: Audit 1.21.1 artifacts from ${{ github.event.workflow_run.head_sha || inputs.source_sha }}
run-name: Audit ${{ github.event.workflow_run.head_branch == 'master-1.21.11' && '1.21.11' || inputs.minecraft_version || '1.21.1' }} artifacts from ${{ github.event.workflow_run.head_sha || inputs.source_sha }}
on:
workflow_run:
workflows: [LootableBodies 1.20 CI, LootableBodies 1.20.6 CI, LootableBodies 1.21.1 CI]
workflows: [LootableBodies 1.20 CI, LootableBodies 1.20.6 CI, LootableBodies 1.21.1 CI, LootableBodies 1.21.11 CI]
types: [completed]
workflow_dispatch:
inputs:
minecraft_version:
description: Minecraft version of the merged archive build
type: choice
default: '1.21.1'
options: ['1.21.1', '1.21.11']
source_run:
description: Successful archive build run ID
required: true
type: string
source_sha:
description: Exact merged 1.21.1 source SHA
description: Exact merged source SHA
required: true
type: string
permissions:
Expand All @@ -24,14 +29,16 @@ jobs:
github.ref == 'refs/heads/master-1.12' &&
(github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'master-1.21.1' && github.event.workflow_run.name == 'LootableBodies 1.21.1 CI'))
((github.event.workflow_run.head_branch == 'master-1.21.1' && github.event.workflow_run.name == 'LootableBodies 1.21.1 CI') ||
(github.event.workflow_run.head_branch == 'master-1.21.11' && github.event.workflow_run.name == 'LootableBodies 1.21.11 CI'))))
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Verify the exact merged archive build
id: source
env:
GH_TOKEN: ${{ github.token }}
TARGET_VERSION: ${{ github.event.workflow_run.head_branch == 'master-1.21.11' && '1.21.11' || inputs.minecraft_version || '1.21.1' }}
SOURCE_RUN: ${{ github.event.workflow_run.id || inputs.source_run }}
SOURCE_SHA: ${{ github.event.workflow_run.head_sha || inputs.source_sha }}
run: |
Expand All @@ -48,22 +55,26 @@ jobs:
return json.loads(subprocess.check_output(['gh', 'api', f'repos/{repo}/{path}']))

run = api(f'actions/runs/{run_id}')
branch = api('git/ref/heads/master-1.21.1')
target = os.environ.get('TARGET_VERSION', '1.21.1')
if target not in ('1.21.1', '1.21.11'):
raise SystemExit('Unsupported archive audit target')
source_branch = 'master-' + target
branch = api('git/ref/heads/' + source_branch)
if (str(run['id']) != run_id or run['head_repository']['full_name'] != repo or
run['event'] != 'push' or run['head_branch'] != 'master-1.21.1' or run['head_sha'] != source or
run['event'] != 'push' or run['head_branch'] != source_branch or run['head_sha'] != source or
run['path'] != '.github/workflows/native120.yml' or run['status'] != 'completed' or
run['conclusion'] != 'success' or branch['object']['sha'] != source):
raise SystemExit('The selected run is not the successful build of the current merged 1.21.1 source')
raise SystemExit('The selected run is not the successful build of the current merged source')
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'run={run_id}\nsha={source}\n')
out.write(f'run={run_id}\nsha={source}\nversion={target}\n')
PY
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ steps.source.outputs.sha }}
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: LootableBodies-1.21.1-${{ steps.source.outputs.sha }}
name: LootableBodies-${{ steps.source.outputs.version }}-${{ steps.source.outputs.sha }}
run-id: ${{ steps.source.outputs.run }}
github-token: ${{ github.token }}
path: audited
Expand Down
Loading
Loading