-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (112 loc) · 3.42 KB
/
cpp.yml
File metadata and controls
126 lines (112 loc) · 3.42 KB
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
name: C/C++ CI
on:
push:
branches:
- main
pull_request:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
steps:
# Step 1: Checkout Code
- name: Checkout Code
uses: actions/checkout@v4
# Step 2: Set Up Dependencies (Linux Only)
- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
build-essential \
cmake
# Step 3: Set Up Dependencies (Windows Only)
- name: Install vcpkg
if: runner.os == 'Windows'
run: |
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.bat
./vcpkg/vcpkg install glfw3:x64-windows opengl:x64-windows
# Step 3: Set Up Dependencies (macOS Only)
- name: Install Dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install cmake glfw
# Step 4: Cache CMake and Build Artifacts
- name: Cache CMake
uses: actions/cache@v3
with:
path: |
build
~/.cache/CMake
key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cmake-
# Step 5: Build Project (Linux)
- name: Build Project (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p build
cd build
cmake ..
make -j12
# Step 5: Build Project (Windows)
- name: Build Project (Windows)
if: runner.os == 'Windows'
run: |
if (Test-Path -Path "build") {
if ((Get-Item "build").PSIsContainer) {
Remove-Item -Recurse -Force "build"
} else {
Remove-Item -Force "build"
}
}
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Debug
shell: pwsh
# Step 5: Build Project (macOS)
- name: Build Project (macOS)
if: runner.os == 'macOS'
run: |
mkdir -p build
cd build
cmake ..
make -j$(sysctl -n hw.ncpu)
# # Step 6: Run Tests (Uncomment if needed)
# - name: Run Tests
# run: |
# ./scripts/run_tests.sh
# Step 6: Upload Build Artifacts (Linux)
- name: Upload Build Artifacts (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: build-artifacts-linux-${{ github.run_id }}
path: build
# Step 6: Upload Build Artifacts (Windows)
- name: Upload Build Artifacts (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: build-artifacts-windows-${{ github.run_id }}
path: build
# Step 6: Upload Build Artifacts (macOS)
- name: Upload Build Artifacts (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: build-artifacts-macos-${{ github.run_id }}
path: build