ci / Compose (pull_request) Successful in 12s
ci / Workflows (pull_request) Successful in 9s
ci / Shell (pull_request) Successful in 21s
ci / Formatting (pull_request) Successful in 22s
ci / Python and tests (pull_request) Successful in 10s
ci / YAML (pull_request) Successful in 11s
ci / Dockerfiles (pull_request) Successful in 6s
ci / Kubernetes (pull_request) Successful in 8s
ci / image-plan (pull_request) Skipped
ci / Image (${{ matrix.name }}) (pull_request) Skipped
ci / build (pull_request) Skipped
25 lines
784 B
Python
25 lines
784 B
Python
"""Keep unit-test workflow commands out of the real CI job files."""
|
|
|
|
import os
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
CI_COMMAND_FILES = ('GITHUB_STEP_SUMMARY', 'GITHUB_OUTPUT', 'GITHUB_ENV', 'GITHUB_PATH', 'GITHUB_STATE')
|
|
|
|
|
|
class IsolatedCITestCase(unittest.TestCase):
|
|
def setUp(self):
|
|
super().setUp()
|
|
directory = tempfile.TemporaryDirectory(prefix='homelab-test-ci-')
|
|
self.addCleanup(directory.cleanup)
|
|
paths = {}
|
|
for variable in CI_COMMAND_FILES:
|
|
path = Path(directory.name) / variable
|
|
path.touch()
|
|
paths[variable] = str(path)
|
|
environment = patch.dict(os.environ, paths)
|
|
environment.start()
|
|
self.addCleanup(environment.stop)
|