Skip to content

Commit

Permalink
Merge pull request #461 from ghutchis/gh-build-tests
Browse files Browse the repository at this point in the history
Enable testing using GitHub
  • Loading branch information
ghutchis authored Apr 28, 2020
2 parents 5be7a5e + 78ddcda commit d1f0436
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
name: "Ubuntu Latest GCC", artifact: "Linux.tar.gz",
os: ubuntu-latest,
cc: "gcc", cxx: "g++",
cmake_flags: "-G Ninja",
cmake_flags: "-G Ninja -DENABLE_TESTING=ON ",
cpack: "",
}
- {
name: "macOS Latest Clang", artifact: "macOS.dmg",
os: macos-latest,
cc: "clang", cxx: "clang++",
cmake_flags: "-G Ninja",
cmake_flags: "-G Ninja -DENABLE_TESTING=ON ",
cpack_flags: "-G DragNDrop",
}
- {
Expand Down Expand Up @@ -73,7 +73,6 @@ jobs:
with:
path: avogadrolibs

# this never seems to hit..
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
Expand All @@ -87,29 +86,6 @@ jobs:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
version: ${{ env.QT_VERSION }}

- name: Download ccache
id: ccache
shell: cmake -P {0}
run: |
set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz)
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Restore cache files
uses: actions/cache@v1
with:
path: .ccache
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
- name: Configure MSVC Command Prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
Expand All @@ -120,14 +96,31 @@ jobs:
run: |
mkdir "${{ runner.workspace }}/build"
cd "${{ runner.workspace }}/build"
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{matrix.config.cmake_flags}}
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${{matrix.config.cmake_flags}}
shell: bash

- name: Build
run: CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{env.BUILD_TYPE}}
run: |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{env.BUILD_TYPE}}
shell: bash
working-directory: ${{ runner.workspace }}/build

- name: Run tests
if: runner.os != 'Windows'
shell: cmake -P {0}
run: |
include(ProcessorCount)
ProcessorCount(N)
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
execute_process(
COMMAND ctest -j ${N}
WORKING_DIRECTORY ${{ runner.workspace }}/build
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Running tests failed!")
endif()
- name: Pack
if: matrix.config.artifact != 0
run: cpack ${{ matrix.config.cpack_flags }}
Expand Down

0 comments on commit d1f0436

Please sign in to comment.