+++ /dev/null
-addons:
- apt:
- packages:
- # irssi build dependencies
- - elinks
- # script test dependencies
- - zsh
- # script dependencies
- - libdb-dev
- - libaspell-dev
- - libgirepository1.0-dev
- - gobject-introspection
- - gir1.2-notify-0.7 # for desktop-notify
- - xosd-bin # for osd
-before_install:
- - wget -nv https://download.opensuse.org/repositories/home:ailin_nemui:irssi-git/Debian_9.0/Release.key -O- | apt-key add -
- - echo 'deb http://download.opensuse.org/repositories/home:/ailin_nemui:/irssi-git/Debian_9.0/ /' > /etc/apt/sources.list.d/irssi_obs.list
- - apt-get update -q && apt-get install -y irssi-git
-install:
- - |
- if [ "${USE_ARTEFACTS_CACHE:-no}" = yes ] && [ "${EXTRACT_TEST_ARTEFACTS:-no}" = yes ]; then
- ./_testing/github/load-old-artefacts.zsh
- fi
- - ./_testing/autoinstall-perl-prereqs.zsh
- - cpanm --quiet --installdeps --notest ./auto
-before_script:
- - ./_testing/run-test.zsh
- - |
- if [ "${GITHUB_REF:-}" != refs/heads/master ]; then
- git diff --stat origin/master
- fi
-script:
- - ./_testing/report-test.zsh || rc=$?
- - echo ${rc:-0} > $HOME/script-rc
-after_script:
- - ./_testing/github/show-failures.zsh
- - |
- if [ "${GITHUB_REF:-}" = refs/heads/master ] && [ -n "${GITHUB_TOKEN:-}" ]; then
- perl ./_testing/update-scripts-yaml.pl
- ./_testing/github/commit-scripts-yaml.zsh
- fi
- - |
- if [ "${GITHUB_REF:-}" = refs/heads/master ] && [ -n "${GITHUB_TOKEN:-}" ] && [ "${EXTRACT_TEST_ARTEFACTS:-no}" = yes ]; then
- ./_testing/github/extract-artefacts.zsh
- fi
- - cat /github/home/.git-credential-helper
-script_result:
- - (exit "$(cat $HOME/script-rc)")
-global_env:
- - export LANG=C.UTF-8
- - export USE_ARTEFACTS_CACHE=yes
- - export EXTRACT_TEST_ARTEFACTS=yes
+++ /dev/null
-# workflow "Check Scripts(M)" {
-# on = "push"
-# resolves = ["update-scripts"]
-# }
-
-# workflow "Check Scripts" {
-# on = "push"
-# resolves = ["result"]
-# }
-
-action "On Master Branch" {
- uses = "actions/bin/filter@master"
- args = "branch master"
-}
-
-action "On Pull Request" {
- uses = "actions/bin/filter@master"
- args = "not branch master"
-}
-
-action "run-test(m)" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["On Master Branch"]
- args = "before_install global_env install before_script"
-}
-
-action "run-test" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["On Pull Request"]
- args = "before_install global_env install before_script"
-}
-
-action "report-test" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["run-test"]
- args = "global_env script"
-}
-
-action "report-test(m)" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["run-test(m)"]
- args = "global_env script"
-}
-
-action "update-scripts" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["report-test(m)"]
- args = "global_env after_script"
- secrets = ["GITHUB_TOKEN"]
-}
-
-action "show-failures" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["report-test"]
- args = "global_env after_script"
-}
-
-action "result" {
- uses = "irssi-import/actions-irssi/check-irssi-scripts@master"
- needs = ["show-failures"]
- args = "global_env script_result"
-}
--- /dev/null
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+name: Check Script
+env:
+ apt_build_deps: irssi-git cpanminus elinks zsh
+ apt_script_deps: libdb-dev libaspell-dev libgirepository1.0-dev gobject-introspection gir1.2-notify-0.7 xosd-bin wbritish
+ USE_ARTEFACTS_CACHE: yes
+ EXTRACT_TEST_ARTEFACTS: yes
+ PERL_MM_NONINTERACTIVE: 1
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@main
+ - uses: mstachniuk/ci-skip@v1
+ with:
+ fail-fast: true
+ - name: prepare required software
+ run: |
+ RELEASE=$(lsb_release -rs)
+ echo "deb http://download.opensuse.org/repositories/home:/ailin_nemui:/irssi-git/xUbuntu_$RELEASE/ /" | sudo tee /etc/apt/sources.list.d/home:ailin_nemui:irssi-git.list
+ curl -fsSL https://download.opensuse.org/repositories/home:ailin_nemui:irssi-git/xUbuntu_$RELEASE/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_ailin_nemui_irssi-git.gpg > /dev/null
+ sudo apt -q update
+ sudo apt -q install $apt_build_deps $apt_script_deps
+ - name: cache cpan
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/extlib
+ key: ${{ runner.os }}-cpan-${{ github.sha }}-${{ github.run_number }}
+ restore-keys: |
+ ${{ runner.os }}-cpan-${{ github.sha }}-
+ ${{ runner.os }}-cpan-
+ - name: fetch origin master branch
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ git fetch --depth=1 origin refs/heads/master
+ - name: configure local::lib
+ run: |
+ eval $(perl -Mlocal::lib="$HOME"/extlib)
+ for v in PATH PERL5LIB PERL_LOCAL_LIB_ROOT PERL_MB_OPT PERL_MM_OPT; do
+ eval echo "\$v=\$$v" >> $GITHUB_ENV
+ done
+ - name: fix the broken Encode module
+ run: |
+ cpanm Encode
+ - name: load old artefacts
+ if: ${{ env.USE_ARTEFACTS_CACHE == 'yes' }}
+ run:
+ ./_testing/github/load-old-artefacts.zsh
+ - name: install cpan dependencies
+ run: |
+ cpanm --installdeps --notest .
+ ./_testing/autoinstall-perl-prereqs.zsh
+ - name: auto-install cpan script dependencies
+ run: |
+ pushd auto
+ cpanm --quiet --installdeps --notest .
+ popd
+ - name: run tests
+ run: |
+ ./_testing/run-test.zsh
+ - name: show diffstat
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ git diff --stat origin/master
+ - name: test report
+ run: |
+ ./_testing/report-test.zsh || rc=$?
+ echo "SCRIPT_RC=${rc:-0}" >> $GITHUB_ENV
+ - name: integration report
+ run: |
+ ./_testing/github/show-failures.zsh
+ - name: update scripts.yaml
+ if: ${{ github.event_name == 'push' }}
+ run: |
+ perl ./_testing/update-scripts-yaml.pl
+ - name: commit scripts.yaml
+ if: ${{ github.event_name == 'push' }}
+ run: |
+ ./_testing/github/commit-scripts-yaml.zsh
+ - uses: actions/checkout@main
+ if: ${{ github.event_name == 'push' && env.EXTRACT_TEST_ARTEFACTS == 'yes' }}
+ with:
+ ref: ci-artefacts
+ path: artefacts
+ - name: extract artefacts
+ if: ${{ github.event_name == 'push' && env.EXTRACT_TEST_ARTEFACTS == 'yes' }}
+ run: |
+ ./_testing/github/extract-artefacts.zsh
+ - name: end
+ run: |
+ exit $SCRIPT_RC
BEGIN {
*CORE::GLOBAL::exit = sub (;$) {
- require Carp;
- Carp::croak("script tried to call exit @_");
+ require Carp;
+ Carp::croak("script tried to call exit @_");
};
}
require YAML::Tiny;
YAML::Tiny->VERSION("1.59");
require Encode;
+die "Broken Encode version (2.88)" if $Encode::VERSION eq '2.88';
{
# This is an ugly hack to be `lax' about the encoding. We try to
# read everything as UTF-8 regardless of declared file encoding
my $orig = YAML::Tiny->can("_has_internal_string_value") || die("Error in ".__PACKAGE__);
no warnings 'redefine';
*YAML::Tiny::_has_internal_string_value = sub {
- my $ret = $orig->(@_);
- use bytes;
- $_[0] = Encode::decode_utf8($_[0], sub{pack 'U', +shift})
- unless Encode::is_utf8($_[0]);
- $ret
+ my $ret = $orig->(@_);
+ use bytes;
+ $_[0] = Encode::decode_utf8($_[0], sub{pack 'U', +shift})
+ unless Encode::is_utf8($_[0]);
+ $ret
}
}
require Module::CoreList;
my $prereq_results = Perl::PrereqScanner->new->scan_file("$SWD/scripts/$CURRENT_SCRIPT.pl");
my @modules = grep {
$_ ne 'perl' &&
- $_ ne 'Irssi' && $_ ne 'Irssi::UI' && $_ ne 'Irssi::TextUI' && $_ ne 'Irssi::Irc'
- && !Module::CoreList->first_release($_)
+ $_ ne 'Irssi' && $_ ne 'Irssi::UI' && $_ ne 'Irssi::TextUI' && $_ ne 'Irssi::Irc'
+ && !Module::CoreList->first_release($_)
} sort keys %{ $prereq_results->as_string_hash };
my (%info, $version, @commands);
- idonkey
- ircgallery
- isdn
+ - iMPD
- ixmmsa
- l33tmusic
- log2ansi
scriptfiles=($(git diff --numstat --no-renames origin/master|cut -f3|grep '^scripts/.*\.pl'))
IFS=$OIFS
if [[ $#scriptfiles -gt 0 ]] {
- filelist=($scriptfiles)
+ filelist=($scriptfiles)
}
} \
elif [[ $USE_ARTEFACTS_CACHE = yes ]] {
#!/bin/zsh
-[[ -z $GITHUB_TOKEN ]] && exit
+[[ -z $GITHUB_ACTION ]] && exit
git config user.email "scripts@irssi.org"
git config user.name "Irssi Scripts Helper"
git add _data/scripts.yaml
git commit -m "automatic scripts database update for $GITHUB_SHA
-[skip ci]"
+[ci skip]"
git config push.default simple
git push --set-upstream origin master
}
#!/bin/zsh
-if [[ -z $GITHUB_TOKEN || -z $GITHUB_REPOSITORY ]] { exit 1 }
+if [[ -z $GITHUB_REPOSITORY ]] { exit 1 }
autoload -Uz zargs
-if { ! git clone -b ci-artefacts https://github.com/${GITHUB_REPOSITORY}.git artefacts } {
- mkdir artefacts && git init artefacts
- pushd artefacts
- git remote add origin https://github.com/${GITHUB_REPOSITORY}.git
- git checkout -b ci-artefacts
- popd
-}
-
pushd artefacts
git config user.email "scripts@irssi.org"
git config user.name "Irssi Scripts Helper"
git add .
git commit -q -m "ci artefacts for $GITHUB_SHA
-[skip ci]"
+[ci skip]"
git push -u origin ci-artefacts
for scriptfile ($filelist) {
echo '--- '$scriptfile:t
if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] {
- echo "FATAL: SCRIPT FAILED TO LOAD "
- }
+ echo "FATAL: SCRIPT FAILED TO LOAD "
+ }
cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null
cat "Test/${scriptfile:t:r}/irssi.log"
- echo
- echo 'Source code critic:'
- cat "Test/${scriptfile:t:r}/perlcritic.log"
- echo
+ echo
+ echo 'Source code critic:'
+ cat "Test/${scriptfile:t:r}/perlcritic.log"
+ echo
}
echo
echo '======== YAML DATABASE ========'
for scriptfile ($filelist) {
if [[ ! -f "Test/${scriptfile:t:r}/failed.yml" ]] {
- cat "Test/${scriptfile:t:r}/info.yml"
- }
+ cat "Test/${scriptfile:t:r}/info.yml"
+ }
}
} \
else {
perl -ne '$score += $1 -1 if /Severity: (\d+)/; END { printf "%3d", $score }' "Test/${scriptfile:t:r}/perlcritic.log" 2>/dev/null
print -n ' '$T
if [[ $pass -lt 3 ]] {
- if [[ -n $allow_fail[$scriptfile:t:r] ]] || [[ ! -f scripts/${scriptfile:t:r}.pl ]] {
- print -n ' '$skipmark' '
- } \
- else {
- print -n ' '$failmark' '
- if [[ $failed -lt 254 ]] { ((++failed)) }
- }
+ if [[ -n $allow_fail[$scriptfile:t:r] ]] || [[ ! -f scripts/${scriptfile:t:r}.pl ]] {
+ print -n ' '$skipmark' '
+ } \
+ else {
+ print -n ' '$failmark' '
+ if [[ $failed -lt 254 ]] { ((++failed)) }
+ }
} \
else {
- print -n ' '$passmark' '; ((++pass))
- echo 1>"Test/${scriptfile:t:r}/passed"
+ print -n ' '$passmark' '; ((++pass))
+ echo 1>"Test/${scriptfile:t:r}/passed"
}
if [[ $+cached_run[(r)$scriptfile] -gt 0 ]] {
print -n $T' (c)'
local base_path="`pwd`"
local test_script="$base_path/_testing/_irssi_test.pl"
+if [[ $(perl -MEncode -e'print $Encode::VERSION') == 2.88 ]] {
+ echo "Broken Encode version (2.88). Please update the Perl Encode module."
+ exit 4
+}
+
. ./_testing/_get_files_arr.zsh
for scriptfile ($filelist) {
rm -rf "Test/${scriptfile:t:r}"
mkdir -p "Test/${scriptfile:t:r}"
if [[ ! -f scripts/${scriptfile:t:r}.pl ]] {
- {echo "command not found: script ${scriptfile:t:r}";echo "test skipped"} >"Test/${scriptfile:t:r}/perlcritic.log"
- continue
+ {echo "command not found: script ${scriptfile:t:r}";echo "test skipped"} >"Test/${scriptfile:t:r}/perlcritic.log"
+ continue
}
perlcritic --theme certrule --exclude RequireEndWithOne -2 scripts/${scriptfile:t:r}.pl >"Test/${scriptfile:t:r}/perlcritic.log" 2>&1
pushd Test
if [[ ! -s stderr.log ]] { rm -f stderr.log }
popd
printf . >&2
+ if [[ -n $GITHUB_ACTION ]] {
+ echo /$scriptfile >&2
+ }
popd
logs=(~/irc.log.*(N))
if [[ $#logs -gt 0 ]] {
scriptfiles=($(git diff --numstat --no-renames $TRAVIS_BRANCH|cut -f3|grep '^scripts/.*\.pl'))
IFS=$OIFS
if [[ $#scriptfiles -gt 0 ]] {
- filelist=($scriptfiles)
+ filelist=($scriptfiles)
}
} \
elif [[ $USE_ARTEFACTS_CACHE = yes ]] {
for scriptfile ($filelist) {
echo '--- '$scriptfile:t
if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] {
- echo "FATAL: SCRIPT FAILED TO LOAD "
- }
+ echo "FATAL: SCRIPT FAILED TO LOAD "
+ }
cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null
cat "Test/${scriptfile:t:r}/irssi.log"
- echo
- echo 'Source code critic:'
- cat "Test/${scriptfile:t:r}/perlcritic.log"
- echo
+ echo
+ echo 'Source code critic:'
+ cat "Test/${scriptfile:t:r}/perlcritic.log"
+ echo
}
echo
echo '======== YAML DATABASE ========'
for scriptfile ($filelist) {
if [[ ! -f "Test/${scriptfile:t:r}/failed.yml" ]] {
- cat "Test/${scriptfile:t:r}/info.yml"
- }
+ cat "Test/${scriptfile:t:r}/info.yml"
+ }
}
} \
else {
my %newmeta;
for my $file (<scripts/*.pl>) {
my ($filename, $base) =
- $file =~ m,^scripts/((.*)\.pl)$,;
+ $file =~ m,^scripts/((.*)\.pl)$,;
my $info_file = "Test/$base/info.yml";
my @cdoc;
if (-f $info_file && open my $ef, '<:utf8', $info_file) {
- local $@;
- @cdoc = eval { Load(do { local $/; <$ef> }); };
- if ($@) {
- print "ERROR $base: $@\n";
- @cdoc=();
- }
+ local $@;
+ @cdoc = eval { Load(do { local $/; <$ef> }); };
+ if ($@) {
+ print "ERROR $base: $@\n";
+ @cdoc=();
+ }
}
if (@cdoc) {
- $newmeta{$filename} = $cdoc[0][0];
- for my $copykey (qw(modified version)) {
- unless (defined $newmeta{$filename}{$copykey}) {
- $newmeta{$filename}{$copykey}
- = $oldmeta{$filename}{$copykey}
- if defined $oldmeta{$filename}{$copykey};
- }
- }
- $newmeta{$filename}{filename} = $filename;
- my $modules = delete $newmeta{$filename}{modules};
- $newmeta{$filename}{modules}
- = join ' ', @$modules
- if 'ARRAY' eq ref $modules;
- my $commands = delete $newmeta{$filename}{commands};
- my @commands = grep { !/ / } @$commands
- if 'ARRAY' eq ref $commands;
- $newmeta{$filename}{commands} = "@commands"
- if @commands;
+ $newmeta{$filename} = $cdoc[0][0];
+ for my $copykey (qw(modified version)) {
+ unless (defined $newmeta{$filename}{$copykey}) {
+ $newmeta{$filename}{$copykey}
+ = $oldmeta{$filename}{$copykey}
+ if defined $oldmeta{$filename}{$copykey};
+ }
+ }
+ $newmeta{$filename}{filename} = $filename;
+ my $modules = delete $newmeta{$filename}{modules};
+ $newmeta{$filename}{modules}
+ = join ' ', @$modules
+ if 'ARRAY' eq ref $modules;
+ my $commands = delete $newmeta{$filename}{commands};
+ my @commands = grep { !/ / } @$commands
+ if 'ARRAY' eq ref $commands;
+ $newmeta{$filename}{commands} = "@commands"
+ if @commands;
}
elsif (exists $oldmeta{$filename}) {
- print "META-INF FOR $base NOT FOUND\n";
- system "ls 'Test/$base/'*";
- $newmeta{$filename} = $oldmeta{$filename};
+ print "META-INF FOR $base NOT FOUND\n";
+ system "ls 'Test/$base/'*";
+ $newmeta{$filename} = $oldmeta{$filename};
}
else {
- print "MISSING META FOR $base\n";
+ print "MISSING META FOR $base\n";
}
}
my @newdoc = map {
my $changed;
my @wl;
for my $sf (@{$config->{whitelist}}) {
- if (-s "Test/$sf:passed") {
- $changed = 1;
- }
- else {
- push @wl, $sf;
- }
+ if (-s "Test/$sf:passed") {
+ $changed = 1;
+ }
+ else {
+ push @wl, $sf;
+ }
}
if ($changed) {
- $config->{whitelist} = \@wl;
- YAML::Tiny::DumpFile('_testing/config.yml', $config);
+ $config->{whitelist} = \@wl;
+ YAML::Tiny::DumpFile('_testing/config.yml', $config);
}
}
my %sc = %$sc;
#sleep 1;
my $res = p("https://$cred{user}:$cred{pass}\@api.github.com/repos/$cred{user}/scripts.irssi.org/issues/$issue/comments"
- => {Accept => "*/*"}
- => json
- => {
- body => "$sc{filename}\n---\n$sc{description}\n\nClick on  :+1: :-1: to add your votes"
- }
- );
+ => {Accept => "*/*"}
+ => json
+ => {
+ body => "$sc{filename}\n---\n$sc{description}\n\nClick on  :+1: :-1: to add your votes"
+ }
+ );
say $res->code;
unless ($res->code == 201) { say $res->body; exit 1; }
exit;