42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class CiContractTests(unittest.TestCase):
|
|
def test_ci_publishes_one_offline_lite_gate(self) -> None:
|
|
workflow = (ROOT / ".gitea/workflows/ci.yml").read_text(encoding="utf-8")
|
|
job_block = workflow.split("jobs:", 1)[1]
|
|
|
|
self.assertEqual(
|
|
re.findall(r"(?m)^ ([a-z][a-z0-9_-]*):\s*$", job_block),
|
|
["lite"],
|
|
)
|
|
self.assertIn(
|
|
"actions/checkout@524e936cd9e579adf00e308bfdf971aebc7de09e",
|
|
workflow,
|
|
)
|
|
self.assertIn("persist-credentials: false", workflow)
|
|
self.assertIn(
|
|
"python3 -m unittest discover -s tests -v",
|
|
workflow,
|
|
)
|
|
for forbidden in (
|
|
"actions/checkout@v",
|
|
"apt ",
|
|
"pip ",
|
|
"curl ",
|
|
"wget ",
|
|
"docker pull",
|
|
):
|
|
self.assertNotIn(forbidden, workflow)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|