Skip to content

Commit 10c688e

Browse files
committed
enable github actions (aka continuous integration)
basic implementation to enable github actions with: - triggered each push or pull request - built on ubuntu (multiple version), macOS, windows - the binary has debug facilities enabled - ignore any commit/push on the .github folder - run all tests - create an archive with binaries (available for 90 days) - can manually triggered setting custom cmake flags
1 parent 9fd7bf2 commit 10c688e

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed

.github/workflows/ci.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: 'build direwolf'
2+
3+
on:
4+
# permit to manually trigger the CI
5+
workflow_dispatch:
6+
inputs:
7+
cmake_flags:
8+
description: 'Custom CMAKE flags'
9+
required: false
10+
push:
11+
paths-ignore:
12+
- '.github/**'
13+
pull_request:
14+
paths-ignore:
15+
- '.github/**'
16+
17+
jobs:
18+
build:
19+
name: ${{ matrix.config.name }}
20+
runs-on: ${{ matrix.config.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
config:
25+
- {
26+
name: 'Windows Latest MinGW 64bit',
27+
os: windows-latest,
28+
cc: 'x86_64-w64-mingw32-gcc',
29+
cxx: 'x86_64-w64-mingw32-g++',
30+
ar: 'x86_64-w64-mingw32-ar',
31+
windres: 'x86_64-w64-mingw32-windres',
32+
arch: 'x86_64',
33+
build_type: 'Release',
34+
cmake_extra_flags: '-G "MinGW Makefiles"'
35+
}
36+
- {
37+
name: 'Windows Latest MinGW 32bit',
38+
os: windows-latest,
39+
cc: 'i686-w64-mingw32-gcc',
40+
cxx: 'i686-w64-mingw32-g++',
41+
ar: 'i686-w64-mingw32-ar',
42+
windres: 'i686-w64-mingw32-windres',
43+
arch: 'i686',
44+
build_type: 'Release',
45+
cmake_extra_flags: '-G "MinGW Makefiles"'
46+
}
47+
- {
48+
name: 'macOS latest',
49+
os: macos-latest,
50+
cc: 'clang',
51+
cxx: 'clang++',
52+
arch: 'x86_64',
53+
build_type: 'Release',
54+
cmake_extra_flags: ''
55+
}
56+
- {
57+
name: 'Ubuntu latest Debug',
58+
os: ubuntu-latest,
59+
cc: 'gcc',
60+
cxx: 'g++',
61+
arch: 'x86_64',
62+
build_type: 'Debug',
63+
cmake_extra_flags: ''
64+
}
65+
- {
66+
name: 'Ubuntu 20.04',
67+
os: ubuntu-20.04,
68+
cc: 'gcc',
69+
cxx: 'g++',
70+
arch: 'x86_64',
71+
build_type: 'Release',
72+
cmake_extra_flags: ''
73+
}
74+
- {
75+
name: 'Ubuntu 18.04',
76+
os: ubuntu-18.04,
77+
cc: 'gcc',
78+
cxx: 'g++',
79+
arch: 'x86_64',
80+
build_type: 'Release',
81+
cmake_extra_flags: ''
82+
}
83+
- {
84+
name: 'Ubuntu 16.04',
85+
os: ubuntu-16.04,
86+
cc: 'gcc',
87+
cxx: 'g++',
88+
arch: 'x86_64',
89+
build_type: 'Release',
90+
cmake_extra_flags: ''
91+
}
92+
steps:
93+
- name: checkout
94+
uses: actions/checkout@v2
95+
with:
96+
fetch-depth: 8
97+
- name: dependency
98+
shell: bash
99+
run: |
100+
# this is not perfect but enought for now
101+
if [ "$RUNNER_OS" == "Linux" ]; then
102+
sudo apt-get update
103+
sudo apt-get install libasound2-dev libudev-dev libhamlib-dev gpsd
104+
elif [ "$RUNNER_OS" == "macOS" ]; then
105+
# just to simplify I use homebrew but
106+
# we can use macports (latest direwolf is already available as port)
107+
brew install portaudio hamlib gpsd
108+
elif [ "$RUNNER_OS" == "Windows" ]; then
109+
# add the folder to PATH
110+
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
111+
fi
112+
- name: create build environment
113+
run: |
114+
cmake -E make_directory ${{github.workspace}}/build
115+
- name: configure
116+
shell: bash
117+
working-directory: ${{github.workspace}}/build
118+
run: |
119+
if [ "$RUNNER_OS" == "Windows" ]; then
120+
export CC=${{ matrix.config.cc }}
121+
export CXX=${{ matrix.config.cxx }}
122+
export AR=${{ matrix.config.ar }}
123+
export WINDRES=${{ matrix.config.windres }}
124+
fi
125+
cmake $GITHUB_WORKSPACE \
126+
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
127+
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
128+
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
129+
-DCMAKE_CXX_FLAGS="-Werror" -DUNITTEST=1 \
130+
${{ matrix.config.cmake_extra_flags }} \
131+
${{ github.event.inputs.cmake_flags }}
132+
- name: build
133+
shell: bash
134+
working-directory: ${{github.workspace}}/build
135+
run: |
136+
if [ "$RUNNER_OS" == "Windows" ]; then
137+
export CC=${{ matrix.config.cc }}
138+
export CXX=${{ matrix.config.cxx }}
139+
export AR=${{ matrix.config.ar }}
140+
export WINDRES=${{ matrix.config.windres }}
141+
fi
142+
cmake --build . --config ${{ matrix.config.build_type }} \
143+
${{ matrix.config.cmake_extra_flags }} \
144+
${{ github.event.inputs.cmake_flags }}
145+
- name: test
146+
continue-on-error: true
147+
shell: bash
148+
working-directory: ${{github.workspace}}/build
149+
run: |
150+
ctest -C ${{ matrix.config.build_type }} \
151+
--parallel 2 --output-on-failure \
152+
${{ matrix.config.cmake_extra_flags }} \
153+
${{ github.event.inputs.cmake_flags }}
154+
- name: package
155+
shell: bash
156+
working-directory: ${{github.workspace}}/build
157+
run: |
158+
if [ "$RUNNER_OS" == "Windows" ] || [ "$RUNNER_OS" == "macOS" ]; then
159+
make package
160+
fi
161+
- name: archive binary
162+
uses: actions/upload-artifact@v2
163+
with:
164+
name: direwolf_${{ matrix.config.os }}_${{ matrix.config.arch }}_${{ github.sha }}
165+
path: |
166+
${{github.workspace}}/build/direwolf-*.zip
167+
${{github.workspace}}/build/direwolf.conf
168+
${{github.workspace}}/build/src/*
169+
${{github.workspace}}/build/CMakeCache.txt
170+
!${{github.workspace}}/build/src/cmake_install.cmake
171+
!${{github.workspace}}/build/src/CMakeFiles
172+
!${{github.workspace}}/build/src/Makefile

0 commit comments

Comments
 (0)