-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (133 loc) · 5.79 KB
/
cmake-debug.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CMake Debug
on:
push:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**CMakeLists.txt'
- .github/workflows/cmake-debug.yml
pull_request:
branches:
- '**'
paths:
- '**.cpp'
- '**.h'
- '**CMakeLists.txt'
- .github/workflows/cmake-debug.yml
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
artifact_dlib_ext: .so
artifact_staticlib_ext: .a
- os: windows-latest
artifact_exec_ext: .exe
artifact_dlib_ext: .dll
artifact_staticlib_ext: .lib
# Note: I wanted to use env.BUILD_TYPE, but it isn't taking
#artifact_out_dir: ${{ BUILD_TYPE }}/
artifact_out_dir: Debug/
artifact_os_name: Windows
artifact_arch: x86_64
- os: macos-latest
artifact_dlib_ext: .dylib
artifact_staticlib_ext: .a
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt install libedit-dev
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Cache C++ dependencies in Packages Directory
uses: actions/cache@v3
with:
path: |
packages
key: ${{ runner.OS }}-c++-packages-cache-Debug-${{ hashFiles('depsCache.json') }}
restore-keys: |
${{ runner.OS }}-c++-packages-cache-Debug-
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuildTest=TRUE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Set variables (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
run: |
APP=$(cat $GITHUB_WORKSPACE/src/lib/Version/appName.txt)
VER=$(cat $GITHUB_WORKSPACE/src/lib/Version/version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
echo "APPNAME=$APP" >> $GITHUB_ENV
- name: Set variables (Windows)
if: matrix.os == 'windows-latest'
run: |
$APP = type .\src\lib\Version\appName.txt
$VER = type .\src\lib\Version\version.txt
echo "VERSION=$VER" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
echo "APPNAME=$APP" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Test Unix-like
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test/${{ env.APPNAME }}Lang_TEST
- name: Test Windows
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test/${{ matrix.artifact_out_dir}}${{ env.APPNAME }}Lang_TEST${{ matrix.artifact_exec_ext }}
#- name: Linux Code Coverage
# if: matrix.os == 'ubuntu-latest'
# working-directory: ${{github.workspace}}
# shell: bash
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ./scripts/runGcov.sh
- name: Prepare Binaries for upload (Mac\Linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
shell: bash
run: |
mkdir ${{github.workspace}}/artifacts
cp build/src/lib/lib${{ env.APPNAME }}Core${{ matrix.artifact_staticlib_ext }} ${{github.workspace}}/artifacts
cp build/src/cli/${{ env.APPNAME }} ${{github.workspace}}/artifacts
pushd ${{github.workspace}}
zip -r ${{ env.APPNAME }}-$(uname -s)-$(uname -m).zip artifacts
popd
- name: Prepare Binaries for upload (windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
[system.io.directory]::CreateDirectory("${{github.workspace}}/artifacts")
Copy-Item "build/src/lib/${{ matrix.artifact_out_dir}}${{ env.APPNAME }}Core${{ matrix.artifact_staticlib_ext }}" -Destination "${{github.workspace}}/artifacts"
Copy-Item "build/src/cli/${{ matrix.artifact_out_dir }}${{ env.APPNAME }}${{ matrix.artifact_exec_ext }}" -Destination "${{github.workspace}}/artifacts"
Compress-Archive -Path ${{github.workspace}}/artifacts/* -DestinationPath ${{ env.APPNAME }}-${{matrix.artifact_os_name}}-${{matrix.artifact_arch}}.zip
- name: 'Upload Pull Request Artifact'
uses: actions/upload-artifact@v3
if: startsWith(github.ref, 'refs/pull/')
with:
name: ${{ env.APPNAME }} Pull Request Artifacts
path: ${{ env.APPNAME }}-*.zip
retention-days: 5