-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Check that all toktok-stack modules are in settings.yaml.
Also added some dependabot PR labels.
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sh_test( | ||
name = "settings_test", | ||
size = "small", | ||
srcs = ["@perl"], | ||
args = [ | ||
"$(location settings_test.pl)", | ||
"$(location //:.gitmodules)", | ||
"$(location settings.yaml)", | ||
], | ||
data = [ | ||
"settings.yaml", | ||
"settings_test.pl", | ||
"//:.gitmodules", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings FATAL => 'all'; | ||
|
||
my ($GITMODULES, $SETTINGS) = @ARGV; | ||
|
||
sub read_file { | ||
my $file = shift; | ||
open my $fh, '<', $file or die "Could not open $file: $!"; | ||
my @lines = <$fh>; | ||
return @lines; | ||
} | ||
|
||
my @gitmodules = read_file($GITMODULES); # .gitmodules | ||
my @settings = read_file($SETTINGS); # settings.yaml | ||
|
||
my @git_modules = map { m!\turl = https://github.com/TokTok/([^/]+)\n! ? lc $1 : () } @gitmodules; | ||
my @settings_modules = map { m!^ name: "?([^"]+)"?\n! ? lc $1 : () } @settings; | ||
|
||
# This is the container, so isn't in .gitmodules. | ||
push @git_modules, 'toktok-stack'; | ||
|
||
# Not in settings.yaml because this is just a storage repo. | ||
# We don't need checks for it. | ||
push @settings_modules, 'toktok-fuzzer'; | ||
|
||
my $ok = 1; | ||
for my $module (@settings_modules) { | ||
if (!grep { $_ eq $module } @git_modules) { | ||
print "Module $module is in settings.yaml but not in .gitmodules\n"; | ||
$ok = 0; | ||
} | ||
} | ||
|
||
for my $module (@git_modules) { | ||
if (!grep { $_ eq $module } @settings_modules) { | ||
print "Module $module is in .gitmodules but not in settings.yaml\n"; | ||
$ok = 0; | ||
} | ||
} | ||
|
||
exit !$ok; |