Skip to content

Commit

Permalink
Implement a basic github actions based CI (#11)
Browse files Browse the repository at this point in the history
* First attempt at getting the server docker build to work

* "Fix" docker server build by dynamically patching the CMakeLists so we can reference the shared protocol files from a different folder.

* CI: Implement caching for intermediary docker image layers (hopefully the vcpkg install step)

* CI: Also checkout submodules

* CI: Also add a client build

* Supply vcpkg commit id

* CI: Convert to actually supplying CMakePresets

* CI: actually use the right preset

* CI: Is CMake dumb?

* CI: Try to configure before building

* CI: Fix argument

* CI: Actually build the client, not the server.

* Move the CMakePresets into the client,  too

* CI: Preserve the artifacts
  • Loading branch information
MeFisto94 authored Dec 23, 2023
1 parent 2ec2d68 commit d850acf
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI Build
on:
push:
branches: [ "master", "feature/ci" ]
pull_request:
branches: [ "master" ]

jobs:
docker-server:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Copying the protocol files
run: cp -rv shared/protocol server/protocol
- uses: satackey/[email protected]
continue-on-error: true
- name: Build the Docker image
working-directory: server
run: docker build . --file Dockerfile --tag cyberverse-server:$(date +%s)

client:
runs-on: windows-latest

env:
VCPKG_DEFAULT_TRIPLET: x64-windows
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: lukka/get-cmake@latest
- name: Setup vcpkg
uses: lukka/run-vcpkg@main
id: runvcpkg
with:
# The vcpkg.json file, which will be part of cache key computation.
vcpkgJsonGlob: 'client/red4ext/vcpkg.json'
vcpkgGitCommitId: '16ee2ecb31788c336ace8bb14c21801efb6836e4'
- name: Generate build output folder
run: mkdir '${{ github.workspace }}\client\red4ext\build\ninja-vcpkg'
- name: Run CMake with vcpkg.json manifest
uses: lukka/run-cmake@v10
with:
cmakeListsTxtPath: '${{ github.workspace }}/client/red4ext/CMakeLists.txt'
configurePreset: ninja-vcpkg
buildPreset: ninja-vcpkg
buildPresetAdditionalArgs: '[`--config Release`]'
- name: List $RUNNER_WORKSPACE after build
run: find $RUNNER_WORKSPACE
shell: bash
- uses: actions/upload-artifact@v4
with:
name: RED4ext Plugin
path: client/red4ext/build/ninja-vcpkg/src/*.dll
37 changes: 37 additions & 0 deletions client/red4ext/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-vcpkg",
"displayName": "Ninja Configure Settings",
"description": "Configure with vcpkg toolchain",
"binaryDir": "${sourceDir}/build/${presetName}",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
}
],
"buildPresets": [
{
"name": "ninja-vcpkg",
"configurePreset": "ninja-vcpkg",
"displayName": "Build ninja-vcpkg",
"description": "Build ninja-vcpkg Configurations"
}
],
"testPresets": [
{
"name": "ninja-vcpkg",
"configurePreset": "ninja-vcpkg"
}
]
}
2 changes: 2 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ADD protocol /workspace/protocol

# generate and build
RUN vcpkg install --triplet=x64-linux
RUN sed -i 's\../../shared/protocol\protocol\g' /workspace/CMakeLists.txt
# TODO: Use CMakePresets instead.
RUN cmake -DCMAKE_TOOLCHAIN_FILE:STRING=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug \
-H/workspace -B/workspace/build -G Ninja
Expand Down

0 comments on commit d850acf

Please sign in to comment.