Files
petrbalvin 788cf0571f
Deploy / deploy (push) Successful in 17s
Test / test (push) Successful in 53s
feat: initial release of the scripts collection
Assisted-by: GLM 5.3 Flash
2026-09-10 04:00:00 +00:00

108 lines
4.1 KiB
YAML

# Test: the push-path gates for the scripts collection. Runs on every push and pull
# request against development, never on main, which is release-only.
#
# The gates are the same set the repository documents in docs/DEVELOPMENT.md: every
# script compiles, carries its licence header, uses no dash as punctuation, and passes
# its own checks under tests/. They are the affordable ones: the container rigs that
# verify a script against a real system need podman and a privileged container, which
# belong to the machine at the keyboard, not to a shared runner.
#
# Every step is one command, and the scripted steps are Perl rather than shell, so no
# shell option has to be trusted for the run to stop. The Perl uses builtins only:
# the runner packages the modules separately.
name: Test
on:
push:
branches: [development]
pull_request:
branches: [development]
jobs:
test:
runs-on: fedora
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- name: Install Perl
run: dnf install -y perl
- name: Every script compiles
run: |
perl -e '
my @files = sort glob q{*.pl};
@files or die qq{ERROR: no scripts found\n};
for my $file (@files) {
system(q{perl}, q{-c}, $file) == 0 or die qq{ERROR: $file does not compile\n};
}
print qq{compiled @files[0..$#files]: }, scalar(@files), qq{ scripts\n};
'
- name: Every script carries the licence header
run: |
perl -e '
my @files = sort glob q{*.pl};
@files or die qq{ERROR: no scripts found\n};
for my $file (@files) {
open(my $fh, q{<}, $file) or die qq{ERROR: $file: $!\n};
my @head = map { my $line = <$fh> // q{}; chomp $line; $line } 1 .. 3;
close($fh);
$head[0] =~ m{^#!/usr/bin/env perl\z}
or die qq{ERROR: $file has no Perl shebang in the form this collection uses\n};
# The name carries a non-ASCII letter and the files are byte strings,
# so its UTF-8 bytes are matched rather than a wildcard width.
$head[1] =~ m{^# Copyright \(c\) \d{4} Petr Balv\xc3\xadn <opensource\@petrbalvin\.org> \(https://petrbalvin\.org\)\z}
or die qq{ERROR: $file has no copyright line\n};
$head[2] =~ m{^# SPDX-License-Identifier: MIT\z}
or die qq{ERROR: $file has no SPDX line, or names another licence\n};
}
print qq{licence header present in }, scalar(@files), qq{ scripts\n};
'
- name: No dash as punctuation
run: |
perl -e '
my @files = (sort(glob q{*.pl}), sort(glob q{tests/*.pl}), sort(glob q{*.md}),
sort(glob q{.gitea/workflows/*.yml}));
@files or die qq{ERROR: no files found\n};
my $found = 0;
for my $file (@files) {
open(my $fh, q{<}, $file) or die qq{ERROR: $file: $!\n};
my $number = 0;
while (my $line = <$fh>) {
$number++;
# The bytes matter: the files are byte strings, so the em dash and
# the en dash are matched as their UTF-8 sequences.
if ($line =~ /\xe2\x80\x94|\xe2\x80\x93/) {
print qq{ERROR: $file:$number uses a dash as punctuation\n};
$found++;
}
}
close($fh);
}
die qq{ERROR: $found line(s) use a dash as punctuation\n} if $found;
print qq{no dash used as punctuation in }, scalar(@files), qq{ files\n};
'
- name: network-diag.pl
run: perl tests/network-diag.pl
- name: security-audit.pl
run: perl tests/security-audit.pl
- name: server-setup.pl
run: perl tests/server-setup.pl
- name: sglang-deploy.pl
run: perl tests/sglang-deploy.pl
- name: system-diag.pl
run: perl tests/system-diag.pl
- name: system-optimise.pl
run: perl tests/system-optimise.pl
- name: workstation-setup.pl
run: perl tests/workstation-setup.pl