From: Ailin Nemui Date: Sun, 10 Sep 2023 17:04:43 +0000 (+0200) Subject: experimental python X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=de759eb98fece251ffb7184c0743c2997d288061;p=irssi-scripts.irssi.org.git experimental python --- diff --git a/.github/pm-perl-critic.json b/.github/pm-perl-critic.json new file mode 100644 index 0000000..c7407da --- /dev/null +++ b/.github/pm-perl-critic.json @@ -0,0 +1,28 @@ +{ + "problemMatcher": [ + { + "owner": "perl-critic", + "severity": "warning", + "pattern": [ + { + "regexp": "^(.*): (.*) at line (\\d+), column (\\d+)\\. (.*)\\. \\(Severity: \\d\\)$", + "file": 1, + "line": 3, + "column": 4, + "message": 2, + "code": 5 + } + ] + }, + { + "owner": "perl-critic-fail", + "pattern": [ + { + "regexp": "^(.*): (.*)\\. \\(Severity: \\d\\)$", + "file": 1, + "message": 2 + } + ] + } + ] +} diff --git a/.github/pm-perl-warning.json b/.github/pm-perl-warning.json new file mode 100644 index 0000000..9fbe1ef --- /dev/null +++ b/.github/pm-perl-warning.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "perl-warning", + "severity": "warning", + "pattern": [ + { + "regexp": "^([*] )?(.*) at (.*) line (\\d+)\\.$", + "file": 3, + "line": 4, + "message": 2 + } + ] + } + ] +} diff --git a/.github/pm-script-error.json b/.github/pm-script-error.json new file mode 100644 index 0000000..e5da014 --- /dev/null +++ b/.github/pm-script-error.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "script-error", + "pattern": [ + { + "regexp": ": Error in script ", + }, + { + "regexp": "^([*] )?(.*) at (.*) line (\\d+)\\.$", + "file": 3, + "line": 4, + "message": 2 + } + ] + } + ] +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7db8cb0..bda65f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,34 +5,18 @@ on: pull_request: name: Check Script env: - apt_build_deps: irssi-git-an cpanminus elinks zsh + apt_build_deps: irssi-git-an irssi-python3 cpanminus elinks flake8 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: - skip: - runs-on: ubuntu-latest - outputs: - skip: ${{ steps.ci-skip-step.outputs.ci-skip }} - skip-not: ${{ steps.ci-skip-step.outputs.ci-skip-not }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - id: ci-skip-step - uses: mstachniuk/ci-skip@v1 test: - needs: skip - if: ${{ needs.skip.outputs.skip == 'false' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@main with: fetch-depth: 0 - - uses: mstachniuk/ci-skip@v1 - with: - fail-fast: true - name: prepare required software run: | RELEASE=$(lsb_release -rs) @@ -40,28 +24,39 @@ jobs: curl -fsSL https://download.opensuse.org/repositories/home:ailin_nemui:irssi-git-an/xUbuntu_$RELEASE/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_ailin_nemui_irssi-git-an.gpg > /dev/null sudo apt -q update sudo apt -q install $apt_build_deps $apt_script_deps - - name: check Perl ver - id: perl-ver + - name: Setup flake8 annotations + uses: rbialon/flake8-annotations@master + if: ${{ github.event_name == 'pull_request' }} + - name: Setup local annotations + if: ${{ github.event_name == 'pull_request' }} + run: | + for pm in "$PWD"/.github/pm-*.json; do + echo "::add-matcher::$pm" + done + - name: check versions + id: ver run: | - echo ::set-output name=perl_version::$(perl -e'print $^V') + echo "perl_version=$(perl -e'print $^V')" | tee -a "$GITHUB_OUTPUT" + echo "python_version=$(python3 -c 'import platform; print(platform.python_version())')" | tee -a "$GITHUB_OUTPUT" + echo "irssi_version=$(irssi --version | awk '{print $2}')" | tee -a "$GITHUB_OUTPUT" - name: cache cpan - uses: actions/cache@v2 + uses: actions/cache@main with: path: | ~/extlib - key: ${{ runner.os }}-${{ steps.perl-ver.outputs.perl_version }}-cpan-${{ github.sha }}-${{ github.run_number }} + key: ${{ runner.os }}-${{ steps.ver.outputs.perl_version }}-cpan-${{ github.sha }}-${{ github.run_number }} restore-keys: | - ${{ runner.os }}-${{ steps.perl-ver.outputs.perl_version }}-cpan-${{ github.sha }}- - ${{ runner.os }}-${{ steps.perl-ver.outputs.perl_version }}-cpan- + ${{ runner.os }}-${{ steps.ver.outputs.perl_version }}-cpan-${{ github.sha }}- + ${{ runner.os }}-${{ steps.ver.outputs.perl_version }}-cpan- - name: fetch origin master branch if: ${{ github.event_name == 'pull_request' }} run: | - git fetch --depth=1 origin refs/heads/master + git fetch 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 + eval echo "\$v=\$$v" >> "$GITHUB_ENV" done - name: fix the broken Encode module run: | @@ -91,17 +86,23 @@ jobs: if: ${{ github.event_name == 'pull_request' }} run: | git diff --stat origin/master + MARKDOWN_REPORT=1 ./_testing/report-test.zsh >> "$GITHUB_STEP_SUMMARY" || : - name: test report run: | ./_testing/report-test.zsh || rc=$? - echo "SCRIPT_RC=${rc:-0}" >> $GITHUB_ENV + 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: show git changes + if: ${{ github.event_name == 'pull_request' }} + run: | + echo '```' >> "$GITHUB_STEP_SUMMARY" + git diff | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" - name: commit scripts.yaml if: ${{ github.event_name == 'push' }} run: | diff --git a/.gitignore b/.gitignore index a16c005..9a30a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ _site +Test/ *~ diff --git a/_testing/_get_files_arr.zsh b/_testing/_get_files_arr.zsh index 70108c2..c25e659 100644 --- a/_testing/_get_files_arr.zsh +++ b/_testing/_get_files_arr.zsh @@ -1,7 +1,4 @@ -if [[ $TRAVIS == true ]] { - . ./_testing/travis/_get_files_arr.zsh -} \ -elif [[ -n $GITHUB_ACTION ]] { +if [[ -n $GITHUB_ACTION ]] { . ./_testing/github/_get_files_arr.zsh } \ else { diff --git a/_testing/_irssi_test.pl b/_testing/_irssi_test.pl index c29cb7c..670c839 100644 --- a/_testing/_irssi_test.pl +++ b/_testing/_irssi_test.pl @@ -84,12 +84,12 @@ for my $rb (keys %info) { if (!%info || !defined $info{name}) { open my $ef, '>>', "perlcritic.log"; - print $ef 'No %IRSSI header in script or name not given. (Severity: 6)', "\n"; + print $ef "scripts/$CURRENT_SCRIPT.pl: ", 'No %IRSSI header in script or name not given. (Severity: 6)', "\n"; $info{name} //= $CURRENT_SCRIPT; } if (!defined $version) { open my $ef, '>>', "perlcritic.log"; - print $ef 'Missing $VERSION in script. (Severity: 6)', "\n"; + print $ef "scripts/$CURRENT_SCRIPT.pl: ", 'Missing $VERSION in script. (Severity: 6)', "\n"; } else { $info{version} = $version; @@ -103,5 +103,6 @@ if ($loginfo) { $info{modules} = \@modules if @modules; $info{commands} = \@commands if @commands; $info{default_package} = $package =~ s/::$//r if $package; +$info{language} = 'Perl'; YAML::Tiny::DumpFile("info.yml", [\%info]); Irssi::command('^window log off'); diff --git a/_testing/_irssi_test_py.pl b/_testing/_irssi_test_py.pl new file mode 100644 index 0000000..457ece1 --- /dev/null +++ b/_testing/_irssi_test_py.pl @@ -0,0 +1,77 @@ +use strict; +use warnings; + +my $CURRENT_SCRIPT = $ENV{CURRENT_SCRIPT}; +my $PWD = $ENV{PWD}; +my $SWD = "$PWD/../.."; + +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 + # and fall back to Latin-1. + 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 %existing_commands; +my (%info, $version, $package, @commands); +Irssi::command_bind('_irssi_test_py_cb' => sub { + my ($data, $server, $witem) = @_; + use JSON::PP; + my $doc = decode_json("$data"); + eval { %info = %{$doc->{'IRSSI'}} }; + eval { $version = $doc->{'VERSION'} }; + eval { $package = $doc->{'package'} }; + @commands = sort grep { !$existing_commands{$_} } map { $_->{cmd} } Irssi::commands; + }); + +%existing_commands = map { ($_->{cmd} => 1) } Irssi::commands; + +Irssi::command('^window log on'); +Irssi::command("py load $CURRENT_SCRIPT"); + +unless (defined $package) { + my %fail = (failed => 1, name => $CURRENT_SCRIPT); + YAML::Tiny::DumpFile("failed.yml", [\%fail]); + # TODO: Grep for the code instead +} +delete $info{''}; +for my $rb (keys %info) { + delete $info{$rb} unless defined $info{$rb}; +} + +if (!%info || !defined $info{name}) { + open my $ef, '>>', "perlcritic.log"; + print $ef "scripts/$CURRENT_SCRIPT.py: ", 'No IRSSI header in script or name not given. (Severity: 6)', "\n"; + $info{name} //= $CURRENT_SCRIPT; +} +if (!defined $version) { + open my $ef, '>>', "perlcritic.log"; + print $ef "scripts/$CURRENT_SCRIPT.py: ", 'Missing __version__ in script. (Severity: 6)', "\n"; +} +else { + $info{version} = $version; +} +chomp(my $loginfo = `git log 2d0759e6... -1 --format=%ai -- "$SWD/scripts/$CURRENT_SCRIPT.py" 2>/dev/null || +git log -1 --format=%d%m%ai -- "$SWD/scripts/$CURRENT_SCRIPT.py" | grep -v grafted | cut -d'>' -f2`); +if ($loginfo) { + my ($date, $time) = split ' ', $loginfo; + $info{modified} = "$date $time"; +} +#$info{modules} = \@modules if @modules; +$info{commands} = \@commands if @commands; +$info{default_package} = $package if $package; +$info{language} = 'Python'; +YAML::Tiny::DumpFile("info.yml", [\%info]); +Irssi::command('^window log off'); diff --git a/_testing/config.yml b/_testing/config.yml index 1eda785..111f043 100644 --- a/_testing/config.yml +++ b/_testing/config.yml @@ -9,6 +9,7 @@ scripts_yaml_keys: - description - license # optional + - language - url - commands - note diff --git a/_testing/github/_get_files_arr.zsh b/_testing/github/_get_files_arr.zsh index 03b3974..1ac2e05 100644 --- a/_testing/github/_get_files_arr.zsh +++ b/_testing/github/_get_files_arr.zsh @@ -1,8 +1,11 @@ -filelist=(scripts/*.pl) +script_pattern='^scripts/.*\.\(pl\|py\)$' +OIFS=$IFS; IFS=$'\n' +filelist=($(find scripts -type f | grep $script_pattern)) +IFS=$OIFS if [[ $GITHUB_REF != refs/heads/master ]] { local -a scriptfiles OIFS=$IFS; IFS=$'\n' - scriptfiles=($(git diff --numstat --no-renames origin/master|cut -f3|grep '^scripts/.*\.pl')) + scriptfiles=($(git diff --numstat --no-renames origin/master | cut -f3 | grep $script_pattern)) IFS=$OIFS if [[ $#scriptfiles -gt 0 ]] { filelist=($scriptfiles) @@ -11,7 +14,7 @@ if [[ $GITHUB_REF != refs/heads/master ]] { elif [[ $USE_ARTEFACTS_CACHE = yes ]] { local -a cache_allowed OIFS=$IFS; IFS=$'\n' - cache_allowed=(scripts/${^$(grep -v __ARTEFACTS_CI__ old-artefacts/can-use-cache | cut -f2- -d\ )}) + cache_allowed=(scripts/${^$(grep -v __ARTEFACTS_CI__ old-artefacts/can-use-cache | cut -f2- -d' ')}) IFS=$OIFS if [[ $REPORT_STAGE == yes ]] { diff --git a/_testing/github/load-old-artefacts.zsh b/_testing/github/load-old-artefacts.zsh index 211d281..c888e72 100755 --- a/_testing/github/load-old-artefacts.zsh +++ b/_testing/github/load-old-artefacts.zsh @@ -1,6 +1,6 @@ #!/bin/zsh echo $(git log --format=%H -1 _testing .github) __ARTEFACTS_CI__>old-artefacts/new-changed-info -for f (scripts/*.pl) { +for f (scripts/*.pl(N) scripts/*.py(N)) { echo $(git hash-object $f) ${f:t} >>old-artefacts/new-changed-info } grep -sxFf old-artefacts/new-changed-info old-artefacts/changed-info >old-artefacts/can-use-cache diff --git a/_testing/github/show-failures.zsh b/_testing/github/show-failures.zsh index 50ef4ea..aeadf39 100755 --- a/_testing/github/show-failures.zsh +++ b/_testing/github/show-failures.zsh @@ -2,6 +2,10 @@ . ./_testing/_get_files_arr.zsh +root_script() { + perl -p -e 's{ at ([^/\s]*) line (\d+)}{ at scripts/$1 line $2}g' +} + if [[ $GITHUB_REF != refs/heads/master ]] { echo '======== INTEGRATION REPORT =========' for scriptfile ($filelist) { @@ -9,11 +13,12 @@ if [[ $GITHUB_REF != refs/heads/master ]] { if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] { echo "FATAL: SCRIPT FAILED TO LOAD " } - cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null - cat "Test/${scriptfile:t:r}/irssi.log" + cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null | root_script + cat "Test/${scriptfile:t:r}/irssi.log" | root_script echo echo 'Source code critic:' - cat "Test/${scriptfile:t:r}/perlcritic.log" + cat "Test/${scriptfile:t:r}/perlcritic.log" 2>/dev/null + cat "Test/${scriptfile:t:r}/flake8.log" 2>/dev/null echo } echo @@ -29,8 +34,8 @@ else { for scriptfile ($filelist) { if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] { echo '--- '$scriptfile:t - cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null - cat "Test/${scriptfile:t:r}/irssi.log" + cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null | root_script + cat "Test/${scriptfile:t:r}/irssi.log" | root_script echo } } diff --git a/_testing/report-test.zsh b/_testing/report-test.zsh index 37a49c6..89af36f 100755 --- a/_testing/report-test.zsh +++ b/_testing/report-test.zsh @@ -53,14 +53,18 @@ for scriptfile ($filelist) { # CRIT if { grep -qs 'Code before strictures are enabled\|Two-argument "open" used' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$failmark' ' } \ + elif { grep -qs ': \(E9\|F63\|F7\|F82\)' "Test/${scriptfile:t:r}/flake8.log" } { print -n ' '$failmark' ' } \ elif { grep -qs 'command not found:' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$skipmark' ' } \ else { print -n ' '$passmark' '; ((++pass)) }; print -n $T # SCORE - perl -ne '$score += $1 -1 if /Severity: (\d+)/; END { printf "%3d", $score }' "Test/${scriptfile:t:r}/perlcritic.log" 2>/dev/null + perl -ne 'BEGIN { @fl = ("E9|F63|F7|F82" => 5, "F[0-9]" => 4, "E[0-9]" => 3, "[CW][0-9]" => 2, "N[0-9]" => 1) } + $score += $1 -1 if /Severity: (\d+)/; + for ($i = 0; $i < @fl; $i += 2) { if (/\d: $fl[$i]/) { $score += $fl[$i + 1]; last } } + END { printf "%3d", $score }' "Test/${scriptfile:t:r}/perlcritic.log" "Test/${scriptfile:t:r}/flake8.log" 2>/dev/null print -n ' '$T if [[ $pass -lt 3 ]] { - if [[ -n $allow_fail[$scriptfile:t:r] ]] || [[ ! -f scripts/${scriptfile:t:r}.pl ]] { + if [[ -n $allow_fail[$scriptfile:t:r] ]] || { [[ ! -f scripts/${scriptfile:t:r}.pl ]] && [[ ! -f scripts/${scriptfile:t:r}.py ]] } { print -n ' '$skipmark' ' } \ else { diff --git a/_testing/run-test.zsh b/_testing/run-test.zsh index 6eb0634..f33259d 100755 --- a/_testing/run-test.zsh +++ b/_testing/run-test.zsh @@ -1,6 +1,7 @@ #!/bin/zsh local base_path="`pwd`" local test_script="$base_path/_testing/_irssi_test.pl" +local test_script_py="$base_path/_testing/_irssi_test_py.pl" if [[ $(perl -MEncode -e'print $Encode::VERSION') == 2.88 ]] { echo "Broken Encode version (2.88). Please update the Perl Encode module." @@ -9,21 +10,7 @@ if [[ $(perl -MEncode -e'print $Encode::VERSION') == 2.88 ]] { . ./_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 - } - perlcritic --theme certrule --exclude RequireEndWithOne -2 scripts/${scriptfile:t:r}.pl >"Test/${scriptfile:t:r}/perlcritic.log" 2>&1 - pushd Test - rm -fr .home - mkdir .home - ln -s ../../scripts .home - local filename="$base_path/$scriptfile" - <.home/startup -^set settings_autosave off +COMMON_STARTUP='^set settings_autosave off ^set use_status_window off ^set autocreate_windows off ^set -clear autocreate_query_level @@ -36,13 +23,9 @@ for scriptfile ($filelist) { ^load irc ^load dcc ^load flood -^load notifylist -^load perl -^load otr -^script exec \$\$^W = 1 -run ${(qqq)test_script} -^quit -STARTUP +^load notifylist' + +test_common() { pushd ${scriptfile:t:r} env TERM=xterm CURRENT_SCRIPT="$scriptfile:t:r" irssi --home="$base_path/Test/.home" >/dev/null 2>stderr.log if [[ ! -s stderr.log ]] { rm -f stderr.log } @@ -52,13 +35,86 @@ STARTUP echo /$scriptfile >&2 } popd + perl -i -pe ' +s,\Q$ENV{PWD}/Test/.home/scripts/\E,,g; +s,\Q$ENV{PWD}/Test/.home\E,..,g; +s,\Q$ENV{PWD}\E,...,g; +s,\(\@INC contains: .*?\),,g' "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null logs=(~/irc.log.*(N)) if [[ $#logs -gt 0 ]] { - perl -i -pe 's,\Q$ENV{PWD}/Test/.home/scripts/\E,,g;s,\Q$ENV{PWD}/Test/.home\E,..,g;s,\Q$ENV{PWD}\E,...,g;s,\(\@INC contains: .*?\),,g' $logs + perl -i -pe ' +s,\Q$ENV{PWD}/Test/.home/scripts/\E,,g; +s,\Q$ENV{PWD}/Test/.home\E,..,g; +s,\Q$ENV{PWD}\E,...,g; +s,\(\@INC contains: .*?\),,g' $logs mv $logs "Test/${scriptfile:t:r}/irssi.log" } \ elif [[ -f stderr.log ]] { cat stderr.log } } + +test_perl() { + perlcritic --theme certrule --exclude RequireEndWithOne -2 --verbose 5 scripts/${scriptfile:t:r}.pl >"Test/${scriptfile:t:r}/perlcritic.log" 2>&1 + pushd Test + rm -fr .home + mkdir .home + ln -s ../../scripts .home + local filename="$base_path/$scriptfile" + <.home/startup +$COMMON_STARTUP +^load perl +^load otr +^script exec \$\$^W = 1 +run ${(qqq)test_script} +^quit +STARTUP + test_common +} + +test_python() { + flake8 --exit-zero --max-complexity=10 --max-line-length=127 --statistics --show-source scripts/${scriptfile:t:r}.py >"Test/${scriptfile:t:r}/flake8.log" 2>&1 + pushd Test + rm -fr .home + mkdir .home + mkdir .home/scripts + cat ../scripts/${scriptfile:t:r}.py > .home/scripts/${scriptfile:t:r}.py + <>.home/scripts/${scriptfile:t:r}.py + +# added by run-test.zsh for _irssi_test_py.pl +import json as __test_json +import irssi as __test_irssi +__test_irssi.command(b'^_irssi_test_py_cb ' + __test_json.dumps({'IRSSI': globals().get('IRSSI'), 'VERSION': globals().get('__version__'), 'package': globals().get('__name__')}).encode('utf-8')) + +CB + local filename="$base_path/$scriptfile" + <.home/startup +$COMMON_STARTUP +^load perl +^load python +^load otr +run ${(qqq)test_script_py} +^quit +STARTUP + test_common +} + +for scriptfile ($filelist) { + if [[ -f scripts/${scriptfile:t:r}.pl ]] && [[ -f scripts/${scriptfile:t:r}.py ]] { + echo "cannot have both ${scriptfile:t:r}.pl and ${scriptfile:t:r}.py" >&2 + exit 1 + } + rm -rf "Test/${scriptfile:t:r}" + mkdir -p "Test/${scriptfile:t:r}" + if [[ -f scripts/${scriptfile:t:r}.pl ]] { + test_perl + } \ + elif [[ -f scripts/${scriptfile:t:r}.py ]] { + test_python + } \ + else { + {echo "command not found: script ${scriptfile:t:r}";echo "test skipped"} >"Test/${scriptfile:t:r}/perlcritic.log" + continue + } +} exit 0 diff --git a/_testing/travis/_get_files_arr.zsh b/_testing/travis/_get_files_arr.zsh deleted file mode 100644 index 98086d7..0000000 --- a/_testing/travis/_get_files_arr.zsh +++ /dev/null @@ -1,27 +0,0 @@ -filelist=(scripts/*.pl) -if [[ $TRAVIS_PULL_REQUEST != false ]] { - local -a scriptfiles - OIFS=$IFS; IFS=$'\n' - scriptfiles=($(git diff --numstat --no-renames $TRAVIS_BRANCH|cut -f3|grep '^scripts/.*\.pl')) - IFS=$OIFS - if [[ $#scriptfiles -gt 0 ]] { - filelist=($scriptfiles) - } -} \ -elif [[ $USE_ARTEFACTS_CACHE = yes ]] { - local -a cache_allowed - OIFS=$IFS; IFS=$'\n' - cache_allowed=(scripts/${^$(grep -v __ARTEFACTS_CI__ old-artefacts/can-use-cache | cut -f2- -d\ )}) - IFS=$OIFS - - if [[ $REPORT_STAGE == yes ]] { - autoload -Uz zargs - mkdir -p Test - { zargs -r -- old-artefacts/Test/${^cache_allowed:t:r} -- mv -nt Test } 2>/dev/null - cached_run=($cache_allowed) - } \ - else { - # is-at-least 5.0.0 - filelist=(${filelist:|cache_allowed}) - } -} diff --git a/_testing/travis/commit-scripts-yaml.zsh b/_testing/travis/commit-scripts-yaml.zsh deleted file mode 100755 index 07157db..0000000 --- a/_testing/travis/commit-scripts-yaml.zsh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/zsh - -[[ -z $REPO_LOGIN_TOKEN ]] && exit -[[ -z $TRAVIS_REPO_SLUG ]] && exit - -echo "https://${REPO_LOGIN_TOKEN}:x-oauth-basic@github.com" > "$HOME/.git-credentials" - -git config user.email "scripts@irssi.org" -git config user.name "Irssi Scripts Helper" -git config credential.helper store -git config remote.origin.url "https://github.com/$TRAVIS_REPO_SLUG" -git checkout "$TRAVIS_BRANCH" - -if [[ "$(git log -1 --format=%an)" != "$(git config user.name)" && - "$(git log -1 --format=%cn)" != "$(git config user.name)" ]] { - git add _data/scripts.yaml - git commit -m "automatic scripts database update for $TRAVIS_COMMIT - -[skip ci]" - git config push.default simple - git push origin -} diff --git a/_testing/travis/extract-artefacts.zsh b/_testing/travis/extract-artefacts.zsh deleted file mode 100755 index 98bd34b..0000000 --- a/_testing/travis/extract-artefacts.zsh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/zsh -if [[ -z $REPO_LOGIN_TOKEN || -z $TRAVIS_REPO_SLUG ]] { exit 1 } -autoload -Uz zargs - -if { ! git clone -b ci-artefacts https://github.com/$TRAVIS_REPO_SLUG artefacts } { - mkdir artefacts && git init artefacts - pushd artefacts - git remote add origin https://github.com/$TRAVIS_REPO_SLUG - git checkout -b ci-artefacts - popd -} - -pushd artefacts -git config user.email "scripts@irssi.org" -git config user.name "Irssi Scripts Helper" -git config credential.helper store - -git rm -qrf . - -echo "This branch stores the travis-ci results for $TRAVIS_REPO_SLUG -See [the testing read-me](../master/_testing/) for details." > README.markdown -pushd .. -MARKDOWN_REPORT=1 ./_testing/report-test.zsh >> artefacts/README.markdown -popd -echo >> README.markdown -echo "$TRAVIS_COMMIT | $TRAVIS_BUILD_NUMBER" >> README.markdown - -mv ../Test . -rm -fr Test/.home -zargs -r -- Test/*/passed(N) -- rm -if [[ $USE_ARTEFACTS_CACHE == yes ]] { - mv ../old-artefacts/new-changed-info changed-info -} - -git add . -git commit -q -m "ci artefacts for $TRAVIS_COMMIT - -[skip ci]" - -git push -u origin ci-artefacts diff --git a/_testing/travis/load-old-artefacts.zsh b/_testing/travis/load-old-artefacts.zsh deleted file mode 100755 index f28e38f..0000000 --- a/_testing/travis/load-old-artefacts.zsh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/zsh -if { ! git clone -q --depth 1 -b ci-artefacts git://github.com/$TRAVIS_REPO_SLUG.git old-artefacts } { - mkdir old-artefacts -} -echo $(git log --format=%H -1 _testing .travis.yml) __ARTEFACTS_CI__>old-artefacts/new-changed-info -for f (scripts/*.pl) { - echo $(git hash-object $f) ${f:t} >>old-artefacts/new-changed-info -} -grep -sxFf old-artefacts/new-changed-info old-artefacts/changed-info >old-artefacts/can-use-cache -if { ! grep -q __ARTEFACTS_CI__ old-artefacts/can-use-cache } { - :>|old-artefacts/can-use-cache -} diff --git a/_testing/travis/show-failures.zsh b/_testing/travis/show-failures.zsh deleted file mode 100755 index 1c5be14..0000000 --- a/_testing/travis/show-failures.zsh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/zsh - -. ./_testing/_get_files_arr.zsh - -if [[ $TRAVIS_PULL_REQUEST != false ]] { - echo '======== INTEGRATION REPORT =========' - for scriptfile ($filelist) { - echo '--- '$scriptfile:t - if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] { - 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 '======== YAML DATABASE ========' - for scriptfile ($filelist) { - if [[ ! -f "Test/${scriptfile:t:r}/failed.yml" ]] { - cat "Test/${scriptfile:t:r}/info.yml" - } - } -} \ -else { - echo '============= DETAILED FAILURE REPORTS =============' - for scriptfile ($filelist) { - if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] { - echo '--- '$scriptfile:t - cat "Test/${scriptfile:t:r}/stderr.log" 2>/dev/null - cat "Test/${scriptfile:t:r}/irssi.log" - echo - } - } -} diff --git a/_testing/update-scripts-yaml.pl b/_testing/update-scripts-yaml.pl index 04228e4..91c837a 100644 --- a/_testing/update-scripts-yaml.pl +++ b/_testing/update-scripts-yaml.pl @@ -19,9 +19,9 @@ for (@{$docs[0]//[]}) { } my %newmeta; -for my $file () { - my ($filename, $base) = - $file =~ m,^scripts/((.*)\.pl)$,; +for my $file () { + my ($filename, $base, $ext) = + $file =~ m,^scripts/((.*)\.(pl|py))$,; my $info_file = "Test/$base/info.yml"; my @cdoc; if (-f $info_file && open my $ef, '<:utf8', $info_file) { diff --git a/index.html b/index.html index 1a1cec0..2bc10c8 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,12 @@ layout: default
How do I submit a script to this page?
See information on how to contribute here.
+ +
Important. + Python script support on this page is experimental.
+
For .py scripts, the irssi-python3 + module needs to be installed. To run them, use + /py load scriptname .

Manual instructions for using scripts

@@ -64,6 +70,12 @@ layout: default
How do I submit a script to this page?
See information on how to contribute here.
+ +
Important. + Python script support on this page is experimental.
+
For .py scripts, the irssi-python3 + module needs to be installed. To run them, use + /py load scriptname .