Feat/cpp unittests #721
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Building and testing ArkScript" | |
on: | |
push: | |
branches: [ dev, master ] | |
paths-ignore: | |
- '.github/workflows/docker.yml' | |
- '.github/workflows/label.yml' | |
- '.github/workflows/lizard.yml' | |
- '.github/workflows/release.yml' | |
- '.vscode/*.*' | |
- 'examples/*.ark' | |
- 'images/*.*' | |
- '*.md' | |
- 'docs/*.*' | |
- 'Dockerfile' | |
- '.dockerignore' | |
- 'LICENCE' | |
- '.gitignore' | |
pull_request: | |
env: | |
BUILD_TYPE: Debug | |
SQLITE_VERSION: 3390100 # 3.39.1 | |
jobs: | |
check: | |
name: Formatting Check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
path: | |
- 'src' | |
- 'include' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run clang-format style check for C/C++/Protobuf programs. | |
uses: jidicula/[email protected] | |
with: | |
clang-format-version: '15' | |
check-path: ${{ matrix.path }} | |
fallback-style: 'Mozilla' # optional | |
repo_visualizer: | |
runs-on: ubuntu-latest | |
needs: [ check ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Update diagram | |
uses: githubocto/repo-visualizer@main | |
with: | |
excluded_paths: 'dist,node_modules,submodules' | |
should_push: false | |
output_file: 'diagram.svg' | |
artifact_name: 'diagram' | |
build: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.name }} | |
needs: [ ] | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
os: ubuntu-latest, name: "Ubuntu Clang 15", cc: "clang-15", cxx: "clang++-15", | |
artifact: "ubuntu-clang-15", sanitizers: "On", preconfigure: "" | |
} | |
- { | |
os: ubuntu-latest, name: "Ubuntu Clang 15 (valgrind)", cc: "clang-15", cxx: "clang++-15", | |
artifact: "ubuntu-clang-15-valgrind", sanitizers: "Off", preconfigure: "" | |
} | |
- { | |
os: ubuntu-latest, name: "Ubuntu GCC 13", cc: "gcc-13", cxx: "g++-13", | |
artifact: "ubuntu-gcc-13", sanitizers: "Off", preconfigure: "" | |
} | |
- { | |
os: windows-latest, name: "Windows VS 2019", cc: "cl", cxx: "cl", | |
artifact: "windows-msvc-19", | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
sanitizers: "On", preconfigure: "" | |
} | |
- { | |
os: macos-latest, name: "MacOS Clang 14", cc: "clang", cxx: "clang++", | |
artifact: "macos-clang-14", | |
sanitizers: "On", preconfigure: "export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/" | |
} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup compilers | |
uses: ./.github/workflows/setup-compilers | |
- name: Setup dependencies | |
uses: ./.github/workflows/setup-deps | |
- name: Configure CMake Ark | |
shell: bash | |
run: | | |
${{ matrix.config.preconfigure }} | |
cmake -Bbuild \ | |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ | |
-DARK_SANITIZERS=${{ matrix.config.sanitizers }} \ | |
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=On -DARK_TESTS=On | |
- name: Add SQLite deps | |
if: startsWith(matrix.config.name, 'Windows') | |
shell: bash | |
run: | | |
cmake -Bbuild \ | |
-DSQLite3_INCLUDE_DIR=$(pwd)/sqlite_code/sqlite-amalgamation-${SQLITE_VERSION} \ | |
-DSQLite3_LIBRARY=$(pwd)/sqlite_lib/sqlite3.lib | |
- name: Build ArkScript | |
shell: bash | |
run: cmake --build build --config $BUILD_TYPE | |
# TODO: remove this to put all the tests under tests/unittests | |
- name: Configure & build CMake Integration tests | |
shell: bash | |
run: | | |
cd tests/cpp | |
cmake -Bbuild \ | |
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ | |
-DARK_SANITIZERS=${{ matrix.config.sanitizers }} | |
cmake --build build --config $BUILD_TYPE | |
- name: Organize files for upload | |
shell: bash | |
run: | | |
mkdir -p artifact/lib/std | |
# Linux/MacOS | |
cp build/arkscript artifact || true | |
cp build/libArkReactor.* artifact || true | |
# Windows | |
cp build/$BUILD_TYPE/arkscript.exe artifact || true | |
cp build/$BUILD_TYPE/ArkReactor.dll artifact || true | |
# Generic | |
cp lib/*.arkm artifact/lib | |
cp lib/std/*.ark artifact/lib/std | |
rm -rf artifact/lib/std/{.git,.github,tests/__arkscript__} | |
- name: Organize temp artifact | |
shell: bash | |
run: | | |
cp build/unittests artifact || true | |
cp build/$BUILD_TYPE/unittests.exe artifact || true | |
mkdir -p temp/unittests/ | |
cp -r tests/cpp temp/ | |
cp -r tests/unittests temp/ | |
- name: Upload artifact | |
uses: actions/[email protected] | |
with: | |
name: ${{ matrix.config.artifact }} | |
path: artifact | |
- name: Upload temp artifact | |
uses: actions/[email protected] | |
with: | |
name: temp-${{ matrix.config.artifact }} | |
path: temp | |
retention-days: 1 | |
tests: | |
runs-on: ${{ matrix.config.os }} | |
name: Tests on ${{ matrix.config.name }} | |
needs: [ build ] | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { os: ubuntu-latest, name: "Ubuntu Clang 15", artifact: "ubuntu-clang-15" } | |
- { os: ubuntu-latest, name: "Ubuntu GCC 13", artifact: "ubuntu-gcc-13" } | |
- { os: windows-latest, name: "Windows VS 2019", artifact: "windows-msvc-19", } | |
- { os: macos-latest, name: "MacOS Clang 14", artifact: "macos-clang-14", } | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup tests | |
uses: ./.github/workflows/setup-tests | |
- name: Unit tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
unittests * | |
# TODO: move to tests/unittests | |
- name: Integration tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
(cd tests/cpp ; bash ./run-tests) | |
# TODO: move to tests/unittests | |
- name: AST tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=use_odr_indicator=1 | |
(cd tests/ast ; bash ./run-tests) | |
- name: Unit tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
(cd tests/arkscript ; bash ./run-tests) | |
# FIXME: re-enable later on | |
#- name: Modules tests | |
# shell: bash | |
# run: | | |
# export ASAN_OPTIONS=detect_odr_violation=0 | |
# (source ./lib/modules/.github/run-tests) | |
# TODO: move to tests/unittests | |
- name: Runtime error message generation tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
(cd tests/errors ; bash ./run-tests) | |
valgrind: | |
runs-on: ubuntu-latest | |
name: Ubuntu Clang 12 Valgrind | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Download artifact | |
id: download | |
uses: actions/[email protected] | |
with: | |
name: "ubuntu-clang-15-valgrind" | |
path: build | |
- name: Update LLVM compilers | |
shell: bash | |
run: | | |
mv build/lib/*.arkm lib/ | |
chmod u+x build/arkscript | |
sudo apt-get update --fix-missing | |
sudo apt-get install -y clang-12 lld-12 libc++-12-dev libc++abi-12-dev clang-tools-12 valgrind | |
- name: Valgrind checks for memory leaks | |
shell: bash | |
run: | | |
valgrind --leak-check=full --show-leak-kinds=all \ | |
--track-origins=yes --track-fds=yes \ | |
--trace-children=yes \ | |
--verbose -s \ | |
--error-exitcode=1 \ | |
build/arkscript tests/arkscript/unittests.ark -L ./lib valgrind |