Linux C++ test & render tests on CI (#1033)

Co-authored-by: rpitre-wetdog <129877142+rpitre-wetdog@users.noreply.github.com>
Co-authored-by: Tadej Novak <tadej@tano.si>
Co-authored-by: Robin <boldtrn@users.noreply.github.com>
Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com>
This commit is contained in:
Bart Louwers
2023-04-22 14:24:42 +02:00
committed by GitHub
parent 33791d5379
commit 453af362cb
14 changed files with 173 additions and 71 deletions

View File

@@ -1,57 +0,0 @@
name: core-build
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- "src/**"
- "include/**"
- "workflows/core-build.yml"
- "vendor/**"
- "CMakeLists.txt"
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' }}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
- name: Get latest CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.24.1
ninjaVersion: latest
- name: Clear ccache
run: ccache --clear
- name: Save and restore ccache keys
uses: actions/cache@v3
env:
cache-name: ccache-maplibre-core
with:
path: ~/.ccache
key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
# INFO: No fallback restore. Only restoring keys that have the same github reference. Rerunning the same workflow
# will be faster. New workflow invocation with different code, sha1, or head will not be.
- name: Build Maplibre GL Core
run: |
cmake --version
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DMBGL_WITH_CLANG_TIDY=ON -DMBGL_WITH_CORE_ONLY=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMBGL_WITH_COVERAGE=ON
cmake --build build

147
.github/workflows/linux-ci.yml vendored Normal file
View File

@@ -0,0 +1,147 @@
name: linux-ci
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- "src/**"
- "include/**"
- ".github/workflows/linux-ci.yml"
- "vendor/**"
- "CMakeLists.txt"
- metrics/linux-gcc8-release-style.json
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
permissions:
id-token: write # This is required for requesting the JWT (AWS)
contents: read # This is required for actions/checkout (AWS)
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' }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- uses: hendrikmuhs/ccache-action@v1.2
- name: Get latest CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.24.1
ninjaVersion: latest
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libcurl4-openssl-dev \
libuv1-dev \
libjpeg-dev \
libpng-dev \
libglfw3-dev
- name: Build Maplibre GL Core
run: |
cmake --version
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DMBGL_WITH_CLANG_TIDY=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMBGL_WITH_COVERAGE=ON
cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner
- name: Archive mbgl-test-runner
uses: actions/upload-artifact@v3
with:
name: mbgl-test-runner
path: build/mbgl-test-runner
retention-days: 1
- name: Archive mbgl-render-test-runner
uses: actions/upload-artifact@v3
with:
name: mbgl-render-test-runner
path: build/mbgl-render-test-runner
retention-days: 1
test:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libopengl0
- name: Download mbgl-test-runner
uses: actions/download-artifact@v3
with:
name: mbgl-test-runner
- run: chmod +x ./mbgl-test-runner
- name: Install npm packages and run test server in background
run: |
npm install
node test/storage/server.js &
- name: Run C++ tests
run: xvfb-run -a ./mbgl-test-runner
render-test:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libopengl0
- uses: actions/checkout@v3
- name: Download mbgl-render-test-runner
uses: actions/download-artifact@v3
with:
name: mbgl-render-test-runner
- run: chmod +x ./mbgl-render-test-runner
- name: Run render test
continue-on-error: true
id: render_test
run: xvfb-run -a ./mbgl-render-test-runner --manifestPath=metrics/linux-gcc8-release-style.json
- name: Configure AWS Credentials
if: ${{ steps.render_test.outcome == 'failure' }}
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.run_id }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Upload render test results to S3
if: ${{ steps.render_test.outcome == 'failure' }}
id: upload_render_test_results
run: |
aws s3 cp metrics/linux-gcc8-release-style.html \
s3://maplibre-native-test-artifacts/${{ github.run_id }}-linux-gcc8-release-style.html \
--expires "$(date -d '+30 days' --utc +'%Y-%m-%dT%H:%M:%SZ')
- name: Make comment with test results
if: ${{ steps.upload_render_test_results.outcome == 'success' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Test results at https://maplibre-native-test-artifacts.s3.eu-central-1.amazonaws.com/${{ github.run_id }}-linux-gcc8-release-style.html

View File

@@ -173,6 +173,7 @@ jobs:
-G Ninja \ -G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DMLN_WITH_NODE=ON
- name: Configure maplibre-gl-native (Linux) - name: Configure maplibre-gl-native (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
@@ -182,7 +183,8 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-10 \ -DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_COMPILER=g++-10 \
-DMLN_WITH_NODE=ON
- name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)" - name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)"
if: runner.os == 'Windows' if: runner.os == 'Windows'
@@ -208,7 +210,8 @@ jobs:
cmake . -B build \ cmake . -B build \
-G Ninja \ -G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DMLN_WITH_NODE=ON
- name: Build maplibre-gl-native (MacOS/Linux) - name: Build maplibre-gl-native (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux' if: runner.os == 'MacOS' || runner.os == 'Linux'

View File

@@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
option(MBGL_WITH_CORE_ONLY "Build only the core bits, no platform code" OFF) option(MBGL_WITH_CORE_ONLY "Build only the core bits, no platform code" OFF)
option(MBGL_WITH_CLANG_TIDY "Build with clang-tidy checks enabled" OFF) option(MBGL_WITH_CLANG_TIDY "Build with clang-tidy checks enabled" OFF)
option(MBGL_WITH_COVERAGE "Enable code coverage collection" OFF) option(MBGL_WITH_COVERAGE "Enable code coverage collection" OFF)
option(MBGL_WITH_QT "Build Mapbox GL Qt bindings" OFF) option(MBGL_WITH_QT "Build MapLibre Native Qt bindings" OFF)
option(MLN_WITH_NODE "Build MapLibre Native Node.js bindings" OFF)
option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF) option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF)
option(MBGL_WITH_RTTI "Compile with runtime type information" OFF) option(MBGL_WITH_RTTI "Compile with runtime type information" OFF)
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON) option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <stdint.h> #include <cstdint>
// Pointers to OpenGL ES functions. They must be // Pointers to OpenGL ES functions. They must be
// initialized by the platform at linking time. // initialized by the platform at linking time.

