[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-cvs
Subject:    [LyX/master] Add script for CI job to check git log for non @lyx.org-adressses
From:       Christian Ridderström <chr () lyx ! org>
Date:       2017-07-30 18:29:30
Message-ID: 20170730182930.4510C2807CD () lyx ! lyx ! org
[Download RAW message or body]

commit 601f70f8fe6e2094a1ec5b71c25a93579ab1e6f8
Author: Christian Ridderström <chr@lyx.org>
Date:   Sun Jul 30 20:28:42 2017 +0200

    Add script for CI job to check git log for non @lyx.org-adressses
    
    The idea is to let a CI job regurlarly invoke this script in order to
    check that there hasn't been any new commits where the author of the
    commit doesn't have an @lyx.org e-mail address.  If this is the case,
    the CI job is expected to fail and a warning e-mail will be sent to
    lyx-devel@lists.lyx.org.
---
 development/CI/README                              |    5 +
 ...eck_git_log_for_unrecognised_email_addresses.sh |   93 ++++++++++++++++++++
 2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/development/CI/README b/development/CI/README
new file mode 100644
index 0000000..3b21f29
--- /dev/null
+++ b/development/CI/README
@@ -0,0 +1,5 @@
+This folder and its subfolders are used by LyX's continuous integration (CI) system.
+
+Structure:
+- bin/ :: Contains scripts used by CI jobs
+
diff --git a/development/CI/bin/check_git_log_for_unrecognised_email_addresses.sh \
b/development/CI/bin/check_git_log_for_unrecognised_email_addresses.sh new file mode \
100755 index 0000000..d6ca547
--- /dev/null
+++ b/development/CI/bin/check_git_log_for_unrecognised_email_addresses.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+#
+#
+CMD=$1
+SINCE_DATE=2015-01-01
+FORMAT='%h %ai name=%an email=%ae'
+SCRIPT=$0
+
+function show_help() {
+    cat <<EOF
+SCRIPT=$SCRIPT
+
+This script filters the git log for commits whose
+author's e-mail is _not_ on @lyx.org.
+
+This script can be used to check that the LyX developers have
+correctly configured their git to provide an e-mail address that's in
+the @lyx.org domain. This is needed for proper functioning of the
+e-mails being automatically sent to lyx-cvs@lyx.org.
+
+Examples:
+	# List contributions from non-@lyx.org-addresses since 2015-01-01
+	$SCRIPT --list
+
+    # Compute hash (SHA-512) of list of contributors
+	$SCRIPT --compute-hash
+
+    # Check hash of list of contributors against expected hash.
+    # This scripts exist with a non-zero error code if hash does not match.
+	$SCRIPT --check-hash \
+        1330d9fca5e385e9de8933cbf6d391222207b2f6af1cf7ca3175babfd4e5ab46b024ff2d98c7c8630b362be506da9376f9262a524755f9acf655d83dcce8a564
 +
+    # Show help text
+	$SCRIPT -h
+
+Background:
+See e-mail thread on developers@lyx.org started by Scott 2017-07-30.
+EOF
+}
+
+
+function fail() {
+    printf "An error occured: %s\n" "$*"
+    exit 1
+}
+
+function list_filtered_git_log() {
+    git log --since=$SINCE_DATE --format="$FORMAT" \
+        | grep -v 'lyx\.org$'
+}
+
+function compute_current_hash() {
+    FILTERED_LOG=$( list_filtered_git_log )
+    echo "$FILTERED_LOG" | shasum -a 512 | cut -d ' ' -f 1
+}
+
+case "$CMD" in
+    "-h"|"--help")
+        show_help
+        exit 0
+        ;;
+
+    "-l"|"--list")
+        list_filtered_git_log
+        ;;
+
+    "--compute-hash")
+        CURRENT_HASH=$( compute_current_hash )
+        printf "Current hash: %s\n" "$CURRENT_HASH"
+        exit 0
+        ;;
+
+    "-c"|"--check-hash")
+        DESIRED_HASH=$2
+        CURRENT_HASH=$( compute_current_hash )
+        if [[ "$CURRENT_HASH" == "$DESIRED_HASH" ]]; then
+            printf "Hash matches current hash\n:"
+            printf "  Current: %s\n" "$CURRENT_HASH"
+            exit 0;
+        else
+            printf "Hash mismatch:\n"
+            printf "  Desired: %s\n" "$DESIRED_HASH"
+            printf "  Current: %s\n" "$CURRENT_HASH"
+            printf "Latest log:\n%s\n" "$FILTERED_LOG"
+            exit 1
+        fi
+        ;;
+
+    *)
+        fail "Unrecognised command(s), give '-h' for help: '$*'"
+        ;;
+esac
+


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic