Skip to content

Commit 9842b91

Browse files
authored
Merge pull request #4 from saxbophone/josh/github-actions
Add Github action for testing
2 parents 15c28cb + a3cd2c2 commit 9842b91

File tree

6 files changed

+701
-438
lines changed

6 files changed

+701
-438
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: continuous-integration
2+
3+
on:
4+
push:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [macos-latest, ubuntu-20.04]
15+
cxx: [g++-10, clang++]
16+
include:
17+
- os: windows-latest
18+
cxx: msvc
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Configure CMake
24+
env:
25+
CXX: ${{ matrix.cxx }}
26+
# Use a bash shell so we can use the same syntax for environment variable
27+
# access regardless of the host operating system
28+
shell: bash
29+
working-directory: ${{github.workspace}}/build
30+
# Note the current convention is to use the -S and -B options here to specify source
31+
# and build directories, but this is only available with CMake 3.13 and higher.
32+
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
33+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=$GITHUB_WORKSPACE/artifacts
34+
35+
- name: Build
36+
working-directory: ${{github.workspace}}/build
37+
shell: bash
38+
# Execute the build. You can specify a specific target with "--target <NAME>"
39+
run: cmake --build . --config Debug
40+
41+
- name: Test
42+
working-directory: ${{github.workspace}}/build
43+
shell: bash
44+
# Execute tests defined by the CMake configuration.
45+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
46+
run: ctest -C Debug
47+
48+
- name: Install
49+
working-directory: ${{github.workspace}}/build
50+
shell: bash
51+
# Use CMake to "install" build artifacts (only interested in CMake registered targets) to our custom artifacts directory
52+
run: cmake --install . --config Debug
53+
54+
# Only run last two steps if this is a release
55+
- name: Release
56+
if: github.event == 'release'
57+
env:
58+
CXX: ${{ matrix.cxx }}
59+
# Use a bash shell so we can use the same syntax for environment variable
60+
# access regardless of the host operating system
61+
shell: bash
62+
working-directory: ${{github.workspace}}/build
63+
# Note the current convention is to use the -S and -B options here to specify source
64+
# and build directories, but this is only available with CMake 3.13 and higher.
65+
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
66+
run: |
67+
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$GITHUB_WORKSPACE/artifacts
68+
cmake --build . --config Release
69+
cmake --install . --config Release
70+
71+
# Only Upload releases
72+
- name: Upload
73+
if: github.event == 'release'
74+
uses: actions/upload-artifact@v2
75+
with:
76+
name: build_${{ github.sha }}_${{ matrix.os }}_${{ matrix.cxx }}
77+
path: ${{github.workspace}}/artifacts

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ set(PROJ_CLI_SOURCE "main.cpp")
9696
# C++ source files for unit tests
9797
file(GLOB TEST_SOURCES "tests/*.cpp")
9898
# Header files
99-
set(PROJ_HEADERS "proj/*.hpp")
99+
set(PROJ_HEADERS "proj/proj.hpp")
100100

101101
# if project is a library
102102
add_library(proj ${PROJ_SOURCES})

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CPP20-Cross-Platform-Template
2-
A template for a cross-platform C++20 project including CMake, unit-testing with Catch and cross-platform Travis-CI
2+
A template for a cross-platform C++20 project including CMake, unit-testing with Catch, cross-platform CI with Travis-CI/Github Actions and cross-platform release builds using Github Actions.
33

44
## What's included
55
- CMake C++20 project skeleton, with strict warning flags enabled when using GCC or Clang.
@@ -9,6 +9,9 @@ A template for a cross-platform C++20 project including CMake, unit-testing with
99
- macOS: Clang-10
1010
- Windows: MSVC 2019
1111
- 1 Additional build on Linux to check Doxygen documentation is well-formed
12+
- Github Action config file supporting:
13+
- Building and running tests on the same Operating Systems and Compilers as Travis-CI (additionally, GCC-10 on macOS)
14+
- Building Releases on each platform when a Github Release is published, uploading these as build Artifacts.
1215
- Doxygen config file with tweaks from the default config settings to provide a few more graphs (usage, caller/callee relationships) than are enabled by default.
1316

1417
## Usage

programs/bin/proj

16.1 KB
Binary file not shown.

proj/proj.hpp

Whitespace-only changes.

0 commit comments

Comments
 (0)