-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (145 loc) · 5.01 KB
/
c-cpp.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# This is a basic workflow to help you get started with Actions
# inspired by gist example: NickNaso / cpp.yml
# https://gist.github.com/NickNaso/0d478f1481686d5bcc868cac06620a60
# I also found this article helpful:
# https://www.incredibuild.com/blog/using-github-actions-with-your-c-project
# See this issue in the CxxTest github page: https://github.com/CxxTest/cxxtest/issues/158
name: C/C++ CI
# Controls when the action will run. Triggers the workflow on push
on:
push:
branches: [ "main" ]
pull_request:
branches: ["main" ]
release:
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# perform static analysis of the code, to ensure no uncaught undefined behavior
cppcheck:
name: cpp-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install cppcheck
run: |
sudo apt-get install -y cppcheck
- name: cppcheck lib
run: |
cppcheck lib/ --error-exitcode=1 --std=c++14
- name: cppcheck src
run: |
cppcheck src/ --error-exitcode=1 --std=c++14
# build and test the code
build-and-test:
# The type of runner that the job will run on
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "ubuntu latest",
os: ubuntu-latest,
artifact: "ubuntu_gcc.7z",
build_type: "Release",
cc: "gcc",
cxx: "g++",
archiver: "7z a",
generators: "Ninja"
}
- {
name: "ubuntu gcc9",
os: ubuntu-latest,
artifact: "ubuntu_gcc9.7z",
build_type: "Release",
cc: "gcc",
cxx: "g++",
archiver: "7z a",
generators: "Ninja"
}
- {
name: "macOS gcc",
os: macos-latest,
artifact: "macos_gcc.7z",
build_type: "Release",
cc: "gcc",
cxx: "g++",
archiver: "7za a",
generators: "Ninja"
}
- {
name: "macOS clang",
os: macos-latest,
artifact: "macos_clang.7z",
build_type: "Release",
cc: "clang",
cxx: "clang++",
archiver: "7za a",
generators: "Ninja"
}
- {
name: "windows gcc",
os: windows-latest,
artifact: "windows_mingw.7z",
build_type: "Release",
cc: "gcc",
cxx: "g++",
archiver: "7z a",
generators: "Ninja"
}
# TODO setup windows runners
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Install dependencies on ubuntu
if: startsWith(matrix.config.name, 'ubuntu latest')
run: |
sudo apt-get update
sudo apt-get install -y cxxtest
sudo apt-get install -y gnuplot
gcc --version
- name: Install dependencies on ubuntu w/ gcc9
if: startsWith(matrix.config.name, 'ubuntu gcc9')
run: |
echo Update gcc-9 =======================================================================
echo gcc version before
gcc --version
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install cxxtest gcc-9 g++-9
sudo apt-get install -y gnuplot
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
echo gcc version after
gcc --version
- name: Install dependencies on macos
if: startsWith(matrix.config.os, 'macos')
# the last line will replace gcc with clang inside makefile
run: |
brew install cxxtest
sed 's/CC=g++/CC=${{ matrix.config.cxx }}/' makefile > changed.txt && mv changed.txt makefile
- name: Build library
shell: bash
run: make library
- name: Build THRAIN
shell: bash
run: make
# there is no cxxtest support in windows or macos, so can only run tests on ubuntu
- name: Build THRAIN tests
if: startsWith(matrix.config.os, 'ubuntu') # || startsWith(matrix.config.os, 'macos')
shell: bash
run: make tests
- name: Run tests
if: startsWith(matrix.config.os, 'ubuntu') # || startsWith(matrix.config.os, 'macos')
shell: bash
run: ./tests/tests.out
- name: Run THRAIN
# on all systems, sun sampleinput6.txt to build a white dwarf
shell: bash
run: ./thrain sampleinput6.txt