From 8d185351d968c8bceba8e257413d7fef6a50cba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renato=20Foot=20Guimar=C3=A3es=20Costallat?= Date: Thu, 30 Nov 2023 23:46:10 -0300 Subject: [PATCH] GHA: Update Docker and Ubuntu workflows (#659) - Remove duplicated entry from editorconfig (again, don't know why it got back after PR that fixed this) - Added entry for cmake files on editorconfig - Removed not used GitVersion - Update ubuntu build workflow (Removed ccache that will not work with UNITY and PCH) - Disabled UNITY and PCH for debug images and enabled more warning flags (Show build warning on PR changes) - Update docker workflow to use newer version (Using newer versions of the actions helped cleaning the workflow, now it is smaller and easier to understand) - Do not upload artifacts when building PR as it failing and we need to re-run the build Signed-off-by: Renato Foot --- .editorconfig | 73 +---------------------------- .github/workflows/build-docker.yml | 75 +++++++++--------------------- .github/workflows/build-ubuntu.yml | 15 ++---- CMakePresets.json | 4 +- GitVersion.yml | 7 --- src/CMakeLists.txt | 20 +++++--- 6 files changed, 45 insertions(+), 149 deletions(-) delete mode 100644 GitVersion.yml diff --git a/.editorconfig b/.editorconfig index 70de4fb75b..79343f4204 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,77 +2,6 @@ root = true [*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}] -# Configurações de Formatação do Visual C++ - -cpp_indent_braces = false -cpp_indent_multi_line_relative_to = statement_begin -cpp_indent_within_parentheses = align_to_parenthesis -cpp_indent_preserve_within_parentheses = true -cpp_indent_case_contents = true -cpp_indent_case_labels = true -cpp_indent_case_contents_when_block = false -cpp_indent_lambda_braces_when_parameter = false -cpp_indent_goto_labels = one_left -cpp_indent_preprocessor = leftmost_column -cpp_indent_access_specifiers = false -cpp_indent_namespace_contents = true -cpp_indent_preserve_comments = false -cpp_new_line_before_open_brace_namespace = ignore -cpp_new_line_before_open_brace_type = new_line -cpp_new_line_before_open_brace_function = ignore -cpp_new_line_before_open_brace_block = same_line -cpp_new_line_before_open_brace_lambda = same_line -cpp_new_line_scope_braces_on_separate_lines = false -cpp_new_line_close_brace_same_line_empty_type = false -cpp_new_line_close_brace_same_line_empty_function = false -cpp_new_line_before_catch = false -cpp_new_line_before_else = false -cpp_new_line_before_while_in_do_while = false -cpp_space_before_function_open_parenthesis = remove -cpp_space_within_parameter_list_parentheses = false -cpp_space_between_empty_parameter_list_parentheses = false -cpp_space_after_keywords_in_control_flow_statements = true -cpp_space_within_control_flow_statement_parentheses = false -cpp_space_before_lambda_open_parenthesis = false -cpp_space_within_cast_parentheses = false -cpp_space_after_cast_close_parenthesis = false -cpp_space_within_expression_parentheses = false -cpp_space_before_block_open_brace = true -cpp_space_between_empty_braces = false -cpp_space_before_initializer_list_open_brace = false -cpp_space_within_initializer_list_braces = true -cpp_space_preserve_in_initializer_list = true -cpp_space_before_open_square_bracket = false -cpp_space_within_square_brackets = false -cpp_space_before_empty_square_brackets = false -cpp_space_between_empty_square_brackets = false -cpp_space_group_square_brackets = true -cpp_space_within_lambda_brackets = false -cpp_space_between_empty_lambda_brackets = false -cpp_space_before_comma = false -cpp_space_after_comma = true -cpp_space_remove_around_member_operators = true -cpp_space_before_inheritance_colon = true -cpp_space_before_constructor_colon = true -cpp_space_remove_before_semicolon = true -cpp_space_after_semicolon = true -cpp_space_remove_around_unary_operator = true -cpp_space_around_binary_operator = insert -cpp_space_around_assignment_operator = insert -cpp_space_pointer_reference_alignment = left -cpp_space_around_ternary_operator = insert -cpp_wrap_preserve_blocks = all_one_line_scopes - -root = true - -[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}] - -# Configurações de Estilo de Código de Visual C++ - -cpp_generate_documentation_comments = xml - -# Configurações de Formatação do Visual C++ - cpp_indent_braces = false cpp_indent_multi_line_relative_to = statement_begin cpp_indent_within_parentheses = align_to_parenthesis @@ -135,3 +64,5 @@ cpp_wrap_preserve_blocks = all_one_line_scopes [CMakeLists.txt] indent_size = 2 indent_style = tab +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 6934901fde..1848d3dfa1 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -5,8 +5,11 @@ on: workflow_dispatch: pull_request: push: - branches: - - main + branches: [ $default-branch ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: docker: @@ -17,63 +20,31 @@ jobs: with: fetch-depth: 0 - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.15 - with: - versionSpec: '5.x' - - - name: Determine Version - id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.15 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2.1.0 - with: - install: true - - - name: Cache Docker layers - uses: actions/cache@main - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2.1.0 + uses: docker/login-action@v3 with: - registry: ghcr.io - username: ${{ github.repository_owner }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build - if: ${{ github.event_name == 'pull_request' }} - uses: docker/build-push-action@v3.2.0 + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 with: - file: Dockerfile - tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} - cache-from: type=gha, scope=${{ github.workflow }} - cache-to: type=gha, scope=${{ github.workflow }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push - id: docker_build - if: ${{ github.event_name == 'push' }} - uses: docker/build-push-action@v3.2.0 + - name: Build and push Docker image + uses: docker/build-push-action@v5 with: + context: . file: Dockerfile - push: true - tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} - cache-from: type=gha, scope=${{ github.workflow }} - cache-to: type=gha, scope=${{ github.workflow }} - - - name: Image digest - if: ${{ github.event_name == 'push' }} - run: echo ${{ steps.docker_build.outputs.digest }} - - # # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # - name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 2c4d49c4c8..9238a2b466 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -9,8 +9,7 @@ on: - main env: - CMAKE_BUILD_PARALLEL_LEVEL: 2 - MAKEFLAGS: '-j 2' + VCPKG_ENABLE_METRICS: 1 jobs: job: @@ -33,7 +32,7 @@ jobs: uses: actions/checkout@main - name: Install Linux Dependencies - run: > + run: > sudo apt-get update && sudo apt-get install ccache libglew-dev libx11-dev linux-headers-$(uname -r) - name: Switch to gcc-11 @@ -42,14 +41,6 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-12 sudo update-alternatives --set gcc /usr/bin/gcc-11 - - name: CCache - uses: hendrikmuhs/ccache-action@main - with: - max-size: "1G" - key: ccache-${{ matrix.os }}-${{ matrix.buildtype }} - restore-keys: | - ccache-${{ matrix.os }} - - name: Restore artifacts and install vcpkg id: vcpkg-step run: | @@ -60,7 +51,6 @@ jobs: - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main with: - vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} - name: Get latest CMake and ninja @@ -73,6 +63,7 @@ jobs: buildPreset: ${{ matrix.buildtype }} - name: Create and Upload Artifact + if: ${{ github.event_name != 'pull_request' }} uses: actions/upload-artifact@main with: name: otclient-${{ matrix.buildtype }}-${{ github.sha }} diff --git a/CMakePresets.json b/CMakePresets.json index 5a5868d943..3bfe0beb0d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -97,7 +97,9 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", "DEBUG_LOG": "ON", - "ASAN_ENABLED": "ON" + "ASAN_ENABLED": "OFF", + "TOGGLE_PRE_COMPILED_HEADER": "OFF", + "SPEED_UP_BUILD_UNITY": "OFF" } } ], diff --git a/GitVersion.yml b/GitVersion.yml deleted file mode 100644 index 470f562989..0000000000 --- a/GitVersion.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -assembly-versioning-scheme: MajorMinorPatchTag -mode: ContinuousDelivery -branches: {} -ignore: - sha: [] -merge-message-formats: {} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9154a93cb..324a814444 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -289,11 +289,11 @@ set(SOURCE_FILES framework/net/protocol.cpp framework/net/protocolhttp.cpp framework/net/server.cpp - framework/otml//otmldocument.cpp - framework/otml//otmlemitter.cpp - framework/otml//otmlexception.cpp - framework/otml//otmlnode.cpp - framework/otml//otmlparser.cpp + framework/otml/otmldocument.cpp + framework/otml/otmlemitter.cpp + framework/otml/otmlexception.cpp + framework/otml/otmlnode.cpp + framework/otml/otmlparser.cpp framework/platform/androidgameactivity.cpp framework/platform/androidmanager.cpp framework/platform/androidmanager.h @@ -508,7 +508,7 @@ elseif(ANDROID) log pugixml::pugixml ) -else() +else() # Linux target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src @@ -549,6 +549,14 @@ else() LibLZMA::LibLZMA pugixml::pugixml ) + + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_options(${PROJECT_NAME} + PRIVATE + -Wall -Wextra -Wpedantic + ) + endif() + endif() # *****************************************************************************