36 lines
1.6 KiB
YAML
36 lines
1.6 KiB
YAML
name: Metadata integrity checks
|
|
on:
|
|
push:
|
|
branches: [main, 'codex/**']
|
|
jobs:
|
|
metadata:
|
|
runs-on: ces-control
|
|
env:
|
|
ARCHIVE_SHA: ${{ github.sha }}
|
|
PYTHONDONTWRITEBYTECODE: '1'
|
|
steps:
|
|
- name: Verify metadata storage and query commands
|
|
run: |
|
|
python3 -B - <<'PY'
|
|
import io, os, pathlib, re, subprocess, tarfile, tempfile, urllib.request
|
|
sha = os.environ['ARCHIVE_SHA']
|
|
if not re.fullmatch(r'[0-9a-fA-F]{40,64}', sha):
|
|
raise SystemExit('Invalid source commit')
|
|
# Public repository archive: no owner credentials or runner SSH keys.
|
|
url = 'https://gitea.entroia.com/Zayden-Jung/paper-atlas/archive/' + sha + '.tar.gz'
|
|
with urllib.request.urlopen(url, timeout=60) as response:
|
|
archive = response.read(16*1024*1024+1)
|
|
if len(archive)>16*1024*1024:
|
|
raise SystemExit('Unexpectedly large source archive')
|
|
with tempfile.TemporaryDirectory(prefix='paper-atlas-ci-') as tmp:
|
|
root = pathlib.Path(tmp)
|
|
with tarfile.open(fileobj=io.BytesIO(archive), mode='r:gz') as tar:
|
|
tar.extractall(root, filter='data')
|
|
candidates = list(root.glob('*/test_import_arxiv.py'))
|
|
if len(candidates)!=1:
|
|
raise SystemExit('Unexpected repository archive layout')
|
|
src = candidates[0].parent
|
|
subprocess.run(['python3','-B','-m','unittest','discover','-v'],cwd=src,check=True)
|
|
subprocess.run(['python3','-B','query.py','--help'],cwd=src,check=True)
|
|
PY
|