Replace the existing test workflow with draco-ci from ci.yml. (#806)

This replaces test.yml with ci.yml and renames the test to draco-ci.

A Github PR with this all put together exists at the following link:
https://github.com/google/draco/pull/806

An example draco-ci test summary exists at this link:
https://github.com/google/draco/actions/runs/1789061363

- Add the following test configurations in a job named
  draco-tests.

  test-macos-make-release-shared
  test-macos-make-release-static
  test-macos-xcode-release-shared
  test-macos-xcode-release-static
  test-ubuntu-make-release-shared
  test-ubuntu-make-release-static
  test-windows-msvc-release-shared
  test-windows-msvc-release-static
  test-windows-make-release-shared
  test-windows-make-release-static

  Each configuration name is intended to be self documenting.
  All configurations build Draco with tests enabled, and then
  run the tests.

- Add the following test configurations in a job named
  draco-install-tests:

  install-test-ubuntu-make
  install-test-macos-make
  install-test-macos-xcode
  install-test-windows-make
  install-test-windows-msvc

  Each configuration runs test.py in verbose mode to allow for
  failure diagnostics.

Some additional changes to make all this work (and improve usability):
- draco-config.cmake now defines DRACO_LIBRARY_DLL and DRACO_FOUND.
  - DRACO_LIBRARY_DLL will contain the full path to the Draco DLL on systems that
     produce DLL files (aka Windows).
- test.py now streams output in verbose mode
This commit is contained in:
Tom Finegan 2022-02-03 13:05:31 -08:00 committed by GitHub
parent 2e8325eb63
commit b7655f7391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 210 additions and 46 deletions

183
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,183 @@
on: [pull_request]
name: draco-ci
jobs:
# Main build and test job.
draco-tests:
strategy:
matrix:
include:
- test_name: macos-make-release-shared
os: macos-latest
cmake_configure_command: |-
cmake .. -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
- test_name: macos-make-release-static
os: macos-latest
cmake_configure_command: |-
cmake .. -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
- test_name: macos-xcode-release-shared
os: macos-latest
cmake_configure_command: |-
cmake .. -G Xcode \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CONFIGURATION_TYPES=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . --config Release
draco_test_command: Release/draco_tests
- test_name: macos-xcode-release-static
os: macos-latest
cmake_configure_command: |-
cmake .. -G Xcode \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_CONFIGURATION_TYPES=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . --config Release
draco_test_command: Release/draco_tests
- test_name: ubuntu-make-release-shared
os: ubuntu-latest
cmake_configure_command: |-
cmake .. -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10 \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
- test_name: ubuntu-make-release-static
os: ubuntu-latest
cmake_configure_command: |-
cmake .. -G "Unix Makefiles" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10 \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
- test_name: windows-msvc-release-shared
os: windows-latest
cmake_configure_command: |-
cmake .. -G "Visual Studio 16 2019" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_CONFIGURATION_TYPES=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . --config Release -- -m:2
draco_test_command: Release/draco_tests
- test_name: windows-msvc-release-static
os: windows-latest
cmake_configure_command: |-
cmake .. -G "Visual Studio 16 2019" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_CONFIGURATION_TYPES=Release \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . --config Release -- -m:2
draco_test_command: Release/draco_tests
- test_name: windows-make-release-shared
os: windows-latest
cmake_configure_command: |-
cmake .. -G "MinGW Makefiles" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
- test_name: windows-make-release-static
os: windows-latest
cmake_configure_command: |-
cmake .. -G "MinGW Makefiles" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DDRACO_TESTS=ON
cmake_build_command: cmake --build . -- -j2
draco_test_command: ./draco_tests
name: test-${{ matrix.test_name }}
runs-on: ${{ matrix.os }}
steps:
- name: Clone Draco with Submodules.
uses: actions/checkout@v2
with:
submodules: true
- name: Create build directory
shell: bash
run: mkdir _gh_build
- name: Configure CMake build
shell: bash
run: ${{ matrix.cmake_configure_command }}
working-directory: ./_gh_build
- name: Build with CMake
shell: bash
run: ${{ matrix.cmake_build_command }}
working-directory: ./_gh_build
- name: Run tests
shell: bash
run: ${{ matrix.draco_test_command }}
working-directory: ./_gh_build
# Runs src/draco/tools/install_test.
draco-install-tests:
strategy:
matrix:
include:
- test_name: ubuntu-make
os: ubuntu-latest
test_command: python3 test.py -v -G "Unix Makefiles"
- test_name: macos-make
os: macos-latest
test_command: python3 test.py -v -G "Unix Makefiles"
- test_name: macos-xcode
os: macos-latest
test_command: python3 test.py -v -G Xcode
- test_name: windows-make
os: windows-latest
test_command: python3 test.py -v -G "MinGW Makefiles"
- test_name: windows-msvc
os: windows-latest
test_command: python3 test.py -v -G "Visual Studio 16 2019"
name: install-test-${{ matrix.test_name }}
runs-on: ${{ matrix.os }}
steps:
- name: Clone Draco with Submodules
uses: actions/checkout@v2
with:
submodules: true
- name: Run src/draco/tools/install_test/test.py
shell: bash
run: ${{ matrix.test_command }}
working-directory: ./src/draco/tools/install_test

View File

@ -1,39 +0,0 @@
on: [pull_request]
name: Build
jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
cc: gcc-10
cxx: g++-10
generator: Unix Makefiles
- os: ubuntu-latest
cc: clang
cxx: clang++
generator: Unix Makefiles
- os: macos-latest
cc: gcc-10
cxx: g++-10
generator: Unix Makefiles
- os: windows-latest
cc: x86_64-w64-mingw32-gcc
cxx: x86_64-w64-mingw32-g++
generator: MinGW Makefiles
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: git clone https://github.com/google/googletest.git ../googletest
- run: mkdir _gh_build
- run: cmake -G "${{ matrix.generator }}" -DENABLE_TESTS=ON ..
working-directory: ./_gh_build
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
- run: make -j10
working-directory: ./_gh_build
- run: ./draco_tests
working-directory: ./_gh_build

View File

@ -2,7 +2,8 @@
<img width="350px" src="docs/artwork/draco3d-vert.svg" />
</p>
[![Build Status](https://github.com/google/draco/workflows/Build/badge.svg)](https://github.com/google/draco/actions?query=workflow%3ABuild)
![draco-ci](https://github.com/google/draco/actions/workflows/ci.yml/badge.svg)
News
=======

View File

@ -1,7 +1,11 @@
@PACKAGE_INIT@
set_and_check(DRACO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check(DRACO_LIBRARY_DIR "@CMAKE_INSTALL_FULL_LIBDIR@")
set(DRACO_NAMES draco.dll libdraco.dylib libdraco.so draco.lib libdraco.a)
set(DRACO_NAMES
draco.dll libdraco.dylib libdraco.so draco.lib libdraco.dll libdraco.a)
find_library(_DRACO_LIBRARY PATHS ${DRACO_LIBRARY_DIR} NAMES ${DRACO_NAMES})
set_and_check(DRACO_LIBRARY ${_DRACO_LIBRARY})
find_file(DRACO_LIBRARY_DLL
PATHS ${DRACO_LIBRARY_DIR}
NAMES draco.dll libdraco.dll)
set(DRACO_FOUND YES)

View File

@ -51,6 +51,6 @@ if(BUILD_SHARED_LIBS AND WIN32)
# Copy the Draco DLL into the bin dir for Windows: Windows doesn't really have
# a concept of rpath, but it does look in the current directory by default
# when a program tries to load a DLL.
install(FILES "${DRACO_LIBRARY_DIR}/draco.dll"
install(FILES "${DRACO_LIBRARY_DLL}"
DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
endif()

View File

@ -27,6 +27,7 @@ import pathlib
import shlex
import shutil
import subprocess
import sys
# CMake executable.
CMAKE = shutil.which('cmake')
@ -113,7 +114,8 @@ def cmake_get_generator():
def run_process_and_capture_output(cmd, env=None):
"""Runs |cmd| as a child process.
Returns process exit code and output.
Returns process exit code and output. Streams process output to stdout when
VERBOSE is true.
Args:
cmd: String containing the command to execute.
@ -133,8 +135,18 @@ def run_process_and_capture_output(cmd, env=None):
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
stdout = proc.communicate()
return [proc.returncode, stdout[0].decode('utf-8')]
stdout = ''
for line in iter(proc.stdout.readline, b''):
decoded_line = line.decode('utf-8')
if VERBOSE:
sys.stdout.write(decoded_line)
sys.stdout.flush()
stdout += decoded_line
# Wait for the process to exit so that the exit code is available.
proc.wait()
return [proc.returncode, stdout]
def create_output_directories():
@ -162,7 +174,10 @@ def cmake_configure(source_path, cmake_args=None):
command = f'{CMAKE} {source_path}'
if CMAKE_GENERATOR:
command += f' -G {CMAKE_GENERATOR}'
if ' ' in CMAKE_GENERATOR:
command += f' -G "{CMAKE_GENERATOR}"'
else:
command += f' -G {CMAKE_GENERATOR}'
if cmake_args:
for arg in cmake_args: