99jobs :
1010 validate-masterlist :
1111 runs-on : ubuntu-latest
12-
12+
1313 steps :
1414 - uses : actions/checkout@v4
15-
15+
1616 - name : Install dependencies
1717 run : |
1818 sudo apt-get update
1919 sudo apt-get install -y perl mirmon
20-
21- - name : Create validation script
22- run : |
23- cat > validate_masterlist.pl << 'SCRIPT'
24- #!/usr/bin/perl
25- use strict;
26- use warnings;
27-
28- my $file = $ARGV[0] || 'Mirrors.masterlist';
29- die "no file $file" unless -f $file;
30-
31- open(my $fh, '<', $file) or die "Could not open $file: $!";
32-
33- my @mirrors;
34- my $data;
35- my $line_num = 0;
36- my $errors = 0;
37-
38- while (my $line = <$fh>) {
39- $line_num++;
40- chomp $line;
41- if ($line =~ /([^:]+): (.*)/) {
42- my $key = lc($1);
43- my $value = $2;
44- $data->{$key} = $value;
45- } elsif ($line eq '') {
46- if ($data) {
47- # Validate required fields
48- unless ($data->{site}) {
49- print "ERROR: Entry missing Site field around line $line_num\n";
50- $errors++;
51- }
52- unless ($data->{type}) {
53- print "ERROR: Entry missing Type field for site " . ($data->{site} || "unknown") . "\n";
54- $errors++;
55- }
56- unless ($data->{country}) {
57- print "ERROR: Entry missing Country field for site " . ($data->{site} || "unknown") . "\n";
58- $errors++;
59- }
60- push @mirrors, $data;
61- }
62- $data = undef;
63- } else {
64- print "WARNING: Malformed line $line_num: $line\n";
65- }
66- }
67-
68- # Check last entry if file does not end with blank line
69- if ($data) {
70- unless ($data->{site}) {
71- print "ERROR: Last entry missing Site field\n";
72- $errors++;
73- }
74- unless ($data->{type}) {
75- print "ERROR: Last entry missing Type field for site " . ($data->{site} || "unknown") . "\n";
76- $errors++;
77- }
78- unless ($data->{country}) {
79- print "ERROR: Last entry missing Country field for site " . ($data->{site} || "unknown") . "\n";
80- $errors++;
81- }
82- push @mirrors, $data;
83- }
84-
85- if ($errors > 0) {
86- print "Found $errors syntax errors in masterlist\n";
87- exit(1);
88- } else {
89- print "Masterlist syntax validation passed (" . @mirrors . " entries)\n";
90- }
91- SCRIPT
92-
93- chmod +x validate_masterlist.pl
94-
20+
9521 - name : Validate masterlist syntax
9622 run : |
9723 # Check if masterlist file exists
9824 if [ ! -f "Mirrors.masterlist" ]; then
9925 echo "ERROR: Mirrors.masterlist not found"
10026 exit 1
10127 fi
102-
103- # Run syntax validation
104- ./validate_masterlist.pl Mirrors.masterlist
105-
28+
29+ # Run syntax validation using the standalone script
30+ ./bin/ validate_masterlist Mirrors.masterlist
31+
10632 - name : Test masterlist2mirmon conversion
10733 run : |
10834 # Make script executable
10935 chmod +x bin/masterlist2mirmon
110-
36+
11137 # Run the conversion
11238 echo "Converting masterlist to mirmon format..."
11339 ./bin/masterlist2mirmon Mirrors.masterlist > test-mirror.list
114-
40+
11541 # Check if output was generated
11642 if [ ! -s test-mirror.list ]; then
11743 echo "ERROR: masterlist2mirmon produced no output"
11844 exit 1
11945 fi
120-
46+
12147 # Count entries
12248 entries=$(wc -l < test-mirror.list)
12349 echo "Generated $entries mirror entries"
124-
50+
12551 # Basic format validation
12652 echo "Validating mirmon list format..."
12753 if ! grep -q "^[A-Z][A-Z] " test-mirror.list; then
12854 echo "ERROR: No valid country code entries found"
12955 exit 1
13056 fi
131-
57+
13258 # Check for valid URL patterns
13359 if ! grep -qE "^[A-Z][A-Z] (https?|ftp|rsync)://" test-mirror.list; then
13460 echo "ERROR: No valid URL entries found"
13561 exit 1
13662 fi
137-
63+
13864 echo "Mirror list format validation passed"
139-
65+
14066 # Show sample output
14167 echo "Sample mirror entries:"
14268 head -5 test-mirror.list
143-
69+
14470 - name : Test mirmon compatibility
14571 run : |
14672 # Create minimal mirmon config for testing
@@ -155,10 +81,10 @@ jobs:
15581 probe /usr/bin/wget -q -O- -T %TIMEOUT% -t 1 %URL%timestamp.txt
15682 icons icons
15783 CONFIG
158-
84+
15985 # Create dummy icons directory
16086 mkdir -p icons
161-
87+
16288 # Test if mirmon can parse our generated mirror list
16389 echo "Testing mirmon compatibility..."
16490 if ! mirmon -c test-mirmon.conf -q test >/dev/null 2>&1; then
16894 else
16995 echo "Mirmon compatibility test passed"
17096 fi
171-
97+
17298 # Alternative test: just verify mirmon can read the mirror list file
17399 echo "Alternative test: verify mirmon can parse mirror list format..."
174100 if perl -e '
@@ -193,15 +119,15 @@ jobs:
193119 echo "ERROR: Mirror list format validation failed"
194120 exit 1
195121 fi
196-
122+
197123 - name : Validate mirror URLs accessibility (sample)
198124 run : |
199125 # Test a sample mirror URL
200126 echo "Testing sample mirror URL accessibility..."
201-
127+
202128 # Extract first HTTPS URL
203129 first_url=$(grep -m1 "^[A-Z][A-Z] https" test-mirror.list | cut -d' ' -f2- || true)
204-
130+
205131 if [ -n "$first_url" ]; then
206132 echo "Testing URL: $first_url"
207133 if timeout 10 curl -sSf --head "$first_url" > /dev/null 2>&1; then
@@ -212,4 +138,4 @@ jobs:
212138 fi
213139 else
214140 echo "No HTTPS URLs found to test"
215- fi
141+ fi
0 commit comments