]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
GitHub Actions
authorailin-nemui <redacted>
Sun, 31 Mar 2019 10:35:53 +0000 (12:35 +0200)
committerAilin Nemui <redacted>
Wed, 24 Apr 2019 11:47:35 +0000 (13:47 +0200)
Implement Github Actions workflow of the travis config

15 files changed:
.github/actions.yml [new file with mode: 0644]
.github/main.workflow [new file with mode: 0644]
.travis.yml
_testing/README.markdown
_testing/_get_files_arr.zsh
_testing/autoinstall-perl-prereqs.zsh [moved from _testing/travis/autoinstall-perl-prereqs.zsh with 100% similarity]
_testing/github/_get_files_arr.zsh [new file with mode: 0644]
_testing/github/commit-scripts-yaml.zsh [new file with mode: 0755]
_testing/github/extract-artefacts.zsh [new file with mode: 0755]
_testing/github/load-old-artefacts.zsh [new file with mode: 0755]
_testing/github/show-failures.zsh [new file with mode: 0755]
_testing/run-test.zsh
_testing/travis/commit-scripts-yaml.zsh [new file with mode: 0755]
_testing/update-scripts-yaml.pl [moved from _testing/travis/update-scripts-yaml.pl with 100% similarity]
_tools/add_script_vote_comment.pl

diff --git a/.github/actions.yml b/.github/actions.yml
new file mode 100644 (file)
index 0000000..cb88d59
--- /dev/null
@@ -0,0 +1,52 @@
+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
diff --git a/.github/main.workflow b/.github/main.workflow
new file mode 100644 (file)
index 0000000..94cf6f2
--- /dev/null
@@ -0,0 +1,62 @@
+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"
+}
index a177382dbba6d55609f82e7ac4afa6e23d4fc294..386edef6714eda2b45864e9b829cd615b6bda1d2 100644 (file)
@@ -40,7 +40,7 @@ install:
 - env -u REPO_LOGIN_TOKEN
   cpanm --quiet --installdeps --notest .
 - env -u REPO_LOGIN_TOKEN
-  ./_testing/travis/autoinstall-perl-prereqs.zsh
+  ./_testing/autoinstall-perl-prereqs.zsh
 - |
   pushd auto
   env -u REPO_LOGIN_TOKEN cpanm --quiet --installdeps --notest .
@@ -61,7 +61,8 @@ after_script:
   ./_testing/travis/show-failures.zsh
 - |
   if [ $TRAVIS_PULL_REQUEST = false ] && $TRAVIS_SECURE_ENV_VARS; then
-    perl ./_testing/travis/update-scripts-yaml.pl
+    env -u REPO_LOGIN_TOKEN perl ./_testing/update-scripts-yaml.pl
+    ./_testing/travis/commit-scripts-yaml.zsh
   fi
 - |
   if [ $TRAVIS_PULL_REQUEST = false ] && $TRAVIS_SECURE_ENV_VARS && [ $EXTRACT_TEST_ARTEFACTS = yes ]; then
index c3480bce27f9aba9d65cdc0ae51f791b2543e524..4eabf6b70090f1ecacf11c6d8b503542fa7dd4ae 100644 (file)
@@ -70,7 +70,7 @@ The following keys are recognised in config.yml:
 
 To manually generate the _data/scripts.yaml file, run:
 
-    perl ./_testing/travis/update-scripts-yaml.pl
+    perl ./_testing/update-scripts-yaml.pl
 
 To download the cached test results, run:
 
index 6c8670e2141b2cc1e6e7df27684915e6ad73ebb9..70108c29e6cff0805b7c381b79b68ccb44fa8b9b 100644 (file)
@@ -1,6 +1,9 @@
 if [[ $TRAVIS == true ]] {
     . ./_testing/travis/_get_files_arr.zsh
 } \
+elif [[ -n $GITHUB_ACTION ]] {
+    . ./_testing/github/_get_files_arr.zsh
+} \
 else {
     filelist=($@)
 }
diff --git a/_testing/github/_get_files_arr.zsh b/_testing/github/_get_files_arr.zsh
new file mode 100644 (file)
index 0000000..384a952
--- /dev/null
@@ -0,0 +1,27 @@
+filelist=(scripts/*.pl)
+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'))
+    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/github/commit-scripts-yaml.zsh b/_testing/github/commit-scripts-yaml.zsh
new file mode 100755 (executable)
index 0000000..947655e
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/zsh
+
+[[ -z $GITHUB_TOKEN ]] && exit
+
+git config user.email "scripts@irssi.org"
+git config user.name "Irssi Scripts Helper"
+git checkout master
+git config -l --show-origin
+
+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 $GITHUB_SHA
+
+[skip ci]"
+    git config push.default simple
+    git push --set-upstream origin master
+}
diff --git a/_testing/github/extract-artefacts.zsh b/_testing/github/extract-artefacts.zsh
new file mode 100755 (executable)
index 0000000..f43f32e
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/zsh
+if [[ -z $GITHUB_TOKEN || -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 rm -qrf .
+
+echo "This branch stores the Github Actions results for $GITHUB_REPOSITORY
+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 "$GITHUB_SHA | $(date -Ins)" >> 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 $GITHUB_SHA
+
+[skip ci]"
+
+git push -u origin ci-artefacts
diff --git a/_testing/github/load-old-artefacts.zsh b/_testing/github/load-old-artefacts.zsh
new file mode 100755 (executable)
index 0000000..2beecab
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/zsh
+if { ! git clone -q --depth 1 -b ci-artefacts git://github.com/$GITHUB_REPOSITORY.git old-artefacts } {
+   mkdir old-artefacts
+}
+echo $(git log --format=%H -1 _testing .github) __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/github/show-failures.zsh b/_testing/github/show-failures.zsh
new file mode 100755 (executable)
index 0000000..95670fc
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/zsh
+
+. ./_testing/_get_files_arr.zsh
+
+if [[ $GITHUB_REF != refs/heads/master ]] {
+    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 11ef11622a4e1ad7156a06b990f1eb74d150e36a..6191d12c5e56eeb569a2ca3aa660f3eae705ffbc 100755 (executable)
@@ -39,7 +39,13 @@ STARTUP
     popd
     printf . >&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' ~/irc.log.*
-    mv ~/irc.log.* "Test/${scriptfile:t:r}/irssi.log"
+    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
+        mv $logs "Test/${scriptfile:t:r}/irssi.log"
+    } \
+    elif [[ -f stderr.log ]] {
+        cat stderr.log
+    }
 }
 exit 0
diff --git a/_testing/travis/commit-scripts-yaml.zsh b/_testing/travis/commit-scripts-yaml.zsh
new file mode 100755 (executable)
index 0000000..6ef54a9
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/zsh
+
index 4fba2f5173432eebee0c218e6e5b68e1493ce2e1..272ba6f6af73d9c8cd3231f2971d7e83b1869ee2 100755 (executable)
@@ -71,7 +71,7 @@ for my $sc (sort { $a->{modified} cmp $b->{modified} } @$x) {
                => {Accept => "*/*"}
                => json
                => {
-                   body => "$sc{filename}\n---\n$sc{description}\n\nClick on +😃  to add your votes"
+                   body => "$sc{filename}\n---\n$sc{description}\n\nClick on ![+😃](https://user-images.githubusercontent.com/5665186/52212818-af6a7480-288d-11e9-9e48-4822b0a8efce.png) :+1: :-1: to add your votes"
                }
               );
     say $res->code;
git clone https://git.99rst.org/PROJECT