forked from osquery/osquery
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (161 loc) · 5.64 KB
/
Copy pathtest.yml
File metadata and controls
186 lines (161 loc) · 5.64 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: OSQuery Test
permissions:
contents: write
packages: write
actions: write
pull-requests: write
attestations: write
id-token: write
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [master]
paths-ignore:
- "**/*.md"
concurrency:
group: pr-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
REGISTRY: "ghcr.io"
ORGANISATION: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
CMAKE_BUILD_TYPE: Release
BINARY_NAME: osqueryd
# =============================================================================
# JOBS
# =============================================================================
jobs:
build_macos:
name: "Build C Client for (${{ matrix.os }} ${{ matrix.os_arch }})"
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- name: "macOS x86-64"
os: macos-15-intel
os_arch: x86-64
cmake_arch: x86_64
artifact_name: osquery-macos-x64
- name: "macOS ARM64"
os: macos-15 # pinned: Xcode 26 on macos-latest fails to compile boost mpl
os_arch: arm64
cmake_arch: arm64
artifact_name: osquery-macos-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Xcode Command Line Tools
shell: bash
run: |
# Install Xcode if not already installed
if ! xcode-select -p >/dev/null 2>&1; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
# Wait for installation to complete
while ! xcode-select -p >/dev/null 2>&1; do
echo "Waiting for Xcode Command Line Tools installation..."
sleep 10
done
fi
- name: Install macOS Dependencies
run: brew install ccache git git-lfs cmake python clang-format flex bison cppcheck
shell: bash
# ccache 4.x defaults to ~/Library/Caches/ccache on macOS
- name: Configure ccache
run: |
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=2G" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ matrix.os_arch }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.os_arch }}-ccache-
- name: Setup Build Environment
run: |
echo "Setting up build environment for ${{ matrix.os_arch }}..."
export SDKROOT=$(xcrun --show-sdk-path)
export CFLAGS="-isysroot $SDKROOT"
export CXXFLAGS="-isysroot $SDKROOT"
echo "SDKROOT=$SDKROOT" >> $GITHUB_ENV
echo "CFLAGS=-isysroot $SDKROOT" >> $GITHUB_ENV
echo "CXXFLAGS=-isysroot $SDKROOT" >> $GITHUB_ENV
- name: Configure CMake
run: |
echo "Creating build directory and configuring..."
mkdir -p build && cd build
cmake \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.CMAKE_OSX_DEPLOYMENT_TARGET }} \
-DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_OSX_SYSROOT=$SDKROOT \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} \
-DOSQUERY_VERSION="5.9.1" \
..
echo "CMake configuration completed"
- name: Build Project
run: |
echo "Starting build for ${{ matrix.os_arch }}..."
cd build
CPU_COUNT=$(sysctl -n hw.ncpu)
echo "Building with $CPU_COUNT parallel jobs"
time cmake --build . -j $CPU_COUNT
echo "Build completed successfully"
- name: ccache statistics
if: always()
run: ccache --show-stats
build_windows:
name: "Build C Client for (${{ matrix.os }} ${{ matrix.os_arch }})"
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
defaults:
run:
shell: cmd
strategy:
fail-fast: false
matrix:
include:
- name: "Windows x64"
os: windows-2022 # pinned: windows-latest is VS 2026; generator below needs VS 17
os_arch: x64
artifact_name: osquery-windows-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Visual Studio Build Tools
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.os_arch }}
- name: Configure CMake for ${{ matrix.os }}
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A ${{ matrix.os_arch }} -DOSQUERY_VERSION="5.9.1" ..
- name: Build OSQuery for Windows ${{ matrix.os_arch }} with MSBuild
run: |
cd build
cmake --build . --config RelWithDebInfo -j10
all-checks:
name: "All Checks"
needs: [build_macos, build_windows]
runs-on: ubuntu-latest
if: always()
steps:
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
- run: echo "All checks passed"