diff --git a/GEMINI.md b/GEMINI.md index 0bc1ced60..8ee0c5128 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -138,6 +138,7 @@ pytest 'tests/modules/project/tftest.yaml::context' --tb=short -s * **Branching:** Use `username/feature-name`. * **Commits:** Atomic commits with clear messages. +* **PR Titles:** Avoid semantic commit prefixes. Use Title Case for the first word. * **Docs:** Do not manually edit the variables/outputs tables in READMEs; use `tfdoc.py`. ## Adding Context Support to a Module diff --git a/tests/examples/test_plan.py b/tests/examples/test_plan.py index 4db489a81..71d64f4ab 100644 --- a/tests/examples/test_plan.py +++ b/tests/examples/test_plan.py @@ -72,7 +72,12 @@ def _test_terraform_example(plan_validator, example): directive.kwargs.get('fixtures')) elif example.type == 'tfvars': (tmp_path / 'terraform.auto.tfvars').write_text(example.code) - shutil.copytree(example.module, tmp_path, dirs_exist_ok=True) + + def ignore_missing(src, names): + return [n for n in names if not (Path(src) / n).exists()] + + shutil.copytree(example.module, tmp_path, dirs_exist_ok=True, + ignore=ignore_missing) tf_var_files = [(tmp_path / 'terraform.auto.tfvars').resolve()] inventory = [] diff --git a/tests/fixtures.py b/tests/fixtures.py index 8cd8c71e4..2ec1330be 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -42,12 +42,15 @@ def _prepare_root_module(path): # directories that are automatically read by terraform. Useful # to avoid surprises if, for example, you have an active fast # deployment with links to configs) - ignore_patterns = shutil.ignore_patterns('*.auto.tfvars', - '*.auto.tfvars.json', - '[0-9]-*-providers.tf', - 'terraform.tfstate*', - '.terraform.lock.hcl', - 'terraform.tfvars', '.terraform') + _ignore = shutil.ignore_patterns('*.auto.tfvars', '*.auto.tfvars.json', + '[0-9]-*-providers.tf', 'terraform.tfstate*', + '.terraform.lock.hcl', 'terraform.tfvars', + '.terraform', '.git') + + def ignore_patterns(src, names): + ignored = set(_ignore(src, names)) + ignored.update([n for n in names if not (Path(src) / n).exists()]) + return list(ignored) with tempfile.TemporaryDirectory(dir=path.parent) as tmp_path: tmp_path = Path(tmp_path) @@ -330,10 +333,8 @@ def get_tfvars_for_e2e(): missing_vars = set([f'TFTEST_E2E_{k}' for k in _variables]) - set( os.environ.keys()) if missing_vars: - raise RuntimeError( - f'Missing environment variables: {missing_vars} required to run E2E tests. ' - f'Consult CONTRIBUTING.md to understand how to set them up. ' - f'If you want to skip E2E tests add -k "not examples_e2e" to your pytest call' + pytest.skip( + f'Missing environment variables: {missing_vars} required to run E2E tests.' ) tf_vars = {k: os.environ.get(f'TFTEST_E2E_{k}') for k in _variables} if tf_vars['region'] == tf_vars['region_secondary']: