No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Julien Dessaux f0ddf2f31c
All checks were successful
main / test (push) Successful in 4s
feat(checks): add check_yaml
2026-11-10 17:50:09 +01:00
.forgejo/workflows feat(library): add a CLI/ForgejoAction ready-made CLI 2026-11-10 17:09:41 +01:00
lib/AdyxaxOrg feat(checks): add check_yaml 2026-11-10 17:50:09 +01:00
.yamllint feat(checks): add check_yaml 2026-11-10 17:50:09 +01:00
CHANGELOG.md feat(library): initial import 2026-11-10 00:56:38 +01:00
init.pl fix(init): fix race condition in the bootstrap flow 2026-11-10 15:18:01 +01:00
LICENSE feat(library): initial import 2026-11-10 00:56:38 +01:00
make.pl feat(checks): add check_yaml 2026-11-10 17:50:09 +01:00
README.md feat(checks): add check_yaml 2026-11-10 17:50:09 +01:00

Perl library

Shared perl modules backing the make.pl scripts of the adyxax.org repositories.

Contents

Requirements

  • perl >= 5.36 with its core modules,
  • IO::Socket::SSL for HTTPS, the only non-core dependency: libio-socket-ssl-perl (Debian), perl-IO-Socket-SSL (RHEL), security/p5-IO-Socket-SSL (FreeBSD, with security/ca_root_nss),
  • curl and git for the bootstrap.

Ready-made command lines

Repositories of the same kind can use the AdyxaxOrg::CLI::* modules. For example, the make.pl of an ansible repository is:

#!/usr/bin/env perl
use v5.36;
use FindBin qw($RealBin);
chdir $RealBin or die "chdir $RealBin: $!\n";

BEGIN {
    $ENV{PERL_LIBRARY_VERSION} = 'main';
    $ENV{PERL_LIBRARY_DIR} = "$ENV{HOME}/.cache/adyxax.org/perl-library-$ENV{PERL_LIBRARY_VERSION}";
    unless (grep { /\A(?:--no-update\z|-[hv]*n)/ } @ARGV) {
        require File::Temp;
        my $url = "https://git.adyxax.org/api/v1/repos/adyxax.org/perl-library/raw/init.pl?ref=$ENV{PERL_LIBRARY_VERSION}";
        my $init = File::Temp->new(SUFFIX => '.pl');
        system('curl', '-fsSL', '-o', "$init", $url) == 0
            or die "perl library bootstrap: failed to download $url\n";
        system($^X, "$init") == 0 or die "perl library bootstrap failed\n";
    }
}
use lib "$ENV{PERL_LIBRARY_DIR}/lib";
use AdyxaxOrg::CLI::Ansible qw(ansible_main);
ansible_main(@ARGV);

Fully custom make.pl example

#!/usr/bin/env perl
use v5.36;
use FindBin qw($RealBin);
use Getopt::Long qw(:config bundling no_ignore_case);
chdir $RealBin or die "chdir $RealBin: $!\n";

BEGIN {
    $ENV{PERL_LIBRARY_VERSION} = 'main';
    $ENV{PERL_LIBRARY_DIR} = "$ENV{HOME}/.cache/adyxax.org/perl-library-$ENV{PERL_LIBRARY_VERSION}";
    unless (grep { /\A(?:--no-update\z|-[hv]*n)/ } @ARGV) {
        require File::Temp;
        my $url = "https://git.adyxax.org/api/v1/repos/adyxax.org/perl-library/raw/init.pl?ref=$ENV{PERL_LIBRARY_VERSION}";
        my $init = File::Temp->new(SUFFIX => '.pl');
        system('curl', '-fsSL', '-o', "$init", $url) == 0
            or die "perl library bootstrap: failed to download $url\n";
        system($^X, "$init") == 0 or die "perl library bootstrap failed\n";
    }
}
use lib "$ENV{PERL_LIBRARY_DIR}/lib";

use AdyxaxOrg::Check qw(check_perl check_shell);
use AdyxaxOrg::Podman qw(podman_push);
use AdyxaxOrg::Shell qw(capture run);

my $build_id = capture(qw(git rev-parse --short HEAD));

sub usage($error = undef) {
    say STDERR $error if defined $error;
    print STDERR <<"EOF";
Usage:
    $0 build      # build the container image.
    $0 check      # lint the scripts and this make.pl.
    $0 push [-t]  # push the image to the registry.
Global options:
    -h  show this help message
    -n  do not update the perl library
    -v  verbose mode, trace every command on stderr
Command options:
    -t  also push the built image to latest
EOF
    exit(defined $error ? 1 : 0);
}

my %opts;
GetOptions(\%opts, 't', 'n', 'h' => sub { usage() },
           'v' => \$AdyxaxOrg::Shell::VERBOSE) or usage('Invalid options');
my $action = shift @ARGV // usage('Missing action');

my %actions = (
    build => sub { run(qw(buildah build ...)) },
    check => sub { check_shell(); check_perl() },
    push  => sub { podman_push('quay.io', 'adyxax', 'example', $build_id, $opts{t}) },
);
my $code = $actions{$action} // usage("Unknown action: $action");
$code->(@ARGV);

Usage from Forgejo Actions

steps:
  - uses: "https://git.adyxax.org/adyxax.org/action-checkout@1.0.0"
  - name: 'Bootstrap the perl library'
    run: './make.pl -h'
  - name: 'Check and lint everything'
    run: './make.pl -n check'

Modules

Module Functions
AdyxaxOrg::Assert assert_commands <command>...
AdyxaxOrg::Check check_ansible [requirements]
check_perl
check_shell
check_tofu [directory]
check_yaml
AdyxaxOrg::CLI::Ansible ansible_main [\%config] @ARGV, ansible_options \%opts
AdyxaxOrg::CLI::AnsibleRole ansible_role_main [\%config] @ARGV
AdyxaxOrg::CLI::ForgejoAction forgejo_action_main [\%config] @ARGV
AdyxaxOrg::Shell capture [\%options] <command>...,
run <command>...,
run_ok <command>...,
which <command>
AdyxaxOrg::Utils ansible_galaxy_install <requirements> [upgrade],
ensure_uv [requirements],
find_files <regex> [directory]