]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
experimental python
authorAilin Nemui <redacted>
Sun, 10 Sep 2023 17:04:43 +0000 (19:04 +0200)
committerAilin Nemui <redacted>
Sun, 24 Sep 2023 20:39:41 +0000 (22:39 +0200)
21 files changed:
.github/pm-perl-critic.json [new file with mode: 0644]
.github/pm-perl-warning.json [new file with mode: 0644]
.github/pm-script-error.json [new file with mode: 0644]
.github/workflows/test.yml
.gitignore
_testing/_get_files_arr.zsh
_testing/_irssi_test.pl
_testing/_irssi_test_py.pl [new file with mode: 0644]
_testing/config.yml
_testing/github/_get_files_arr.zsh
_testing/github/load-old-artefacts.zsh
_testing/github/show-failures.zsh
_testing/report-test.zsh
_testing/run-test.zsh
_testing/travis/_get_files_arr.zsh [deleted file]
_testing/travis/commit-scripts-yaml.zsh [deleted file]
_testing/travis/extract-artefacts.zsh [deleted file]
_testing/travis/load-old-artefacts.zsh [deleted file]
_testing/travis/show-failures.zsh [deleted file]
_testing/update-scripts-yaml.pl
index.html

diff --git a/.github/pm-perl-critic.json b/.github/pm-perl-critic.json
new file mode 100644 (file)
index 0000000..c7407da
--- /dev/null
@@ -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 (file)
index 0000000..9fbe1ef
--- /dev/null
@@ -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 (file)
index 0000000..e5da014
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "problemMatcher": [
+    {
+      "owner": "script-error",
+      "pattern": [
+       {
+         "regexp": ": Error in script ",
+       },
+       {
+         "regexp": "^([*] )?(.*) at (.*) line (\\d+)\\.$",
+         "file": 3,
+         "line": 4,
+         "message": 2
+       }
+      ]
+    }
+  ]
+}
index 7db8cb0f2274284251f0f8456dc75976175621fd..bda65f89f9315d0a2adbc6ed7585026495d0b243 100644 (file)
@@ -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: |
index a16c005dfbfbe345fb650213a88e5a7433a5f922..9a30a0b22d97df78d53394886aa6e94e43c27bf6 100644 (file)
@@ -1,2 +1,3 @@
 _site
+Test/
 *~
index 70108c29e6cff0805b7c381b79b68ccb44fa8b9b..c25e659c65688819162388ec03bcba8e11f1628a 100644 (file)
@@ -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 {
index c29cb7cd9a37419fd6d7c745b51f38de5380fb08..670c839404d66f848c945dcb850067aa9c509bc5 100644 (file)
@@ -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 (file)
index 0000000..457ece1
--- /dev/null
@@ -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');
index 1eda785a59cc79bf0adcf7a76af8929821ab7687..111f0437ceb40aae5bbec587a7f8c2e56f240d80 100644 (file)
@@ -9,6 +9,7 @@ scripts_yaml_keys:
   - description
   - license
   # optional
+  - language
   - url
   - commands
   - note
index 03b397492d236c77da9a27c4405b31babe513b21..1ac2e053cba629a76b79cfa6293dab8f6eb81ad1 100644 (file)
@@ -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 ]] {
index 211d281344ef4a4b012d431b7b85391ccdd55bd0..c888e7230f74cb7373da80f82e07f30fc1dba0fd 100755 (executable)
@@ -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
index 50ef4ea279b2fb9979be19d7755b50e3fea9e375..aeadf39c0e8464d9abf196e43c6a20377e21418b 100755 (executable)
@@ -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
         }
     }
index 37a49c6585b73e543cead0ba24d975ec1cb89e12..89af36f78314f51daa79e90878728fe2876d7948 100755 (executable)
@@ -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 {
index 6eb0634929d245eea7de8df35c549c348429f60e..f33259d4e7f49b3103d3b43e9070576a8df1d285 100755 (executable)
@@ -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"
-    <<STARTUP>.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"
+    <<STARTUP>.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
+    <<CB>>.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"
+    <<STARTUP>.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 (file)
index 98086d7..0000000
+++ /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 (executable)
index 07157db..0000000
+++ /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 (executable)
index 98bd34b..0000000
+++ /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 (executable)
index f28e38f..0000000
+++ /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 (executable)
index 1c5be14..0000000
+++ /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
-        }
-    }
-}
index 04228e47b34bfafebe7ca3055c550bbf59650254..91c837a13a96b63c0df051751b06556acdae0e19 100644 (file)
@@ -19,9 +19,9 @@ for (@{$docs[0]//[]}) {
 }
 
 my %newmeta;
-for my $file (<scripts/*.pl>) {
-    my ($filename, $base) =
-        $file =~ m,^scripts/((.*)\.pl)$,;
+for my $file (<scripts/*.pl scripts/*.py>) {
+    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) {
index 1a1cec08057063afdb75f09d4d2e0f99902438e6..2bc10c8961add25d3d20578a7f7ded2e07449149 100644 (file)
@@ -34,6 +34,12 @@ layout: default
 
                 <dt>How do I submit a script to this page?</dt>
                 <dd>See information on how to contribute <a href="https://github.com/irssi/scripts.irssi.org">here</a>.</dd>
+
+                <dt><span class="bg-danger text-danger" style="display: inline-block; padding: 0 2px; border-radius: 4px">Important.
+                  </span> Python script support on this page is experimental.</dt>
+                <dd>For .py scripts, the <a href="//irssi.org/modules/#scripting-languages"><code>irssi-python3</code>
+                    module</a> needs to be installed. To run them, use
+                  <code><b>/py</b> load <i>scriptname</i></code> .</dd>
             </dl>
             <h4>Manual instructions for using scripts</h4>
             <dl class="manual-instructions">
@@ -64,6 +70,12 @@ layout: default
 
                 <dt>How do I submit a script to this page?</dt>
                 <dd>See information on how to contribute <a href="https://github.com/irssi/scripts.irssi.org">here</a>.</dd>
+
+                <dt><span class="bg-danger text-danger" style="display: inline-block; padding: 0 2px; border-radius: 4px">Important.
+                  </span> Python script support on this page is experimental.</dt>
+                <dd>For .py scripts, the <a href="//irssi.org/modules/#scripting-languages"><code>irssi-python3</code>
+                    module</a> needs to be installed. To run them, use
+                  <code><b>/py</b> load <i>scriptname</i></code> .</dd>
             </dl>
         </div>
         <hr>
git clone https://git.99rst.org/PROJECT