Skip to content

Commit

Permalink
Add various CI builds
Browse files Browse the repository at this point in the history
This adds older versions of GCC, VS2015, scan-build, and a mix of
amalgamated vs. source builds. It also cleans up the CI definitions and
scripts. The old build matrix is gone. The GitHub actions file just
defines each build individually now.
  • Loading branch information
ludocode committed Aug 23, 2021
1 parent a1cae04 commit c6271df
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 101 deletions.
224 changes: 158 additions & 66 deletions .github/workflows/unit.yml
Expand Up @@ -3,71 +3,163 @@ 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 }}


macos-clang-amalgamated:
name: "macOS Clang (amalgamated)"
runs-on: macos-latest
env:
AMALGAMATED: 1
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: brew install ninja

- name: Run ci-unix
run: test/unit/ci-unix.sh



ubuntu-scan-build:
name: "Clang Static Analysis (source)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang-tools
- name: Run scan-build
run: tools/scan-build.sh



ubuntu-tcc:
name: "TinyCC (source)"
runs-on: ubuntu-latest
env:
CC: tcc
CXX: /bin/false
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build tcc
- name: Run ci-unix
run: test/unit/ci-unix.sh



ubuntu-gcc-9:
name: "Ubuntu 20.04 GCC 9 (source)"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Install Ninja
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Install lcov
run: |
curl -LO https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz
tar xzf lcov-1.15.tar.gz
cd lcov-1.15
sudo make install
- name: Run ci-unix
run: test/unit/ci-unix.sh

- name: Collect coverage
run: tools/coverage.sh

- name: Submit coverage to Coveralls
id: coverage
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Print Coveralls submission result
run: echo ${{ steps.coverage.outputs['coveralls-api-result'] }}



ubuntu-gcc-7:
name: "Ubuntu 20.04 GCC 7 (amalgamated)"
runs-on: ubuntu-20.04
env:
CC: gcc-7
CXX: g++-7
AMALGAMATED: 1
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-7
- name: Run ci-unix
run: test/unit/ci-unix.sh



ubuntu-gcc-5:
name: "Ubuntu 18.04 GCC 5 (amalgamated)"
runs-on: ubuntu-18.04
env:
CC: gcc-5
CXX: g++-5
AMALGAMATED: 1
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
# https://askubuntu.com/a/1087368
# note for when 18.04 is EOL: https://askubuntu.com/a/1313032
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-5
- name: Run ci-unix
run: test/unit/ci-unix.sh



windows-cl-2019-x64:
name: "Windows VS2019 amd64 (source)"
runs-on: windows-latest
env:
COMPILER: cl-2019-x64
steps:
- uses: actions/checkout@v2

- name: Run ci-windows (Windows)
shell: cmd
run: test\\unit\\ci-windows.bat



windows-cl-2015-x86:
name: "Windows VS2015 x86 (amalgamated)"
runs-on: windows-latest
env:
COMPILER: cl-2015-x86
AMALGAMATED: 1
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: Install lcov (Ubuntu+gcc)
if: contains(matrix.cc, 'gcc')
run: |
curl -LO https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz
tar xzf lcov-1.15.tar.gz
cd lcov-1.15
sudo make install
- 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

- name: Submit coverage to Coveralls
id: coverage
if: contains(matrix.cc, 'gcc')
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Print Coveralls submission result
if: contains(matrix.cc, 'gcc')
run: echo ${{ steps.coverage.outputs['coveralls-api-result'] }}
- uses: actions/checkout@v2

- name: Amalgamate
shell: bash
run: tools\\amalgamate.sh

- name: Run ci-windows (Windows)
shell: cmd
run: test\\unit\\ci-windows.bat
1 change: 1 addition & 0 deletions src/mpack/mpack-platform.h
Expand Up @@ -1027,6 +1027,7 @@
// These are a bunch of mostly useless warnings emitted under MSVC /W4,
// some as a result of the expansion of macros.
#define MPACK_SILENCE_WARNINGS_MSVC_W4 \
__pragma(warning(disable:4996)) /* _CRT_SECURE_NO_WARNINGS */ \
__pragma(warning(disable:4127)) /* comparison is constant */ \
__pragma(warning(disable:4702)) /* unreachable code */ \
__pragma(warning(disable:4310)) /* cast truncates constant value */
Expand Down
27 changes: 4 additions & 23 deletions test/unit/ci-unix.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Builds and runs the unit test suite under UNIX.
#
Expand All @@ -9,31 +9,12 @@

set -e