View File

@@ -357,6 +357,7 @@ size_t HTTPRequest::headerCallback(char *const buffer, const size_t size, const
baton->response = std::make_unique<Response>(); baton->response = std::make_unique<Response>();
} }
// NOLINTBEGIN(bugprone-assignment-in-if-condition)
const size_t length = size * nmemb; const size_t length = size * nmemb;
size_t begin = std::string::npos; size_t begin = std::string::npos;
if ((begin = headerMatches("last-modified: ", buffer, length)) != std::string::npos) { if ((begin = headerMatches("last-modified: ", buffer, length)) != std::string::npos) {
@@ -379,6 +380,7 @@ size_t HTTPRequest::headerCallback(char *const buffer, const size_t size, const
} else if ((begin = headerMatches("x-rate-limit-reset: ", buffer, length)) != std::string::npos) { } else if ((begin = headerMatches("x-rate-limit-reset: ", buffer, length)) != std::string::npos) {
baton->xRateLimitReset = std::string(buffer + begin, length - begin - 2); // remove \r\n baton->xRateLimitReset = std::string(buffer + begin, length - begin - 2); // remove \r\n
} }
// NOLINTEND(bugprone-assignment-in-if-condition)
return length; return length;
} }

View File

@@ -27,7 +27,7 @@ static void init_source(j_decompress_ptr cinfo) {
static boolean fill_input_buffer(j_decompress_ptr cinfo) { static boolean fill_input_buffer(j_decompress_ptr cinfo) {
auto* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src); auto* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
wrap->stream->read(reinterpret_cast<char*>(&wrap->buffer[0]), BUF_SIZE); wrap->stream->read(reinterpret_cast<char*>(wrap->buffer.data()), BUF_SIZE);
std::streamsize size = wrap->stream->gcount(); std::streamsize size = wrap->stream->gcount();
wrap->manager.next_input_byte = wrap->buffer.data(); wrap->manager.next_input_byte = wrap->buffer.data();
wrap->manager.bytes_in_buffer = BUF_SIZE; wrap->manager.bytes_in_buffer = BUF_SIZE;

View File

@@ -137,7 +137,9 @@ target_link_libraries(
add_subdirectory(${PROJECT_SOURCE_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test) add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node) if(MLN_WITH_NODE)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node)
endif()
add_executable( add_executable(
mbgl-test-runner mbgl-test-runner

View File

@@ -102,7 +102,9 @@ target_link_libraries(
add_subdirectory(${PROJECT_SOURCE_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test) add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node) if(MLN_WITH_NODE)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node)
endif()
add_executable( add_executable(
mbgl-test-runner mbgl-test-runner

View File

@@ -48,13 +48,13 @@ To compile the Node.js bindings and install module dependencies, from the reposi
#### MacOS #### MacOS
```bash ```bash
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -DMBGL_WITH_COVERAGE=ON cmake . -B build -G Ninja -DMLN_WITH_NODE=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Debug -DMBGL_WITH_COVERAGE=ON
``` ```
#### Linux #### Linux
```bash ```bash
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 cmake . -B build -G Ninja -DMLN_WITH_NODE=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
``` ```
### Building ### Building
@@ -88,8 +88,6 @@ To clean up your pull request and prepare it for merging, update your local `mai
## Publishing ## Publishing
We aim to publish the `@mapbox/mapbox-gl-native` package on the same four-week cadence as the iOS, Android, and JavaScript SDKs, including a beta release one week prior to the final release. Responsibility for publishing rotates between team members.
To publish a new version of the package: To publish a new version of the package:
- [ ] make a commit in the release branch which includes: - [ ] make a commit in the release branch which includes:
- [ ] an updated version number in [`package.json`](../../package.json#L3) - [ ] an updated version number in [`package.json`](../../package.json#L3)

View File

@@ -183,7 +183,9 @@ target_link_libraries(
add_subdirectory(${PROJECT_SOURCE_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test) add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node) if(MLN_WITH_NODE)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node)
endif()
add_executable( add_executable(
mbgl-test-runner mbgl-test-runner

View File

@@ -394,6 +394,8 @@ JointPlacement Placement::placeSymbol(const SymbolInstance& symbolInstance, cons
const size_t anchorsSize = variableTextAnchors.size(); const size_t anchorsSize = variableTextAnchors.size();
const size_t placementAttempts = ctx.textAllowOverlap ? anchorsSize * 2 : anchorsSize; const size_t placementAttempts = ctx.textAllowOverlap ? anchorsSize * 2 : anchorsSize;
for (size_t i = 0u; i < placementAttempts; ++i) { for (size_t i = 0u; i < placementAttempts; ++i) {
// when anchorsSize is 0, placementAttempts is also 0, so this code would not be reached
// NOLINTNEXTLINE(clang-analyzer-core.DivideZero)
auto anchor = variableTextAnchors[i % anchorsSize]; auto anchor = variableTextAnchors[i % anchorsSize];
const bool allowOverlap = (i >= anchorsSize); const bool allowOverlap = (i >= anchorsSize);
shift = calculateVariableLayoutOffset(anchor, shift = calculateVariableLayoutOffset(anchor,

View File

@@ -16,7 +16,7 @@
#include <procfs.h> #include <procfs.h>
#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
#include <stdio.h> #include <cstdio>
#endif #endif