From e8ee5fb44bd6f0af7e696362ae5278fc14bb78f1 Mon Sep 17 00:00:00 2001
From: Jacobo de Vera <devel@jacobodevera.com>
Date: Mon, 15 Jul 2024 23:03:40 +0100
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Create=20Github=20Action?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .github/workflows/build_and_test.yml | 26 ++++++++++++++++++++++++++
 test/_build.bats                     |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 .github/workflows/build_and_test.yml

diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml
new file mode 100644
index 0000000..bc9322a
--- /dev/null
+++ b/.github/workflows/build_and_test.yml
@@ -0,0 +1,26 @@
+name: Build and Test
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+env:
+  TERM: linux
+
+jobs:
+  linux-tests:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        submodules: 'recursive'
+    - name: Checks
+      run: make check
+    - name: Run tests (as root)
+      run: |
+        sudo make test
+    - name: Compile to a file
+      run: make build
+    - name: Run checks on the single file
+      run: make distcheck
diff --git a/test/_build.bats b/test/_build.bats
index 7d44394..e3bc27c 100755
--- a/test/_build.bats
+++ b/test/_build.bats
@@ -5,7 +5,7 @@ setup_file() {
     PROJECT_ROOT="$( cd "$( dirname "$BATS_TEST_FILENAME" )/.." >/dev/null 2>&1 && pwd )"
     export JDVLIB_COMPILED_PATH=$BATS_FILE_TMPDIR/jdvlib.sh
     pushd "$PROJECT_ROOT" > /dev/null || return 1
-    "$PROJECT_ROOT/compile.sh" lib "${JDVLIB_COMPILED_PATH}"
+    ./compile.sh lib "${JDVLIB_COMPILED_PATH}"
     popd > /dev/null || return 1
 }