Skip to content

Commit

Permalink
Add CI workflow of tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tdcosta100 committed Oct 22, 2024
1 parent 8554ab9 commit 86d755f
Show file tree
Hide file tree
Showing 11 changed files with 353 additions and 37 deletions.
243 changes: 243 additions & 0 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
name: windows-ci

on:
workflow_dispatch:
push:
branches:
- main
- windows-*.*.x
tags:
- windows-*

pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# INFO: We are cancelling the concurrency group if the change is on PR. For workflow dispatch, this will not work.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions:
id-token: write # needed for AWS
actions: read # needed for CodeQL
contents: read # needed for CodeQL
security-events: write # needed for CodeQL

jobs:
pre-job:
runs-on: windows-2022
outputs:
should_skip: ${{ github.event_name != 'workflow_dispatch' && steps.changed-files.outputs.any_modified != 'true' }}
steps:
- run: |
git config --system core.longpaths true
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get all Windows files that have changed
if: github.event_name != 'workflow_dispatch'
id: changed-files
uses: tj-actions/changed-files@v45

- name: List changed files
if: steps.changed-files.outputs.any_modified == 'true'
shell: bash
run: |
echo "Changed file(s): ${{ steps.changed-files.outputs.all_changed_files }}"
windows-build-and-test:
if: needs.pre_job.outputs.should_skip != 'true'
needs: pre-job
strategy:
matrix:
renderer: [opengl, egl, vulkan, osmesa]
rendering_mode: [legacy, drawable]
exclude:
- renderer: vulkan
rendering_mode: legacy
runs-on: windows-2022
steps:
- run: |
git config --system core.longpaths true
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp

- uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.renderer }}-${{ matrix.rendering_mode }}

- if: matrix.rendering_mode == 'legacy'
shell: bash
run: echo rendering_mode_flag_cmake=-DMLN_LEGACY_RENDERER=ON >> "$GITHUB_ENV"

- if: matrix.rendering_mode == 'drawable'
shell: bash
run: echo rendering_mode_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV"

- if: matrix.renderer == 'opengl'
shell: bash
run: echo renderer_flag_cmake="-DMLN_WITH_OPENGL=ON" >> "$GITHUB_ENV"

- if: matrix.renderer == 'egl'
shell: bash
run: echo renderer_flag_cmake="-DMLN_WITH_EGL=ON" >> "$GITHUB_ENV"

- if: matrix.renderer == 'vulkan'
shell: bash
run: echo renderer_flag_cmake="-DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF" >> "$GITHUB_ENV"

- if: matrix.renderer == 'osmesa'
shell: bash
run: echo renderer_flag_cmake="-DMLN_WITH_OSMESA=ON" >> "$GITHUB_ENV"

- uses: ilammy/msvc-dev-cmd@v1

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Configure MapLibre Native Core
env:
CI: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
cmake --version
cmake -B build -GNinja `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
${{ env.renderer_flag_cmake }} `
${{ env.rendering_mode_flag_cmake }}
- name: Build MapLibre Native Core
run: |
cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner mbgl-expression-test mbgl-render mbgl-benchmark-runner
# mbgl-render (used for size test) & mbgl-benchmark-runner

- name: Upload mbgl-render as artifact
if: matrix.renderer == 'drawable' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: mbgl-render
path: |
build/bin/mbgl-render.exe
- name: Upload mbgl-benchmark-runner as artifact
if: matrix.renderer == 'drawable' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: mbgl-benchmark-runner
path: |
build/mbgl-benchmark-runner.exe
- name: Configure AWS Credentials
if: matrix.renderer == 'drawable' && github.ref == 'refs/heads/main' && vars.OIDC_AWS_ROLE_TO_ASSUME
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.run_id }}

- name: Upload mbgl-render & mbgl-benchmark-runner to S3
if: matrix.renderer == 'drawable' && github.ref == 'refs/heads/main' && vars.OIDC_AWS_ROLE_TO_ASSUME
run: |
aws s3 cp build/bin/mbgl-render.exe s3://maplibre-native/mbgl-render-main
aws s3 cp build/mbgl-benchmark-runner.exe s3://maplibre-native/mbgl-benchmark-runner-main
# CodeQL

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"

- name: Download Mesa3D
run: |
Invoke-WebRequest https://github.com/pal1000/mesa-dist-win/releases/download/24.2.5/mesa3d-24.2.5-release-msvc.7z -OutFile mesa3d.7z
- name: Extract Mesa3D files for OpenGL
if: matrix.renderer != 'vulkan'
run: |
& 'C:\Program Files\7-Zip\7z.exe' e -obuild .\mesa3d.7z x64\opengl32.dll x64\libgallium_wgl.dll x64\libGLESv2.dll x64\libglapi.dll
- name: Extract Mesa3D files for Vulkan
if: matrix.renderer == 'vulkan'
run: |
& 'C:\Program Files\7-Zip\7z.exe' e -obuild .\mesa3d.7z x64\lvp_icd.x86_64.json x64\vulkan_lvp.dll
- name: Extract Mesa3D files for OSMesa
if: matrix.renderer == 'osmesa'
run: |
& 'C:\Program Files\7-Zip\7z.exe' e -obuild .\mesa3d.7z x64\osmesa.dll
# unit tests

