Skip to content

Commit 3ccc52a

Browse files
committed
setup ci
1 parent f6b9104 commit 3ccc52a

File tree

2 files changed

+256
-2
lines changed

2 files changed

+256
-2
lines changed

.github/workflows/main.yml

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: CMake on multiple platforms
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build_ubuntu:
8+
runs-on: ubuntu-22.04
9+
strategy:
10+
matrix:
11+
build_type: [Release]
12+
c_compiler: [clang, gcc]
13+
include:
14+
- c_compiler: clang
15+
- c_compiler: gcc
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set reusable strings
19+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
20+
id: strings
21+
shell: bash
22+
run: |
23+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
24+
- name: Configure CMake
25+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
26+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
27+
run: >
28+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
29+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
30+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
31+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
32+
-S ${{ github.workspace }}
33+
- name: Build
34+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
35+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
36+
- name: Run
37+
run: |
38+
mkdir -p output/linux_x64_${{ matrix.c_compiler }}
39+
${{ steps.strings.outputs.build-output-dir }}/dmath_test
40+
cp ${{ github.workspace }}/case_result.txt output/linux_x64_${{ matrix.c_compiler }}
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: linux_x64_${{ matrix.c_compiler }}
44+
path: output
45+
46+
build_ubuntu_multiarch:
47+
runs-on: ubuntu-22.04
48+
strategy:
49+
matrix:
50+
build_type: [Release]
51+
arch: [x86, aarch64, armv7]
52+
c_compiler: [clang, gcc]
53+
include:
54+
- arch: x86
55+
c_compiler: clang
56+
- arch: x86
57+
c_compiler: gcc
58+
- arch: aarch64
59+
c_compiler: clang
60+
- arch: aarch64
61+
c_compiler: gcc
62+
- arch: armv7
63+
c_compiler: clang
64+
- arch: armv7
65+
c_compiler: gcc
66+
steps:
67+
- uses: actions/checkout@v4
68+
with:
69+
submodules: recursive
70+
- name: Setup Alpine Linux for ${{ matrix.arch }}
71+
uses: jirutka/setup-alpine@v1
72+
with:
73+
arch: ${{ matrix.arch }}
74+
packages: gcc make cmake libc-dev linux-headers python3
75+
- name: Set reusable strings
76+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
77+
id: strings
78+
shell: bash
79+
run: |
80+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
81+
- name: Configure CMake
82+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
83+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
84+
run: >
85+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
86+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
87+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
88+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
89+
-S ${{ github.workspace }}
90+
- name: Build
91+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
92+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
93+
- name: Run
94+
run: ${{ steps.strings.outputs.build-output-dir }}/dmath_test
95+
- name: Run
96+
run: |
97+
mkdir -p output/linux_${{ matrix.arch }}_${{ matrix.c_compiler }}
98+
${{ steps.strings.outputs.build-output-dir }}/dmath_test
99+
cp ${{ github.workspace }}/case_result.txt output/linux_${{ matrix.arch }}_${{ matrix.c_compiler }}
100+
- uses: actions/upload-artifact@v4
101+
with:
102+
name: linux_${{ matrix.arch }}_${{ matrix.c_compiler }}
103+
path: output
104+
105+
build_macos:
106+
runs-on: macos-14
107+
strategy:
108+
matrix:
109+
build_type: [Release]
110+
c_compiler: [clang]
111+
steps:
112+
- uses: actions/checkout@v4
113+
- name: Set reusable strings
114+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
115+
id: strings
116+
shell: bash
117+
run: |
118+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
119+
- name: Configure CMake
120+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
121+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
122+
run: >
123+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
124+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
125+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
126+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
127+
-S ${{ github.workspace }}
128+
- name: Build
129+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
130+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
131+
- name: Run
132+
run: |
133+
mkdir -p output/macos_${{ matrix.c_compiler }}
134+
${{ steps.strings.outputs.build-output-dir }}/dmath_test
135+
cp ${{ github.workspace }}/case_result.txt output/macos_${{ matrix.c_compiler }}
136+
- uses: actions/upload-artifact@v4
137+
with:
138+
name: macos_${{ matrix.c_compiler }}
139+
path: output
140+
141+
build_win32:
142+
runs-on: windows-2022
143+
strategy:
144+
matrix:
145+
build_type: [Release]
146+
c_compiler: [cl]
147+
cpp_compiler: [cl]
148+
steps:
149+
- uses: actions/checkout@v4
150+
- name: Set reusable strings
151+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
152+
id: strings
153+
shell: bash
154+
run: |
155+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
156+
- name: Configure CMake
157+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
158+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
159+
run: >
160+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
161+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
162+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
163+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
164+
-S ${{ github.workspace }}
165+
- name: Build
166+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
167+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
168+
- name: Run
169+
run: |
170+
mkdir -p output/win32_${{ matrix.c_compiler }}
171+
${{ steps.strings.outputs.build-output-dir }}/${{ matrix.build_type }}/dmath_test.exe
172+
cp ${{ github.workspace }}/case_result.txt output/win32_${{ matrix.c_compiler }}
173+
- uses: actions/upload-artifact@v4
174+
with:
175+
name: win32_${{ matrix.c_compiler }}
176+
path: output
177+
merge:
178+
runs-on: ubuntu-22.04
179+
needs: [build_ubuntu, build_ubuntu_multiarch, build_macos, build_win32]
180+
steps:
181+
- uses: actions/checkout@v4
182+
- name: "Create output directory"
183+
run: |
184+
mkdir output
185+
mkdir output/all-in-one
186+
187+
- name: "Merge win32"
188+
uses: actions/[email protected]
189+
with:
190+
name: win32_cl
191+
path: ${{ github.workspace }}/output/all-in-one
192+
193+
- name: "Merge macos"
194+
uses: actions/[email protected]
195+
with:
196+
name: macos_clang
197+
path: ${{ github.workspace }}/output/all-in-one
198+
199+
- name: "Merge linux_x64_clang"
200+
uses: actions/[email protected]
201+
with:
202+
name: linux_x64_clang
203+
path: ${{ github.workspace }}/output/all-in-one
204+
205+
- name: "Merge linux_x64_gcc"
206+
uses: actions/[email protected]
207+
with:
208+
name: linux_x64_gcc
209+
path: ${{ github.workspace }}/output/all-in-one
210+
211+
- name: "Merge linux_x86_gcc"
212+
uses: actions/[email protected]
213+
with:
214+
name: linux_x86_gcc
215+
path: ${{ github.workspace }}/output/all-in-one
216+
217+
- name: "Merge linux_aarch64_gcc"
218+
uses: actions/[email protected]
219+
with:
220+
name: linux_aarch64_gcc
221+
path: ${{ github.workspace }}/output/all-in-one
222+
223+
- name: "Merge linux_armv7_gcc"
224+
uses: actions/[email protected]
225+
with:
226+
name: linux_armv7_gcc
227+
path: ${{ github.workspace }}/output/all-in-one
228+
229+
- name: "Merge linux_x86_clang"
230+
uses: actions/[email protected]
231+
with:
232+
name: linux_x86_clang
233+
path: ${{ github.workspace }}/output/all-in-one
234+
235+
- name: "Merge linux_aarch64_clang"
236+
uses: actions/[email protected]
237+
with:
238+
name: linux_aarch64_clang
239+
path: ${{ github.workspace }}/output/all-in-one
240+
241+
- name: "Merge linux_armv7_clang"
242+
uses: actions/[email protected]
243+
with:
244+
name: linux_armv7_clang
245+
path: ${{ github.workspace }}/output/all-in-one
246+
247+
- name: "Compare artifacts"
248+
run: |
249+
pip install pandas
250+
python scripts/all-in-one.py ${{ github.workspace }}/output
251+
252+
- name: "Upload merged artifact"
253+
uses: actions/[email protected]
254+
with:
255+
name: all-in-one
256+
path: ${{ github.workspace }}/output

compile_flags.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
-Iinclude/common
22
-Iinclude/win32
3-
-Imusl
4-
-D_XOPEN_SOURCE=700

0 commit comments

Comments
 (0)