Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 6655784

Browse files
committed
refactor: reorganize test structure and fix cloud-init header
- Mirror production directory structure in tests (t/command/provision.t) - Update GitHub Actions workflow to use recursive test discovery (prove -lr) - Configure yamllint to ignore cloud-init files for header format exception - Add critical warning comment to prevent future cloud-init header modifications - Update test regex to match corrected header format Fixes VM provisioning issues caused by cloud-init header spacing.
1 parent 35fedb6 commit 6655784

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ jobs:
6161
- name: Run tests
6262
run: |
6363
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
64-
carmel exec -- prove -l t/
64+
carmel exec -- prove -lr t/

.yamllint-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ rules:
88
document-start: disable # Cloud-init files don't need --- start
99
truthy:
1010
allowed-values: ["true", "false", "yes", "no", "on", "off"] # Allow cloud-init and GitHub Actions common values
11+
12+
# Ignore cloud-init files for comment spacing since #cloud-config is a special directive
13+
ignore: |
14+
**/cloud-init.yml

t/provision_command.t renamed to t/command/provision.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use Test2::V0;
22
use FindBin qw($Bin);
3-
use lib "$Bin/../lib";
3+
use lib "$Bin/../../lib";
44
use Path::Tiny qw(path);
55
use File::Temp qw(tempdir);
66

@@ -30,7 +30,7 @@ subtest 'Provision command is discoverable by app' => sub {
3030
};
3131

3232
subtest 'Template files exist and are readable' => sub {
33-
my $project_root = path($Bin)->parent;
33+
my $project_root = path($Bin)->parent->parent;
3434
my $templates_dir = $project_root->child('templates/provision');
3535

3636
ok($templates_dir->exists, 'Templates/provision directory exists');
@@ -49,7 +49,7 @@ subtest 'Template files exist and are readable' => sub {
4949
};
5050

5151
subtest 'Template files have expected content' => sub {
52-
my $project_root = path($Bin)->parent;
52+
my $project_root = path($Bin)->parent->parent;
5353
my $templates_dir = $project_root->child('templates/provision');
5454

5555
my $main_tf_content = $templates_dir->child('tofu/providers/libvirt/main.tf')->slurp_utf8;
@@ -59,7 +59,7 @@ subtest 'Template files have expected content' => sub {
5959
like($main_tf_content, qr/torrust-tracker/, 'main.tf contains torrust-tracker VM name');
6060

6161
my $cloud_init_content = $templates_dir->child('cloud-init.yml')->slurp_utf8;
62-
like($cloud_init_content, qr/#cloud-config/, 'cloud-init.yml has cloud-config header');
62+
like($cloud_init_content, qr/^#cloud-config/, 'cloud-init.yml has cloud-config header');
6363
like($cloud_init_content, qr/hostname:\s*torrust-tracker/, 'cloud-init.yml sets hostname');
6464
like($cloud_init_content, qr/name:\s*torrust/, 'cloud-init.yml creates torrust user');
6565
};
@@ -76,7 +76,7 @@ subtest 'Provision command template copying functionality' => sub {
7676
});
7777

7878
# Test the _copy_templates method directly
79-
my $project_root = path($Bin)->parent;
79+
my $project_root = path($Bin)->parent->parent;
8080
my $templates_dir = $project_root->child('templates/provision');
8181

8282
# Test that template directory exists

templates/provision/cloud-init.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#cloud-config
2-
# cloud-config
3-
# Optimized cloud-init configuration based on manual testing
2+
# ⚠️ CRITICAL: The line above MUST be exactly "#cloud-config" (no space after #)
3+
# This is a special cloud-init directive that will break VM provisioning if modified.
4+
# Linting tools may warn about missing space, but this is intentional and required.
45

56
# Basic system configuration
67
hostname: torrust-tracker

0 commit comments

Comments
 (0)