- name: Configure Mesa3D drivers (OpenGL)
if: matrix.renderer != 'vulkan'
shell: bash
run: |
echo GALLIUM_DRIVER="llvmpipe" >> "$GITHUB_ENV"
- name: Configure Mesa3D drivers (Vulkan)
if: matrix.renderer == 'vulkan'
shell: bash
run: |
echo VK_DRIVER_FILES="${{ github.workspace }}/build/lvp_icd.x86_64.json" >> "$GITHUB_ENV"
echo VK_LAYER_PATH="${{ github.workspace }}/build" >> "$GITHUB_ENV"
echo VK_LOADER_DRIVERS_SELECT="*lvp*" >> "$GITHUB_ENV"
- name: Run C++ tests
continue-on-error: ${{ matrix.renderer == 'vulkan' }}
shell: bash
run: build/mbgl-test-runner.exe

# render tests

- name: Run render test
id: render_test
shell: bash
run: build/mbgl-render-test-runner.exe --manifestPath=metrics/windows-${{ matrix.renderer }}.json

- name: Upload render test result
if: always() && steps.render_test.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: render-test-result-${{ matrix.renderer }}
path: |
metrics/windows-${{ matrix.renderer }}.html
# expression tests

- name: Run expression test
shell: bash
run: build/expression-test/mbgl-expression-test.exe

- if: github.event_name == 'pull_request'
uses: ./.github/actions/save-pr-number

windows-ci-result:
name: Windows CI Result
if: needs.pre-job.outputs.should_skip != 'true' && always()
runs-on: windows-2022
needs:
- pre-job
- windows-build-and-test
steps:
- name: Mark result as failed
if: needs.windows-build-and-test.result != 'success'
shell: bash
run: exit 1
14 changes: 14 additions & 0 deletions metrics/windows-drawable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"base_test_path": "integration",
"cache_path": "cache-style.db",
"expectation_paths": [
],
"ignore_paths": [
"ignores/platform-all.json"
],
"metric_path": "linux-gcc8-release",
"probes": [
"probeGFX",
"probeNetwork"
]
}
14 changes: 14 additions & 0 deletions metrics/windows-legacy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"base_test_path": "integration",
"cache_path": "cache-style.db",
"expectation_paths": [
],
"ignore_paths": [
"ignores/platform-all.json"
],
"metric_path": "linux-gcc8-release",
"probes": [
"probeGFX",
"probeNetwork"
]
}
14 changes: 14 additions & 0 deletions metrics/windows-vulkan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"base_test_path": "integration",
"cache_path": "cache-style.db",
"expectation_paths": [
],
"ignore_paths": [
"ignores/platform-all.json"
],
"metric_path": "linux-gcc8-release",
"probes": [
"probeGFX",
"probeNetwork"
]
}
19 changes: 14 additions & 5 deletions platform/windows/Get-VendorPackages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,33 @@ foreach($letter in [byte][char]'Z'..[byte][char]'A')
if(-not (Test-Path $vcpkg_temp_dir))
{
& subst $vcpkg_temp_dir ([System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg'))
$env:VCPKG_ROOT = ('{0}\' -f $vcpkg_temp_dir)
break
}
}

switch($Renderer)
{
'EGL' { $renderer_packages = @('egl', 'opengl-registry'); break }
'OSMesa' { $renderer_packages = @(''); break }
'OSMesa' { $renderer_packages = @(); break }
'OpenGL' { $renderer_packages = @('opengl-registry'); break }
'Vulkan' { $renderer_packages = @(''); break }
'Vulkan' { $renderer_packages = @(); break }
}

if(-not (Test-Path "$vcpkg_temp_dir\vcpkg.exe"))
if(-not (Test-Path ('{0}\vcpkg.exe' -f $vcpkg_temp_dir)))
{
& "$vcpkg_temp_dir\bootstrap-vcpkg.bat"
& ('{0}\bootstrap-vcpkg.bat' -f $vcpkg_temp_dir)
}

& "$vcpkg_temp_dir\vcpkg.exe" --disable-metrics --overlay-triplets=$([System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg-custom-triplets')) --triplet=$($Triplet) --clean-after-build install curl dlfcn-win32 glfw3 icu libuv libjpeg-turbo libpng libwebp $($renderer_packages)
& ('{0}\vcpkg.exe' -f $vcpkg_temp_dir) $(
@(
'--disable-metrics',
('--overlay-triplets={0}' -f [System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg-custom-triplets')),
('--triplet={0}' -f $Triplet),
'--clean-after-build',
'install', 'curl', 'dlfcn-win32', 'glfw3', 'icu', 'libuv', 'libjpeg-turbo', 'libpng', 'libwebp'
) + $renderer_packages
)

subst $vcpkg_temp_dir /D

Expand Down
2 changes: 2 additions & 0 deletions test/map/map.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ TEST(Map, Offline) {

#if ANDROID
test::checkImage("test/fixtures/map/offline", test.frontend.render(test.map).image, 0.0046, 0.1);
#elif WIN32
test::checkImage("test/fixtures/map/offline", test.frontend.render(test.map).image, 0.035, 0.1);
#else
test::checkImage("test/fixtures/map/offline", test.frontend.render(test.map).image, 0.0015, 0.1);
#endif
Expand Down
1 change: 1 addition & 0 deletions test/src/mbgl/test/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void runServer(std::unique_ptr<httplib::Server>& server) {
uint64_t start = std::strtoull(str.substr(0, str.find("-")).c_str(), nullptr, 10);
uint64_t end = std::strtoull(str.substr(str.find("-") + 1).c_str(), nullptr, 10);
content = content.substr(start, end - start + 1);
res.status = 206;
}
res.set_content(content, "text/plain");
});
Expand Down
Loading

0 comments on commit 86d755f

Please sign in to comment.