Skip to content

Commit

Permalink
Add GitHub actions unit test config
Browse files Browse the repository at this point in the history
  • Loading branch information
ludocode committed Jul 14, 2021
1 parent d83b7fb commit dd1cc30
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 30 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Unit Tests

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04]

# workaround for matrix keys not allowed to be empty. we want
# to manually specify the compilers for each platform.
cc: [nocc]
exclude:
- cc: nocc

include:
- os: macos-latest
cc: clang
- os: ubuntu-20.04
cc: gcc
- os: ubuntu-20.04
cc: tcc
- os: windows-latest
cc: cl

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install Ninja (Ubuntu)
if: contains(matrix.os, 'ubuntu')
# sudo apt-get update -y &&
run: sudo apt-get install -y ninja-build

- name: Install Ninja (macOS)
if: contains(matrix.os, 'macos')
run: brew install ninja

- name: Install TinyCC (Ubuntu+tcc)
if: contains(matrix.cc, 'tcc')
run: sudo apt-get install -y tcc

- name: Run ci-unix (Ubuntu, macOS)
if: ${{ !contains(matrix.os, 'windows') }}
run: test/unit/ci-unix.sh
env:
CC: ${{ matrix.cc }}

- name: Run ci-windows (Windows)
if: contains(matrix.os, 'windows')
shell: cmd
run: test\\unit\\ci-windows.bat
4 changes: 2 additions & 2 deletions test/unit/ci-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ if [ "$CC" = "gcov" ]; then
exit $?
fi

test/unit/configure.py
ninja -f build/unit/build.ninja all
# Run the "more" variant of unit tests
tools/unit.sh more
32 changes: 4 additions & 28 deletions test/unit/ci-windows.bat
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
@echo off

REM Builds and runs the unit test suite under MSVC on Windows.
REM
REM This should be run in a normal command prompt, not a Visual Studio Build
REM Tools command prompt. This script will find the build tools itself.
REM
REM This script is run by the continuous integration server to test MPack with
REM MSVC on Windows.
REM This script is run by the continuous integration server to build and run
REM the MPack unit test suite with MSVC on Windows.

setlocal enabledelayedexpansion

REM Find vcvarsall.bat for latest Visual Studio
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find **\vcvarsall.bat`) do (SET "vcvarsall=%%i")

REM Load compiler into PATH using vcvarsall.bat
call "%vcvarsall%" amd64
if %errorlevel% neq 0 exit /b %errorlevel%

REM Load Python 3.8 into PATH on Appveyor
if "%APPVEYOR%"=="True" (
path C:\Python38-x64;!PATH!
)

REM Run Python configuration
python test\unit\configure.py
if %errorlevel% neq 0 exit /b %errorlevel%

REM Build and run unit tests with Ninja
ninja -f build\unit\build.ninja all
if %errorlevel% neq 0 exit /b %errorlevel%
REM Run the "more" variant of unit tests
call tools\unit.bat more
28 changes: 28 additions & 0 deletions tools/unit.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off

REM Builds and runs the unit test suite under the Visual Studio C compiler on
REM Windows.
REM
REM Pass a configuration to run or pass "all" to run all configurations.
REM
REM You can run this in a normal command prompt or in a Visual Studio Build
REM Tools command prompt. It will find the build tools automatically if needed
REM but it will run a lot faster if they are already available.

setlocal enabledelayedexpansion

REM Find build tools
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find **\vcvarsall.bat`) do (SET "vcvarsall=%%i")

REM Enable build tools if needed
where cl 1>NUL 2>NUL
if %errorlevel% neq 0 call "%vcvarsall%" amd64
if %errorlevel% neq 0 exit /b %errorlevel%

REM Configure unit tests
python test\unit\configure.py
if %errorlevel% neq 0 exit /b %errorlevel%

REM Run unit tests
ninja -f test\.build\build.ninja %*
if %errorlevel% neq 0 exit /b %errorlevel%

0 comments on commit dd1cc30

Please sign in to comment.