if [ "$AMALGAMATED" = "1" ]; then
# Amalgamate if necessary
if [[ "$AMALGAMATED" == "1" ]]; then
tools/amalgamate.sh
cd build/amalgamation
cd .build/amalgamation
fi
pwd

if [[ "$CC" == "scan-build" ]]; then
unset CC
unset CXX

echo "Not yet implemented!"
exit 1

scan-build -o analysis --use-cc=`which clang` --status-bugs test/unit/configure.py
ninja -f .build/unit/build.ninja
exit $?
fi

# Run the "more" variant of unit tests
tools/unit.sh more

if [ "$CC" = "gcc" ]; then
# Collect coverage info.
# This is submitted to Coveralls as a separate GitHub Action.
unset CC
unset CXX
tools/coverage.sh
fi
16 changes: 16 additions & 0 deletions test/unit/ci-windows.bat
Expand Up @@ -3,5 +3,21 @@
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 build tools
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find **\vcvarsall.bat`) do (SET "vcvarsall=%%i")

IF "%AMALGAMATED%"=="1" (
cd .build\amalgamation
)

IF "%COMPILER%"=="cl-2019-x64" (
call "%vcvarsall%" amd64
)
IF "%COMPILER%"=="cl-2015-x86" (
call "%vcvarsall%" x86 -vcvars_ver=14.0
)

REM Run the "more" variant of unit tests
call tools\unit.bat more
10 changes: 9 additions & 1 deletion test/unit/src/test.h
Expand Up @@ -78,7 +78,7 @@ MPACK_SILENCE_WARNINGS_BEGIN
#pragma warning(disable:4221) // nonstandard extension used: cannot be initialized using address of automatic variable
#endif

// We shadow variables in some macros
// We silence shadow warnings around variable declarations in some macros
#if defined(MPACK_SILENCE_WARNINGS_PUSH)
#ifdef __GNUC__
#define TEST_MPACK_SILENCE_SHADOW_BEGIN \
Expand All @@ -100,6 +100,14 @@ MPACK_SILENCE_WARNINGS_BEGIN
#define TEST_MPACK_SILENCE_SHADOW_END /*nothing*/
#endif

// For some older versions of GCC, we silence shadow warnings globally since
// they don't properly handle push/pop around variable declarations.
#ifdef __GNUC__
#if __GNUC__ < 9
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#endif



/**
Expand Down
22 changes: 12 additions & 10 deletions tools/amalgamate.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# This script amalgamates the MPack code into a single pair of
# source files, mpack.h and mpack.c. The resulting amalgamation
# is in build/amalgamation/ (without documentation.)
# is in .build/amalgamation/ (without documentation.)

. "`dirname $0`"/getversion.sh

Expand All @@ -26,8 +26,10 @@ SOURCES="\
TOOLS="\
tools/afl.sh \
tools/clean.sh \
tools/gcov.sh \
tools/coverage.sh \
tools/scan-build.sh \
tools/unit.bat \
tools/unit.sh \
tools/valgrind-suppressions \
"

Expand All @@ -40,10 +42,10 @@ FILES="\
"

# add top license and comment
rm -rf build/amalgamation
mkdir -p build/amalgamation/src/mpack
HEADER=build/amalgamation/src/mpack/mpack.h
SOURCE=build/amalgamation/src/mpack/mpack.c
rm -rf .build/amalgamation
mkdir -p .build/amalgamation/src/mpack
HEADER=.build/amalgamation/src/mpack/mpack.h
SOURCE=.build/amalgamation/src/mpack/mpack.c
echo '/**' > $HEADER
sed 's/^/ * /' LICENSE >> $HEADER
cat - >> $HEADER <<EOF
Expand Down Expand Up @@ -80,9 +82,9 @@ for f in $SOURCES; do
done

# assemble package contents
cp -ar $FILES build/amalgamation
mkdir -p build/amalgamation/tools
cp $TOOLS build/amalgamation/tools
cp -a $FILES .build/amalgamation
mkdir -p .build/amalgamation/tools
cp -a $TOOLS .build/amalgamation/tools

# done!
echo "Done. MPack amalgamation is in build/amalgamation/"
echo "Done. MPack amalgamation is in .build/amalgamation/"
2 changes: 1 addition & 1 deletion tools/scan-build.sh
@@ -1,2 +1,2 @@
#!/bin/bash
scan-build -o analysis --use-cc=`which clang` --status-bugs --view scons
scan-build -o analysis --status-bugs bash -c 'test/unit/configure.py && ninja -f .build/unit/build.ninja'

0 comments on commit c6271df

Please sign in to comment.