Repository navigation
849 lines (793 loc) · 32 KB
/
Copy pathosrm-backend.yml
File metadata and controls
849 lines (793 loc) · 32 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
name: osrm-backend CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
workflow_dispatch:
env:
CCACHE_TEMPDIR: /tmp/.ccache-temp
CCACHE_COMPRESS: 1
CASHER_TIME_OUT: 599 # one second less than 10m to avoid 10m timeout error: https://github.com/Project-OSRM/osrm-backend/issues/2742
CMAKE_VERSION: 3.31.0
ENABLE_NODE_BINDINGS: 'ON'
# vcpkg baseline is also pinned in vcpkg-configuration.json; this env var
# is what lukka/run-vcpkg consumes to pick the vcpkg tool version.
VCPKG_COMMIT_ID: d015e31e90838a4c9dfa3eed45979bc70d9357fc
# Use a local filesystem directory as vcpkg's binary cache. The directory
# itself is persisted across CI runs via actions/cache@v5. The x-gha
# backend was removed upstream; files+actions/cache is the replacement.
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-bincache,readwrite"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
vcpkg-smoke-prereq:
if: github.repository == 'Project-OSRM/osrm-backend'
runs-on: ubuntu-26.04
steps:
- name: Configure DNS servers
if: runner.os == 'Linux'
run: |
sudo rm -f /etc/resolv.conf
{
echo "nameserver 1.1.1.1"
echo "nameserver 8.8.8.8"
} | sudo tee /etc/resolv.conf > /dev/null
- uses: actions/checkout@v7
- uses: dorny/paths-filter@v4
id: dep_changes
with:
filters: |
deps:
- 'vcpkg.json'
- 'vcpkg-configuration.json'
- 'vcpkg-overlay-ports/**'
- 'CMakePresets.json'
- '.github/workflows/osrm-backend.yml'
- '.github/workflows/vcpkg-smoke.yml'
- name: Enable vcpkg binary cache
if: steps.dep_changes.outputs.deps == 'true'
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.vcpkg-bincache
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-x64-linux-${{ env.VCPKG_COMMIT_ID }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'vcpkg-overlay-ports/**') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ runner.arch }}-x64-linux-${{ env.VCPKG_COMMIT_ID }}-
- name: Setup vcpkg (smoke)
if: steps.dep_changes.outputs.deps == 'true'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
runVcpkgInstall: true
# Pin to top-level manifest; the default glob **/vcpkg.json would
# otherwise pick up overlay port manifests in vcpkg-overlay-ports/.
vcpkgJsonGlob: 'vcpkg.json'
env:
VCPKG_DEFAULT_TRIPLET: x64-linux
windows-release-bindings:
needs: [format-taginfo-docs, vcpkg-smoke-prereq]
strategy:
matrix:
os: [windows-2025]
runs-on: ${{ matrix.os }}
if: github.repository == 'Project-OSRM/osrm-backend'
continue-on-error: false
env:
BUILD_TYPE: Release
steps:
- name: Configure DNS servers
if: runner.os == 'Linux'
run: |
sudo rm -f /etc/resolv.conf
{
echo "nameserver 1.1.1.1"
echo "nameserver 8.8.8.8"
} | sudo tee /etc/resolv.conf > /dev/null
- uses: actions/checkout@v7
- name: Move temp directory to D drive
shell: pwsh
run: |
New-Item -ItemType Directory -Path 'D:\Temp' -Force | Out-Null
'TMP=D:\Temp' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
'TEMP=D:\Temp' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- run: cmake --version
- uses: actions/setup-node@v7
with:
node-version: 24
- run: node --version
- run: npm --version
- name: Enable vcpkg binary cache
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.vcpkg-bincache
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-x64-windows-static-md-${{ env.VCPKG_COMMIT_ID }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'vcpkg-overlay-ports/**') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ runner.arch }}-x64-windows-static-md-${{ env.VCPKG_COMMIT_ID }}-
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
# Pin to top-level manifest; the default glob **/vcpkg.json would
# otherwise pick up overlay port manifests in vcpkg-overlay-ports/.
vcpkgJsonGlob: 'vcpkg.json'
- name: Prepare environment
shell: bash
run: |
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
# cibuildwheel parses [tool.cibuildwheel.windows].environment in
# pyproject.toml as bash export statements. lukka/run-vcpkg sets
# VCPKG_ROOT with native backslashes (D:\a\...), and bash eats those
# as escapes during $VAR expansion, mangling CMAKE_TOOLCHAIN_FILE
# into "D:aosrm-backend...". Rewrite with forward slashes — CMake
# accepts both separators on Windows.
echo "VCPKG_ROOT=${VCPKG_ROOT//\\//}" >> "$GITHUB_ENV"
- run: npm install --ignore-scripts
- run: npm link --ignore-scripts
- name: Build
id: build
shell: bash
run: |
cmake --preset ci-windows -DENABLE_NODE_BINDINGS=ON
cmake --build --preset ci-windows
# TODO: MSVC goes out of memory when building our tests
# - name: Run tests
# shell: bash
# run: |
# cd build
# cmake --build . --config Release --target tests
# # TODO: run tests
# - name: Run node tests
# shell: bash
# run: |
# ./lib/binding_napi_v8/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf
# mkdir -p test/data/ch
# cp test/data/monaco.osrm* test/data/ch/
# ./lib/binding_napi_v8/osrm-contract.exe test/data/ch/monaco.osrm
# ./lib/binding_napi_v8/osrm-datastore.exe test/data/ch/monaco.osrm
# node test/nodejs/index.js
- name: Build Node package
shell: bash
run: ./scripts/ci/node_package.sh
- name: Publish Node package
if: ${{ env.PUBLISH == 'On' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: build/stage/**/*.tar.gz
omitBody: true
omitBodyDuringUpdate: true
omitName: true
omitNameDuringUpdate: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run CIBuildWheel
if: github.event_name != 'pull_request'
uses: pypa/cibuildwheel@v4.3.0
with:
output-dir: dist
# The wheel-build CMAKE_ARGS (vcpkg toolchain + triplet) and the
# delvewheel --add-path for vcpkg-installed runtime DLLs live in
# [tool.cibuildwheel.windows] in pyproject.toml. VCPKG_ROOT is
# exported by lukka/run-vcpkg above and inherited by cibuildwheel.
- name: Upload Windows wheel
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v7
with:
name: wheels-windows
path: dist/*.whl
if-no-files-found: error
format-taginfo-docs:
if: github.repository == 'Project-OSRM/osrm-backend'
runs-on: ubuntu-26.04
permissions:
contents: read
actions: write # needed by actions/cache
pull-requests: write # needed to post PR comments with instructions
steps:
- uses: actions/checkout@v7
- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: latest
- name: Enable Node.js cache
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Prepare environment
run: |
# sudo apt-get update -y
sudo apt-get install -y clang-format-22
npm ci --ignore-scripts
clang-format-22 --version
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Run `pre-commit`
uses: pre-commit/action@v3.0.1
- name: Validate taginfo
run: ./scripts/check_taginfo.py taginfo.json profiles/car.lua
# ---- code formatting ----
- name: Check code formatting
id: format
run: |
./scripts/format.sh
if ! git diff --exit-code --quiet; then
echo "dirty=true" >> "$GITHUB_OUTPUT"
git diff > /tmp/formatting-fixes.patch
cat /tmp/formatting-fixes.patch
fi
- name: Upload formatting patch
if: steps.format.outputs.dirty == 'true'
uses: actions/upload-artifact@v7
with:
name: formatting-fixes
path: /tmp/formatting-fixes.patch
retention-days: 7
- name: Post formatting instructions on PR
if: steps.format.outputs.dirty == 'true' && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body "## :wrench: Code Formatting Required
\`./scripts/format.sh\` produced changes on this branch.
**Option 1 — Download and apply** [formatting-fixes.zip](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/formatting-fixes.zip):
\`\`\`bash
curl -LO https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/formatting-fixes.zip
unzip formatting-fixes.zip
git apply formatting-fixes.patch
\`\`\`
**Option 2 — Run locally:**
\`\`\`bash
./scripts/format.sh
\`\`\`
Then commit the changes."
env:
GH_TOKEN: ${{ github.token }}
- name: Stash formatting changes
if: steps.format.outputs.dirty == 'true'
run: git stash push --message "formatting changes"
# ---- api documentation ----
- name: Check API documentation
id: docs
run: |
npm run docs
if ! git diff --exit-code --quiet; then
echo "dirty=true" >> "$GITHUB_OUTPUT"
git diff > /tmp/docs-fixes.patch
fi
- name: Upload documentation patch
if: steps.docs.outputs.dirty == 'true'
uses: actions/upload-artifact@v7
with:
name: docs-fixes
path: /tmp/docs-fixes.patch
retention-days: 7
- name: Post documentation instructions on PR
if: steps.docs.outputs.dirty == 'true' && github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body "## :memo: API Documentation Required
\`npm run docs\` produced changes on this branch.
**Option 1 — Download and apply** [docs-fixes.zip](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/docs-fixes.zip):
\`\`\`bash
curl -LO https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/docs-fixes.zip
unzip docs-fixes.zip
git apply docs-fixes.patch
\`\`\`
**Option 2 — Run locally:**
\`\`\`bash
npm run docs
\`\`\`
Then commit the changes."
env:
GH_TOKEN: ${{ github.token }}
- name: Restore formatting changes
if: steps.format.outputs.dirty == 'true'
run: git stash pop
# ---- final checks ----
- name: Run npm audit
run: npm audit --production
- name: Fail on outstanding changes
if: steps.format.outputs.dirty == 'true' || steps.docs.outputs.dirty == 'true'
run: |
if [[ "${{ steps.format.outputs.dirty }}" == 'true' ]]; then
echo "::error title=Code formatting out of date::Run './scripts/format.sh' locally, or download formatting-fixes.zip from the workflow artifacts."
fi
if [[ "${{ steps.docs.outputs.dirty }}" == 'true' ]]; then
echo "::error title=API documentation out of date::Run 'npm run docs' locally, or download docs-fixes.zip from the workflow artifacts."
fi
exit 1
docker-build-extract-test:
strategy:
matrix:
docker-base-image: ['debian']
needs: [format-taginfo-docs, vcpkg-smoke-prereq]
if: github.repository == 'Project-OSRM/osrm-backend'
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Configure DNS servers
if: runner.os == 'Linux'
run: |
sudo rm -f /etc/resolv.conf
{
echo "nameserver 1.1.1.1"
echo "nameserver 8.8.8.8"
} | sudo tee /etc/resolv.conf > /dev/null
- name: Check out the repo
uses: actions/checkout@v7
- name: Enable osm.pbf cache
uses: actions/cache@v6
with:
path: berlin-latest.osm.pbf
key: v1-berlin-osm-pbf
restore-keys: |
v1-berlin-osm-pbf
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Docker build
uses: docker/build-push-action@v7
with:
context: .
file: docker/Dockerfile-${{ matrix.docker-base-image }}
tags: osrm-backend-local
load: true
# Persist BuildKit layer + vcpkg/ccache mount cache across runs via
# GitHub Actions cache. Scope per base image so different images don't
# collide.
cache-from: type=gha,scope=docker-${{ matrix.docker-base-image }}
cache-to: type=gha,mode=max,scope=docker-${{ matrix.docker-base-image }}
- name: Test Docker image
run: |
if [ ! -f "${PWD}/berlin-latest.osm.pbf" ]; then
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
fi
TAG=osrm-backend-local
# when `--memory-swap` value equals `--memory` it means container won't use swap
# see https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
MEMORY_ARGS="--memory=1g --memory-swap=1g"
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-extract --dump-nbg-graph -p /opt/car.lua /data/berlin-latest.osm.pbf
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-components /data/berlin-latest.osrm.nbg /data/berlin-latest.geojson
if [ ! -s "${PWD}/berlin-latest.geojson" ]
then
>&2 echo "No berlin-latest.geojson found"
exit 1
fi
# removing `.osrm.nbg` to check that whole pipeline works without it
rm -rf "${PWD}/berlin-latest.osrm.nbg"
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-partition /data/berlin-latest.osrm
docker run $MEMORY_ARGS -t -v "${PWD}:/data" "${TAG}" osrm-customize /data/berlin-latest.osrm
docker run $MEMORY_ARGS --name=osrm-container -t -p 5000:5000 -v "${PWD}:/data" "${TAG}" osrm-routed --algorithm mld /data/berlin-latest.osrm &
curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
docker stop osrm-container
build-matrix:
needs: [format-taginfo-docs, vcpkg-smoke-prereq]
if: github.repository == 'Project-OSRM/osrm-backend'
strategy:
matrix:
include:
- name: clang-20-release
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: clang-20
CXXCOMPILER: clang++-20
ENABLE_LTO: ON
- name: clang-20-debug
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Debug
CCOMPILER: clang-20
CXXCOMPILER: clang++-20
ENABLE_ASSERTIONS: ON
ENABLE_LTO: OFF
- name: clang-19-release
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: clang-19
CXXCOMPILER: clang++-19
ENABLE_LTO: OFF
- name: clang-18-release
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: clang-18
CXXCOMPILER: clang++-18
ENABLE_LTO: OFF
- name: clang-20-debug-clang-tidy
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Debug
CCOMPILER: clang-20
CXXCOMPILER: clang++-20
ENABLE_CLANG_TIDY: ON
NODE_PACKAGE_TESTS_ONLY: ON
ENABLE_LTO: OFF
- name: clang-20-debug-asan-ubsan
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Debug
CCOMPILER: clang-20
CXXCOMPILER: clang++-20
ENABLE_SANITIZER: ON
TARGET_ARCH: x86_64-asan-ubsan
OSRM_CONNECTION_RETRIES: 10
OSRM_CONNECTION_EXP_BACKOFF_COEF: 1.5
- name: clang-20-debug-cov
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Debug
CCOMPILER: clang-20
CXXCOMPILER: clang++-20
ENABLE_COVERAGE: ON
- name: gcc-14-release
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: gcc-14
CXXCOMPILER: g++-14
- name: gcc-15-release
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: gcc-15
CXXCOMPILER: g++-15
- name: linux-release-bindings
build_bindings: true
continue-on-error: false
node: 24
runs-on: ubuntu-26.04
BUILD_TYPE: Release
CCOMPILER: clang-18
CXXCOMPILER: clang++-18
NODE_PACKAGE_TESTS_ONLY: ON
- name: linux-arm64-release-bindings
build_bindings: true
continue-on-error: false
node: 24
runs-on: ubuntu-26.04-arm
BUILD_TYPE: Release
CCOMPILER: clang-18
CXXCOMPILER: clang++-18
ENABLE_LTO: OFF
- name: macos-26-arm64-release
continue-on-error: true
node: 24
runs-on: macos-26 # arm64
BUILD_TYPE: Release
CCOMPILER: clang
CXXCOMPILER: clang++
vcpkg_triplet: arm64-osx
# python & nodeJS release bindings
- name: macos-15-arm64-release-bindings
build_bindings: true
continue-on-error: true
node: 24
runs-on: macos-15 # arm64
BUILD_TYPE: Release
CCOMPILER: clang
CXXCOMPILER: clang++
vcpkg_triplet: arm64-osx
name: ${{ matrix.name}}
continue-on-error: ${{ matrix.continue-on-error }}
runs-on: ${{ matrix.runs-on }}
env:
BUILD_TYPE: ${{ matrix.BUILD_TYPE }}
BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }}
CCOMPILER: ${{ matrix.CCOMPILER }}
CFLAGS: ${{ matrix.CFLAGS }}
CXXCOMPILER: ${{ matrix.CXXCOMPILER }}
CXXFLAGS: ${{ matrix.CXXFLAGS }}
ENABLE_ASSERTIONS: ${{ matrix.ENABLE_ASSERTIONS }}
ENABLE_CLANG_TIDY: ${{ matrix.ENABLE_CLANG_TIDY }}
ENABLE_COVERAGE: ${{ matrix.ENABLE_COVERAGE }}
ENABLE_SANITIZER: ${{ matrix.ENABLE_SANITIZER }}
NODE_PACKAGE_TESTS_ONLY: ${{ matrix.NODE_PACKAGE_TESTS_ONLY }}
TARGET_ARCH: ${{ matrix.TARGET_ARCH }}
OSRM_CONNECTION_RETRIES: ${{ matrix.OSRM_CONNECTION_RETRIES }}
OSRM_CONNECTION_EXP_BACKOFF_COEF: ${{ matrix.OSRM_CONNECTION_EXP_BACKOFF_COEF }}
ENABLE_LTO: ${{ matrix.ENABLE_LTO }}
BUILD_BINDINGS: ${{ matrix.build_bindings }}
steps:
- name: Configure DNS servers
if: runner.os == 'Linux'
run: |
sudo rm -f /etc/resolv.conf
{
echo "nameserver 1.1.1.1"
echo "nameserver 8.8.8.8"
} | sudo tee /etc/resolv.conf > /dev/null
- uses: actions/checkout@v7
with:
fetch-tags: true
- name: Build machine architecture
run: uname -m
- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
- name: Enable Node.js cache
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Restore compiler cache
id: ccache-restore
uses: actions/cache/restore@v6
with:
path: ~/.ccache
key: ccache-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
ccache-${{ matrix.name }}-
- name: Enable vcpkg binary cache
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.vcpkg-bincache
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}-${{ matrix.vcpkg_triplet || matrix.name }}-${{ env.VCPKG_COMMIT_ID }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'vcpkg-overlay-ports/**') }}
restore-keys: |
vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}-${{ matrix.vcpkg_triplet || matrix.name }}-${{ env.VCPKG_COMMIT_ID }}-
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
# Pin to top-level manifest; the default glob **/vcpkg.json would
# otherwise pick up overlay port manifests in vcpkg-overlay-ports/.
vcpkgJsonGlob: 'vcpkg.json'
- name: Enable test cache
uses: actions/cache@v6
with:
path: ${{github.workspace}}/test/cache
key: v4-test-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
v4-test-${{ matrix.name }}-
- name: Prepare environment
run: |
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
mkdir -p $HOME/.ccache
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
echo "OSRM_BUILD_DIR=${GITHUB_WORKSPACE}/build-osrm" >> $GITHUB_ENV
if [[ "$ENABLE_SANITIZER" == 'ON' ]]; then
# We can only set this after checkout once we know the workspace directory
echo "LSAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/leaksanitizer.conf" >> $GITHUB_ENV
echo "UBSAN_OPTIONS=symbolize=1:halt_on_error=1:print_stacktrace=1:suppressions=${GITHUB_WORKSPACE}/scripts/ci/undefinedsanitizer.conf" >> $GITHUB_ENV
echo "ASAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/addresssanitizer.conf" >> $GITHUB_ENV
fi
if [[ "${RUNNER_OS}" == "Linux" ]]; then
echo "JOBS=$((`nproc` + 1))" >> $GITHUB_ENV
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
echo "JOBS=$((`sysctl -n hw.ncpu` + 1))" >> $GITHUB_ENV
fi
- name: Install compiler and ccache
run: |
if [[ "${RUNNER_OS}" == "Linux" ]]; then
sudo apt-get update -y
sudo apt-get install -y ${CCOMPILER} ${CXXCOMPILER} ccache
if [[ "${ENABLE_COVERAGE}" == "ON" ]]; then
sudo apt-get install -y lcov llvm-20
fi
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
brew install ccache
fi
- name: Prepare build
run: |
mkdir ${OSRM_BUILD_DIR}
ccache --max-size=256M
npm ci --ignore-scripts
if [[ "${ENABLE_COVERAGE}" == "ON" ]]; then
lcov --directory . --zerocounters # clean cached files
fi
echo "CC=${CCOMPILER}" >> $GITHUB_ENV
echo "CXX=${CXXCOMPILER}" >> $GITHUB_ENV
- name: Build and install OSRM
id: build
run: |
echo "Using ${JOBS} jobs"
# so vcpkg's bincache is consistent with cibuildwheel (python bindings)
if [[ "${RUNNER_OS}" == "macOS" && "${BUILD_BINDINGS}" == "true" ]]; then
export MACOSX_DEPLOYMENT_TARGET=15.0
fi
pushd ${OSRM_BUILD_DIR}
ccache --zero-stats
cmake -S ${GITHUB_WORKSPACE} -B . \
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \
-DENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY:-OFF} \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} \
-DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
-DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \
-DENABLE_CCACHE=ON \
-DENABLE_LTO=${ENABLE_LTO:-ON} \
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR}
make --jobs=${JOBS}
if [[ "${NODE_PACKAGE_TESTS_ONLY}" != "ON" ]]; then
make tests --jobs=${JOBS}
make benchmarks --jobs=${JOBS}
sudo make install
if [[ "${RUNNER_OS}" == "Linux" ]]; then
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OSRM_INSTALL_DIR}/lib" >> $GITHUB_ENV
fi
echo "PKG_CONFIG_PATH=${OSRM_INSTALL_DIR}/lib/pkgconfig" >> $GITHUB_ENV
fi
popd
- name: Run all tests
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' }}
run: |
make -C test/data benchmark
# macOS SIP strips the linker path. Reset this inside the running shell
export LD_LIBRARY_PATH=${{ env.LD_LIBRARY_PATH }}
# All tests assume to be run from the build directory
pushd ${OSRM_BUILD_DIR}
for i in ./unit_tests/*-tests ; do echo Running $i ; $i ; done
if [ -z "${ENABLE_SANITIZER}" ]; then
npm run nodejs-tests
fi
popd
./scripts/ci/test_cli_parsing.sh -b "${OSRM_BUILD_DIR}"
# Coverage counts accumulate into shared .gcda files, which concurrent
# osrm-routed processes clobber, so a parallel run reports a different
# number every time. Run the suite serially where it is measured. See
# codecov.yml.
if [[ "${ENABLE_COVERAGE}" == "ON" ]]; then
npm test
else
npm test -- --parallel $JOBS
fi
- name: Generate coverage report
if: ${{ matrix.ENABLE_COVERAGE == 'ON' }}
run: |
cat > llvm-gcov.sh <<'EOF'
#!/usr/bin/env bash
exec llvm-cov-20 gcov "$@"
EOF
chmod +x llvm-gcov.sh
lcov --gcov-tool "${PWD}/llvm-gcov.sh" --directory "${OSRM_BUILD_DIR}" --capture --ignore-errors inconsistent,format --output-file coverage.lcov
lcov --ignore-errors inconsistent,format --remove coverage.lcov '*/test/*' '*/unit_tests/*' --output-file coverage.lcov.filtered
- name: Upload coverage to codecov.io
if: ${{ matrix.ENABLE_COVERAGE == 'ON' }}
uses: codecov/codecov-action@v7
with:
files: coverage.lcov.filtered
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Use Node 22
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v7
with:
node-version: 22
- name: Run Node package tests on Node 22
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
run: |
node --version
npm run nodejs-tests
- name: Use Node 24
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v7
with:
node-version: 24
- name: Run Node package tests on Node 24
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
run: |
node --version
npm run nodejs-tests
- name: Use Node latest
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
uses: actions/setup-node@v7
with:
node-version: latest
- name: Run Node package tests on Node-latest
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
run: |
node --version
npm run nodejs-tests
- name: Upload test logs
uses: actions/upload-artifact@v7
if: failure()
with:
name: logs
path: test/logs/
- name: Build Node package
if: ${{ env.BUILD_BINDINGS }}
run: ./scripts/ci/node_package.sh
- name: Publish Node package
if: ${{ env.BUILD_BINDINGS && env.PUBLISH == 'On' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: build/stage/**/*.tar.gz
omitBody: true
omitBodyDuringUpdate: true
omitName: true
omitNameDuringUpdate: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
# Python bindings
- name: Set up Python
if: ${{ env.BUILD_BINDINGS }}
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Build sdist
if: ${{ env.BUILD_BINDINGS && runner.os == 'Linux' }}
run: |
python -m pip install build
python -m build --sdist
- name: Locate sdist
if: ${{ env.BUILD_BINDINGS && runner.os == 'Linux' }}
id: sdist
shell: bash
run: echo "path=$(ls dist/*.tar.gz | head -n1)" >> "$GITHUB_OUTPUT"
- name: Run cibuildwheel
uses: pypa/cibuildwheel@v4.3.0
if: ${{ env.BUILD_BINDINGS }}
with:
# for linux build the wheel from the sdist
package-dir: ${{ runner.os == 'Linux' && steps.sdist.outputs.path || '.' }}
output-dir: dist
env:
# The full Linux env (LD_LIBRARY_PATH, CCACHE_DIR, CMAKE_ARGS for the
# vcpkg toolchain) lives in [tool.cibuildwheel.linux].environment in
# pyproject.toml. Setting CIBW_ENVIRONMENT_LINUX here would *replace*
# that whole block (cibuildwheel doesn't merge), so we don't.
CIBW_CONTAINER_ENGINE: "docker; create_args: --volume /home/runner/.ccache:/ccache"
CIBW_CONFIG_SETTINGS_MACOS: "cmake.define.CMAKE_CXX_COMPILER_LAUNCHER=ccache cmake.define.CMAKE_C_COMPILER_LAUNCHER=ccache"
- name: Upload wheels and sdist
if: ${{ env.BUILD_BINDINGS && env.PUBLISH == 'On' }}
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.name }}
path: |
dist/*.whl
dist/*.tar.gz
if-no-files-found: error
- name: Save compiler cache
if: always() && steps.build.outcome != 'cancelled'
uses: actions/cache/save@v6
with:
path: ~/.ccache
key: ccache-${{ matrix.name }}-${{ github.sha }}
- name: Show CCache statistics
run: |
ccache -p
ccache -s
ci-complete:
runs-on: ubuntu-latest
needs: [build-matrix, windows-release-bindings, docker-build-extract-test]
if: github.repository == 'Project-OSRM/osrm-backend'
steps:
- name: Configure DNS servers
if: runner.os == 'Linux'
run: |
sudo rm -f /etc/resolv.conf
{
echo "nameserver 1.1.1.1"
echo "nameserver 8.8.8.8"
} | sudo tee /etc/resolv.conf > /dev/null
- name: Fail if any dependency failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- run: echo "CI complete"