Merge pull request #237 from mity/expand_ci Expand continouous integration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index 30d99dc..22f4c5c 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -5,7 +5,12 @@ on:
- push
jobs:
- linux:
+ # Linux builds.
+ #
+ # gcc sometimes warns (e.g. about potentially uninitialized variables) only
+ # when some optimizations are enabled. So we build Debug as well as Release
+ # on Linux. The Debug build also collects and uploads test coverage.
+ linux-debug:
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -15,7 +20,7 @@ jobs:
- name: Build
run: make VERBOSE=1
- name: Test
- run: ./scripts/run-tests.sh
+ run: python3 ./scripts/run-tests.py
- name: Create coverage report
run: |
sudo apt-get install -y lcov
@@ -25,22 +30,52 @@ jobs:
- name: Upload coverage report
uses: codecov/codecov-action@v3
- windows-32:
+ linux-release:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Configure
+ run: CFLAGS='--coverage -Werror' cmake -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles' .
+ - name: Build
+ run: make VERBOSE=1
+ - name: Test
+ run: python3 ./scripts/run-tests.py
+
+ # Windows builds.
+ #
+ # We do both 32 and 64-bit builds. Also note 32-bit does Debug build while
+ # 64-bit one does Release build. (Full matrix would likely be an overkill.)
+ windows-32-debug:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v4
- - uses: microsoft/setup-msbuild@v1.3.1
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Dev command prompt
+ uses: ilammy/msvc-dev-cmd@v1
+ with:
+ arch: x86
- name: Configure
- run: cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A Win32 .
+ run: cmake -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" .
- name: Build
- run: msbuild.exe md4c.sln /p:Configuration=Release /p:Platform=Win32
+ run: nmake
+ - name: Setyp Python
+ uses: actions/setup-python@v5
+ - name: Test
+ run: python .\scripts\run-tests.py
- windows-64:
+ windows-64-release:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v4
- - uses: microsoft/setup-msbuild@v1.3.1
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Dev command prompt
+ uses: ilammy/msvc-dev-cmd@v1
+ with:
+ arch: x64
- name: Configure
- run: cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 .
+ run: cmake -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" .
- name: Build
- run: msbuild.exe md4c.sln /p:Configuration=Release /p:Platform=x64
+ run: nmake
+ - name: Test
+ run: python .\scripts\run-tests.py
diff --git a/scripts/run-tests.py b/scripts/run-tests.py
new file mode 100644
index 0000000..d71cc7b
--- /dev/null
+++ b/scripts/run-tests.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+import glob
+import os
+import subprocess
+import sys
+
+
+argv0_dir = os.path.dirname(sys.argv[0])
+project_dir = os.path.abspath(os.path.join(argv0_dir, ".."))
+test_dir = os.path.join(project_dir, "test")
+program = os.path.abspath(os.path.join("md2html", "md2html"))
+
+if __name__ == "__main__":
+ err_count = 0
+
+ os.chdir(test_dir)
+
+ for testsuite in glob.glob('*.txt'):
+ print("Testing {}".format(testsuite))
+ sys.stdout.flush()
+ sys.stderr.flush()
+ args = [
+ sys.executable,
+ "run-testsuite.py",
+ "-s", testsuite,
+ "-p", str(program)
+ ]
+ p = subprocess.run(args)
+ if p.returncode != 0:
+ err_count += 1
+ print()
+
+ print("Testing pathological inputs:")
+ sys.stdout.flush()
+ sys.stderr.flush()
+ args = [
+ sys.executable,
+ "pathological-tests.py",
+ "-p", str(program)
+ ]
+ subprocess.run(args)
+ if p.returncode != 0:
+ err_count += 1
+
+ sys.exit(err_count)
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
deleted file mode 100755
index 8af7684..0000000
--- a/scripts/run-tests.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/sh
-#
-# Run this script from build directory.
-
-#set -e
-
-SELF_DIR=`dirname $0`
-PROJECT_DIR="$SELF_DIR/.."
-TEST_DIR="$PROJECT_DIR/test"
-
-
-PROGRAM="md2html/md2html"
-if [ ! -x "$PROGRAM" ]; then
- echo "Cannot find the $PROGRAM." >&2
- echo "You have to run this script from the build directory." >&2
- exit 1
-fi
-
-if which py >>/dev/null 2>&1; then
- PYTHON=py
-elif which python3 >>/dev/null 2>&1; then
- PYTHON=python3
-elif which python >>/dev/null 2>&1; then
- if [ `python --version | awk '{print $2}' | cut -d. -f1` -ge 3 ]; then
- PYTHON=python
- fi
-fi
-
-echo
-echo "CommonMark specification:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec.txt" -p "$PROGRAM"
-
-echo
-echo "Permissive autolink extensions:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-permissive-autolinks.txt" -p "$PROGRAM"
-
-echo
-echo "Hard soft breaks extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-hard-soft-breaks.txt" -p "$PROGRAM"
-
-echo
-echo "Tables extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-tables.txt" -p "$PROGRAM"
-
-echo
-echo "Strikethrough extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-strikethrough.txt" -p "$PROGRAM"
-
-echo
-echo "Task lists extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-tasklists.txt" -p "$PROGRAM"
-
-echo
-echo "LaTeX extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-latex-math.txt" -p "$PROGRAM"
-
-echo
-echo "Wiki links extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-wiki-links.txt" -p "$PROGRAM"
-
-echo
-echo "Underline extension:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/spec-underline.txt" -p "$PROGRAM"
-
-echo
-echo "Code coverage:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/coverage.txt" -p "$PROGRAM"
-
-echo
-echo "Regressions:"
-$PYTHON "$TEST_DIR/run-testsuite.py" -s "$TEST_DIR/regressions.txt" -p "$PROGRAM"
-
-echo
-echo "Pathological inputs:"
-$PYTHON "$TEST_DIR/pathological-tests.py" -p "$PROGRAM"