Skip to content

Commit

Permalink
GHA: Update Docker and Ubuntu workflows (mehah#659)
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
Costallat authored Dec 1, 2023
1 parent 28eaf13 commit 8d18535
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 149 deletions.
73 changes: 2 additions & 71 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
75 changes: 23 additions & 52 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -17,63 +20,31 @@ jobs:
with:
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]
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/[email protected]
# 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/[email protected]
- 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
15 changes: 3 additions & 12 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ on:
- main

env:
CMAKE_BUILD_PARALLEL_LEVEL: 2
MAKEFLAGS: '-j 2'
VCPKG_ENABLE_METRICS: 1

jobs:
job:
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
],
Expand Down
7 changes: 0 additions & 7 deletions GitVersion.yml

This file was deleted.

20 changes: 14 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -508,7 +508,7 @@ elseif(ANDROID)
log
pugixml::pugixml
)
else()
else() # Linux
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_SOURCE_DIR}/src
Expand Down Expand Up @@ -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()

# *****************************************************************************
Expand Down

0 comments on commit 8d18535

Please sign in to comment.