forked from lasp/xmera
-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (189 loc) · 6.91 KB
/
pull-request.yml
File metadata and controls
220 lines (189 loc) · 6.91 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: "Pull Request Test"
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
env:
USERNAME: ${{ github.repository_owner }}
FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite"
VCPKG_FEATURE_FLAGS: "manifests,registries,binarycaching"
CMAKE_BUILD_PARALLEL_LEVEL: 4
CTEST_PARALLEL_LEVEL: 4
CTEST_OUTPUT_ON_FAILURE: 1
jobs:
pre-commit:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements.txt
**/pyproject.toml
**/requirements*.txt
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install clang-format (Linux static binary)
run: |
sudo wget -qO /usr/local/bin/clang-format https://github.com/cpp-linter/clang-tools-static-binaries/releases/latest/download/clang-format-20_linux-amd64
sudo chmod a+x /usr/local/bin/clang-format
clang-format --version
- id: file_changes
uses: tj-actions/changed-files@v46
- name: Run pre-commit (changed files)
uses: pre-commit/action@v3.0.1
with:
extra_args: --color always --files ${{ steps.file_changes.outputs.all_changed_files }}
build-test:
name: Build & Test (${{ matrix.os }} / py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
if: ${{ github.event.pull_request.draft == false }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-14]
python-version: ["3.9", "3.10", "3.11"]
permissions:
contents: read
packages: write
actions: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements.txt
**/pyproject.toml
**/requirements*.txt
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
ninja-build build-essential \
pkg-config autoconf automake libtool \
zip unzip \
bison swig \
libdrm-dev \
libx11-dev libxkbcommon-x11-dev libx11-xcb-dev \
libxft-dev libxext-dev libgles2-mesa-dev \
libxi-dev libxtst-dev libxrandr-dev libltdl-dev \
libgtk2.0-dev \
python3-setuptools python3-jinja2 python3-tk \
mono-complete
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_ANALYTICS: 1
run: |
brew install ninja swig pkg-config mono || true
swig -version
mono --version || true
- name: Setup CMake 3.28.3
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.28.3'
- name: Install vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgJsonGlob: "src/vcpkg.json"
vcpkgConfigurationJsonGlob: "src/vcpkg-configuration.json"
- name: Cache vcpkg build artifacts
uses: actions/cache@v4
with:
path: |
${{ runner.workspace }}/b/vcpkg/installed
${{ runner.workspace }}/b/vcpkg/packages
${{ runner.workspace }}/b/vcpkg/buildtrees
key: vcpkg-${{ runner.os }}-${{ hashFiles('src/vcpkg.json', 'src/vcpkg-configuration.json') }}
- name: Add NuGet sources for vcpkg binary cache (portable)
env:
VCPKG_EXE: ${{ runner.workspace }}/b/vcpkg/vcpkg
run: |
set -euo pipefail
NUGET="$(${VCPKG_EXE} fetch nuget | tail -n 1)"
# Build the command invocation safely (handles paths with spaces)
if [[ "$NUGET" == *.exe ]]; then
NUGET_CMD=(mono "$NUGET")
else
# e.g., "nuget" shim from Mono on macOS, or a native path
NUGET_CMD=("$NUGET")
fi
echo "Using NuGet CLI: ${NUGET_CMD[*]}"
"${NUGET_CMD[@]}" sources add \
-Source "${FEED_URL}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${USERNAME}" \
-Password "${{ secrets.GH_VCPKG_PACKAGES_TOKEN }}"
"${NUGET_CMD[@]}" setapikey "${{ secrets.GH_VCPKG_PACKAGES_TOKEN }}" \
-Source "${FEED_URL}"
- name: Create virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
python -V
pip -V
- name: Install required Python dependencies
run: |
source .venv/bin/activate
python -m pip install -r requirements.txt
- name: Configure (CMake preset)
working-directory: src
env:
VCPKG_BINARY_SOURCES: "clear;nuget,${{ env.FEED_URL }},readwrite"
run: cmake --preset fuzz-smoke-test
- name: Build
working-directory: src
run: cmake --build ../build --parallel
- name: Install Xmera (editable)
run: |
source .venv/bin/activate
cmake --install build --prefix $(pwd)/dist
python -m pip install -e .
- name: Run Python tests
run: |
source .venv/bin/activate
cd src
pytest -n auto -m "not scenarioTest" --junitxml=../junit/test-results-${{ matrix.python-version }}.xml
- name: Upload pytest test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: pytest-${{ matrix.os }}-py${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
retention-days: 7
- name: Run C/C++ unit tests (include fuzz-smoke)
working-directory: ./build
env:
CTEST_PARALLEL_LEVEL: 1
run: ctest --output-on-failure -LE fuzz
- name: Upload CMake & test logs on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: cmake-logs-${{ matrix.os }}-py${{ matrix.python-version }}
path: |
dist3/CMakeCache.txt
dist3/CMakeFiles/CMakeOutput.log
dist3/CMakeFiles/CMakeError.log
**/Testing/Temporary/LastTest.log
retention-days: 7