Skip to content

Commit

Permalink
Automated Distribution Release (#33)
Browse files Browse the repository at this point in the history
* add artifact & distribution

* add windows binary release

* bump msvc version

* bump msvc dev shell version

* remove header include

* static build

* don't link statically with clang-san

* make soro-server not dependent on outer directories

* move osm profiles into server_resources

* fix msvc linking

* msvc linking

* msvc linking

* use add_subdirectory for client and server build

* update tiles

* use libc++ for clang build

* cmake formatting

* remove unused

* don't use from_chars with clang libc++

* disable warnings for tiles library

* fix warning

* fix libc++ coro header

* remove unused

* use lld for clang builds

* use SORO_SERVER_DIR instead of CURRENT_BINARY_DIR

* moved to server

* fix cmake

* fix windows warnings

* fix warnings

* update readme

* update ci yml

* fix clang tidy

* add automated docker container generation

* clean up cmake

* Update linux.yml

* Create Dockerfile

* remove empty line

* remove copy paste remnants

* msvc compilation

* artifact name as parameter

* fix windows ci server resources path

* fix profile path

* fix path

* fix paths in windows ci

* fix windows path

* update dockerfile

* update readme

* fix link

* fix readme
  • Loading branch information
julianharbarth authored Dec 15, 2022
1 parent 2f8df15 commit 1466b51
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 566 deletions.
79 changes: 77 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
matrix:
config:
- preset: clang-release
artifact: linux-amd64
- preset: clang-debug
- preset: gcc-release
- preset: gcc-debug
Expand Down Expand Up @@ -58,11 +59,85 @@ jobs:
- name: Build
run: |
buildcache -z
cmake --build build/${{ matrix.config.preset }} --target soro-server-client
cmake --build build/${{ matrix.config.preset }} --target soro-server
buildcache -s
# ==== WEB TESTS ====
- name: Run Server
run: |
cd ./build/${{ matrix.config.preset }}
./soro-server -t
./soro-server -t --resource_dir ../../resources
# ==== DISTRIBUTION ====
- name: Create Distribution
if: matrix.config.artifact
run: |
mkdir -p soro-s
rm -rf build/clang-release/server_resources/infrastructure
rm -rf build/clang-release/server_resources/timetable
mv build/clang-release/soro-server soro-s/
mv build/clang-release/server_resources soro-s/
tar cjf soro-s-${{ matrix.config.artifact }}.tar.bz2 soro-s
- name: Upload Distribution
if: matrix.config.artifact
uses: actions/upload-artifact@v1
with:
name: soro-s-${{ matrix.config.artifact }}
path: soro-s-${{ matrix.config.artifact }}.tar.bz2

# ==== RELEASE ====
- name: Upload Release
if: github.event.action == 'published' && matrix.config.artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./soro-s-${{ matrix.config.artifact }}.tar.bz2
asset_name: soro-s-${{ matrix.config.artifact }}.tar.bz2
asset_content_type: application/x-tar

docker:
runs-on: ubuntu-20.04
needs: linux
steps:
- uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3

- name: Docker setup-buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge
- name: Docker build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
46 changes: 43 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ on:

jobs:
windows-build:
runs-on: windows-2019
runs-on: windows-2022

strategy:
fail-fast: false
matrix:
config:
- preset: msvc-release
artifact: windows-amd64
- preset: msvc-debug

env:
Expand All @@ -42,10 +43,49 @@ jobs:
$devShell = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find **\Microsoft.VisualStudio.DevShell.dll
$installPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath
Import-Module $devShell
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments "-arch=amd64 -vcvars_ver=14.29"
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments "-arch=amd64 -vcvars_ver=14.34"
cmake --preset=${{ matrix.config.preset }}
cmake --build build\${{ matrix.config.preset }} --target soro-server
cmake --build build\${{ matrix.config.preset }} --target soro-test
# ==== TESTS ====
- name: Run Tests
run: .\build\${{ matrix.config.preset }}\soro-test.exe
run: .\build\${{ matrix.config.preset }}\soro-test.exe

# ==== WEB TESTS ====
- name: Run Server
run: |
.\build\${{ matrix.config.preset }}\soro-server.exe -t --resource_dir .\resources --server_resource_dir .\build\${{ matrix.config.preset }}\server_resources\
# ==== DISTRIBUTION ====
- name: Delete unnecessary files
if: matrix.config.artifact
run: |
rm .\build\${{ matrix.config.preset }}\server_resources\infrastructure -r -force
rm .\build\${{ matrix.config.preset }}\server_resources\timetable -r -force
- name: Create Distribution
if: matrix.config.artifact
run: >
7z a soro-s-${{ matrix.config.artifact }}.zip
.\build\${{ matrix.config.preset }}\soro-server.exe
.\build\${{ matrix.config.preset }}\server_resources
- name: Upload Distribution
if: matrix.config.artifact
uses: actions/upload-artifact@v1
with:
name: soro-s-${{ matrix.config.artifact }}
path: soro-s-${{ matrix.config.artifact }}.zip

# ==== RELEASE ====
- name: Upload Release
if: github.event.action == 'published' && matrix.config.artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./soro-s-${{ matrix.config.artifact }}.zip
asset_name: soro-s-${{ matrix.config.artifact }}.zip
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[tiles]
[email protected]:motis-project/tiles.git
branch=master
commit=84b3686006d748b2c48c5ef05763af21b0f8403f
commit=653637bd3fb595eaaca71d9a153ddfcc59930a8b
[rapidjson]
[email protected]:motis-project/rapidjson.git
branch=master
Expand Down
52 changes: 39 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ option(SORO_LINT "Run clang-tidy with the compiler." OFF)

if (SORO_SAN)
SET(SORO_COMPILE_DEFINITIONS SORO_SAN ${SORO_COMPILE_DEFINITIONS})
SET(SORO_LINK_STATIC "")
else ()
SET(SORO_LINK_STATIC "-static")
endif ()

if (SORO_LINT)
Expand Down Expand Up @@ -68,7 +71,6 @@ find_package(Threads REQUIRED)
set(SORO_COMPILE_OPTIONS "")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(SORO_COMPILE_OPTIONS ${SORO_COMPILE_OPTIONS}
# -fno-strict-aliasing
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
Expand All @@ -87,11 +89,13 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-Wno-missing-noreturn
-Wno-deprecated-experimental-coroutine
-Werror
-fcoroutines-ts
${SORO_LINK_STATIC}
)

if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13)
if (CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 15)
set(SORO_COMPILE_OPTIONS ${SORO_COMPILE_OPTIONS}
-Wno-reserved-identifier)
-Wno-deprecated-non-prototype)
endif ()

