From 7ad36a21644a1eadfc449a56f4756b9c1fa56f88 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin@koconnor.net>
Date: Fri, 25 Sep 2020 22:13:56 -0400
Subject: [PATCH] github: Run continuous integration tests using "github
 actions"

Use "github actions" instead of "travis ci" for the automatic build
regression tests.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
---
 .github/workflows/build-test.yaml | 30 ++++++++++++++++++++++++++++++
 .travis.yml                       | 27 ---------------------------
 docs/Debugging.md                 |  5 +++--
 scripts/travis-build.sh           |  8 ++------
 scripts/travis-install.sh         |  4 +++-
 5 files changed, 38 insertions(+), 36 deletions(-)
 create mode 100644 .github/workflows/build-test.yaml
 delete mode 100644 .travis.yml

diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml
new file mode 100644
index 000000000..916741c91
--- /dev/null
+++ b/.github/workflows/build-test.yaml
@@ -0,0 +1,30 @@
+# Perform continuous integration tests on updates and pull requests
+name: Build test
+on: [push, pull_request]
+
+jobs:
+  build:
+    runs-on: ubuntu-18.04
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Install system dependencies
+      run: sudo apt-get install gcc-avr avr-libc pv libmpfr-dev libgmp-dev libmpc-dev texinfo libncurses5-dev bison flex python-virtualenv virtualenv python-dev libffi-dev build-essential
+
+    - name: Setup cache
+      uses: actions/cache@v2
+      with:
+        path: travis_cache
+        key: ${{ runner.os }}-build-${{ hashFiles('scripts/travis-install.sh') }}
+
+    - name: Prepare tests
+      run: ./scripts/travis-install.sh
+
+    - name: Test
+      run: ./scripts/travis-build.sh 2>&1
+
+    - name: Upload micro-controller data dictionaries
+      uses: actions/upload-artifact@v2
+      with:
+        name: data-dict
+        path: travis_build/dict
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index fa7516409..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-# This is a travis-ci.org continuous integration configuration file.
-language: c
-dist: bionic
-
-addons:
-  apt:
-    packages:
-      # AVR GCC packages
-      - gcc-avr
-      - avr-libc
-      # PRU GCC build packages
-      - pv
-      - libmpfr-dev
-      - libgmp-dev
-      - libmpc-dev
-      - texinfo
-      - libncurses5-dev
-      - bison
-      - flex
-
-cache:
-  directories:
-  - travis_cache
-
-install: ./scripts/travis-install.sh
-
-script: ./scripts/travis-build.sh
diff --git a/docs/Debugging.md b/docs/Debugging.md
index dfd04add1..4286a37a3 100644
--- a/docs/Debugging.md
+++ b/docs/Debugging.md
@@ -178,8 +178,9 @@ and effect scenarios.
 Running the regression tests
 ============================
 
-The main Klipper GitHub repository uses TravisCI to run a series of
-regression tests. It can be useful to run some of these tests locally.
+The main Klipper GitHub repository uses "github actions" to run a
+series of regression tests. It can be useful to run some of these
+tests locally.
 
 The source code "whitespace check" can be run with:
 ```
diff --git a/scripts/travis-build.sh b/scripts/travis-build.sh
index 2cd966313..19877bf6d 100755
--- a/scripts/travis-build.sh
+++ b/scripts/travis-build.sh
@@ -18,8 +18,7 @@ PYTHON=${BUILD_DIR}/python-env/bin/python
 
 start_test()
 {
-    echo "travis_fold:start:$1"
-    echo "=============== $2"
+    echo "::group::=============== $1 $2"
     set -x
 }
 
@@ -27,7 +26,7 @@ finish_test()
 {
     set +x
     echo "=============== Finished $2"
-    echo "travis_fold:end:$1"
+    echo "::endgroup::"
 }
 
 
@@ -64,9 +63,6 @@ done
 # Verify klippy host software
 ######################################################################
 
-HOSTDIR=${BUILD_DIR}/hosttest
-mkdir -p ${HOSTDIR}
-
 start_test klippy "Test invoke klippy"
 $PYTHON scripts/test_klippy.py -d ${DICTDIR} test/klippy/*.test
 finish_test klippy "Test invoke klippy"
diff --git a/scripts/travis-install.sh b/scripts/travis-install.sh
index b0192e7c3..d0f42c41b 100755
--- a/scripts/travis-install.sh
+++ b/scripts/travis-install.sh
@@ -43,7 +43,9 @@ PRU_DIR=${BUILD_DIR}/pru-gcc
 
 if [ ! -f ${PRU_FILE} ]; then
     cd ${BUILD_DIR}
-    git clone https://github.com/dinuxbg/gnupru -b 2018.03-beta-rc3
+    git config --global user.email "you@example.com"
+    git config --global user.name "Your Name"
+    git clone https://github.com/dinuxbg/gnupru -b 2018.03-beta-rc3 --depth 1
     cd gnupru
     export PREFIX=${PRU_DIR}
     ./download-and-patch.sh 2>&1 | pv -nli 30 > ${BUILD_DIR}/gnupru-build.log