mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-15 15:02:24 +00:00
Run AppImage CLI regression checks in shared packaging lint
This commit is contained in:
1 parent
fa5ef18780
commit
7cb1cfbbd8
4 files changed
+56
No files matched your search
@@ -11,6 +11,7 @@ on:
|
||||
- .github/workflows/windows-arm64.yml
|
||||
- .github/workflows/test-freebsd.yml
|
||||
- actions/install-apt-packages/**
|
||||
- actions/packaging-lint/**
|
||||
- tests/**
|
||||
push:
|
||||
branches: [main]
|
||||
@@ -23,6 +24,7 @@ on:
|
||||
- .github/workflows/windows-arm64.yml
|
||||
- .github/workflows/test-freebsd.yml
|
||||
- actions/install-apt-packages/**
|
||||
- actions/packaging-lint/**
|
||||
- tests/**
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
@@ -117,6 +117,9 @@ Lints all packaging configurations and metadata:
|
||||
- `appstreamcli validate`
|
||||
- Flatpak manifest consistency checks
|
||||
- FreeBSD dry run & embedded icons verification
|
||||
- AppImage desktop integration and bundled CLI/MCP tests, when the caller provides
|
||||
`packaging/linux/apprun-test.sh` or `packaging/linux/apprun-cli-test.sh`. No app-local
|
||||
workflow job is needed; a failing script fails the shared lint job.
|
||||
|
||||
#### Caller Example:
|
||||
```yaml
|
||||
|
||||
@@ -59,6 +59,13 @@ runs:
|
||||
bash packaging/linux/apprun-test.sh
|
||||
fi
|
||||
|
||||
- name: AppImage bundled CLI and MCP entry point
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -f packaging/linux/apprun-cli-test.sh ]; then
|
||||
bash packaging/linux/apprun-cli-test.sh
|
||||
fi
|
||||
|
||||
- name: Linux tarball installer test
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Exercise the shared AppImage CLI hook without building an app."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ACTION = yaml.safe_load((ROOT / 'actions/packaging-lint/action.yml').read_text())
|
||||
STEP = next(s for s in ACTION['runs']['steps'] if s['name'] == 'AppImage bundled CLI and MCP entry point')
|
||||
|
||||
|
||||
class PackagingCliTests(unittest.TestCase):
|
||||
def run_hook(self, script=None):
|
||||
with tempfile.TemporaryDirectory(prefix='packaging hook ') as directory:
|
||||
root = Path(directory)
|
||||
if script is not None:
|
||||
target = root / 'packaging/linux/apprun-cli-test.sh'
|
||||
target.parent.mkdir(parents=True)
|
||||
target.write_text(script)
|
||||
result = subprocess.run(['bash', '-e', '-o', 'pipefail', '-c', STEP['run']],
|
||||
cwd=root, capture_output=True, text=True, timeout=10)
|
||||
ran = (root / 'ran').exists()
|
||||
return result, ran
|
||||
|
||||
def test_missing_hook_is_optional(self):
|
||||
result, ran = self.run_hook()
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertFalse(ran)
|
||||
|
||||
def test_hook_runs_in_the_caller_checkout_without_executable_bit(self):
|
||||
result, ran = self.run_hook('printf "CLI hook ran\\n"; touch ran\n')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertTrue(ran)
|
||||
self.assertIn('CLI hook ran', result.stdout)
|
||||
|
||||
def test_failure_is_not_swallowed(self):
|
||||
result, _ = self.run_hook('echo "CLI regression" >&2; exit 37\n')
|
||||
self.assertEqual(result.returncode, 37)
|
||||
self.assertIn('CLI regression', result.stderr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user