if (SORO_SAN)
Expand All @@ -108,18 +112,46 @@ else ()
-Wextra
-Werror
-fcoroutines
${SORO_LINK_STATIC}
)
endif ()

set(SORO_COMPILE_FEATURES cxx_std_20)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

# Gets us the soro-lib library
include(cmake/soro-lib.cmake)
# === soro-lib ===
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

file(GLOB_RECURSE soro-lib-files src/*.cc)
add_library(soro-lib STATIC EXCLUDE_FROM_ALL ${soro-lib-files})

if (SORO_CUDA)
add_library(infrastructure-cuda src/infrastructure/gpu/exclusion.cu)
set_target_properties(infrastructure-cuda PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
CUDA_STANDARD 20
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
target_include_directories(infrastructure-cuda PUBLIC include)
set_property(TARGET infrastructure-cuda PROPERTY CUDA_ARCHITECTURES 75 61)
endif ()

target_compile_options(soro-lib PRIVATE ${SORO_COMPILE_OPTIONS})
target_compile_features(soro-lib PRIVATE ${SORO_COMPILE_FEATURES})
target_compile_definitions(soro-lib PRIVATE ${SORO_COMPILE_DEFINITIONS})
target_include_directories(soro-lib PUBLIC include)
target_link_libraries(soro-lib PRIVATE utl cista date pugixml Threads::Threads)

if (SORO_CUDA)
target_link_libraries(soro-lib PUBLIC infrastructure-cuda)
endif ()

# Gets us the soro-server-client target
include(cmake/soro-server-client.cmake)
set(SORO_SERVER_DIR ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(web/server)
add_subdirectory(web/client)

# Generate file_paths.h for locating the test resources
configure_file(test/include/test/file_paths.h.in
Expand All @@ -133,7 +165,7 @@ target_compile_options(soro-test PRIVATE ${SORO_COMPILE_OPTIONS})
target_compile_features(soro-test PRIVATE ${SORO_COMPILE_FEATURES})
target_compile_definitions(soro-test PRIVATE ${SORO_COMPILE_DEFINITIONS})

target_link_libraries(soro-test PUBLIC doctest soro-lib soro-server-lib)
target_link_libraries(soro-test PUBLIC utl doctest date soro-lib soro-server-lib)
target_include_directories(soro-test PUBLIC test/include)

# Make clang-tidy only output on soro-s files, not on dependencies.
Expand Down Expand Up @@ -161,9 +193,3 @@ if (SORO_LINT)
)
endforeach ()
endif ()

# add an ALL target for CLion convenience
add_custom_target(ALL)
add_dependencies(ALL
soro-test
soro-server-client)
6 changes: 4 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"hidden": true,
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-15",
"CMAKE_CXX_COMPILER": "clang++-15"
"CMAKE_CXX_COMPILER": "clang++-15",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-lstdc++ -lc++abi -fuse-ld=lld"
}
},
{
Expand All @@ -33,7 +35,7 @@
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"toolset": {
"value": "version=14.29",
"value": "version=14.34",
"strategy": "external"
},
"cacheVariables": {
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3.14
ARG TARGETARCH
ADD soro-s-linux-$TARGETARCH/soro-s-linux-$TARGETARCH.tar.bz2 /
RUN addgroup -S soro-s && adduser -S soro-s -G soro-s && \
chown -R soro-s:soro-s /soro-s/

EXPOSE 8080
VOLUME ["/resources"]
WORKDIR /soro-s
USER soro-s
CMD ["/soro-s/soro-server", "--resource_dir", "/resources"]
Loading

0 comments on commit 1466b51

Please sign in to comment.