Skip to content

Commit 34dca0f

Browse files
committed
CI: Update to use vcpkg
1 parent fe8516d commit 34dca0f

File tree

3 files changed

+115
-20
lines changed

3 files changed

+115
-20
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@ on:
1414

1515
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1616
jobs:
17-
# This workflow contains a single job called "build"
1817
build:
1918
strategy:
2019
matrix:
21-
runs-on: [windows-2019, ubuntu-20.04]
20+
os:
21+
- runs-on: windows-2019
22+
vcpkg-triplet: x86-windows-static
23+
preset: ci-windows
24+
- runs-on: ubuntu-20.04
25+
vcpkg-triplet: x86-linux
26+
preset: ci-linux
2227
target: [client, server]
2328

2429
# The type of runner that the job will run on
25-
runs-on: ${{ matrix.runs-on }}
30+
runs-on: ${{ matrix.os.runs-on }}
31+
32+
env:
33+
VCPKG_ROOT: '${{github.workspace}}/vcpkg'
34+
VCPKG_DEFAULT_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
35+
VCPKG_DEFAULT_HOST_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
2636

2737
# Steps represent a sequence of tasks that will be executed as part of the job
2838
steps:
@@ -32,30 +42,46 @@ jobs:
3242
submodules: recursive
3343
fetch-depth: 0 # Required for automatic versioning
3444

35-
- name: Set up Python
36-
uses: actions/setup-python@v5
37-
with:
38-
python-version: 3.8
39-
4045
- name: Install Ubuntu packages
41-
if: matrix.runs-on == 'ubuntu-20.04'
46+
if: matrix.os.runs-on == 'ubuntu-20.04'
4247
run: |
4348
sudo dpkg --add-architecture i386
4449
sudo apt update || true
4550
sudo apt install -y libc6:i386 ninja-build gcc-9-multilib g++-9-multilib libssl1.1:i386 libssl-dev:i386 zlib1g-dev:i386
4651
47-
- name: Build release
48-
id: build
49-
run: |
50-
python ./scripts/BuildRelease.py --target ${{ matrix.target }} --build-type release --vs 2019 --toolset v141_xp --linux-compiler gcc-9 --out-dir ./_build_out --cmake-args="-DWARNINGS_ARE_ERRORS=ON" --github-actions
52+
# Restore artifacts, or setup vcpkg for building artifacts
53+
- name: Set up vcpkg
54+
uses: lukka/run-vcpkg@v11
55+
id: runvcpkg
56+
with:
57+
vcpkgJsonGlob: 'vcpkg.json'
58+
vcpkgDirectory: '${{env.VCPKG_ROOT}}'
59+
vcpkgGitCommitId: 'ef7dbf94b9198bc58f45951adcf1f041fcbc5ea0'
60+
runVcpkgInstall: false
61+
62+
# Run CMake+vcpkg+Ninja+CTest to generate/build/test.
63+
- name: Build and Test with CMake
64+
uses: lukka/run-cmake@v10
65+
id: runcmake
66+
with:
67+
configurePreset: '${{ matrix.os.preset }}'
68+
buildPreset: '${{ matrix.os.preset }}'
69+
buildPresetAdditionalArgs: "['--target ${{ matrix.target }} test_${{ matrix.target }}']"
70+
testPreset: '${{ matrix.os.preset }}'
71+
testPresetAdditionalArgs: "['-R ${{ matrix.target }}']"
72+
env:
73+
VCPKG_FORCE_SYSTEM_BINARIES: 1
5174

52-
- name: Run tests
75+
# Install
76+
- name: Install with CMake
5377
run: |
54-
cd ./_build_out/build
55-
ctest -R ${{ matrix.target }} --build-config RelWithDebInfo --output-on-failure
78+
cd ${{github.workspace}}/_build/${{ matrix.os.preset }}
79+
cmake --install . --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
5680
81+
# Upload result
5782
- name: Upload build result
5883
uses: actions/upload-artifact@v4
5984
with:
60-
name: ${{ steps.build.outputs.artifact_name }}
61-
path: ./_build_out/BugfixedHL-*.zip
85+
name: bhl-cmake-install
86+
path: ${{github.workspace}}/_build/ci-install
87+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ CMakeUserPresets.json
1111
# Ignore .vscode but allow examples
1212
.vscode/*
1313
!.vscode/**/*.example.*
14+
15+
# CI stuff
16+
/vcpkg

CMakePresets.json

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"configurePresets": [
44
{
55
"name": "default",
6-
"binaryDir": "${sourceDir}/_build",
6+
"binaryDir": "${sourceDir}/_build/${presetName}",
77
"hidden": true,
88
"cacheVariables": {
99
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
@@ -13,17 +13,83 @@
1313
"GNU_FORCE_COLORED_OUTPUT": true
1414
}
1515
},
16+
{
17+
"name": "vcpkg-windows",
18+
"inherits": ["default"],
19+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
20+
"generator": "Ninja",
21+
"cacheVariables": {
22+
"CMAKE_BUILD_TYPE": "Debug",
23+
"VCPKG_HOST_TRIPLET": "x86-windows-static",
24+
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
25+
}
26+
},
1627
{
1728
"name": "vcpkg-linux",
1829
"inherits": ["default"],
19-
"toolchainFile": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
30+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
2031
"generator": "Ninja",
2132
"cacheVariables": {
2233
"CMAKE_BUILD_TYPE": "Debug",
2334
"VCPKG_HOST_TRIPLET": "x86-linux",
2435
"VCPKG_TARGET_TRIPLET": "x86-linux",
2536
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/linux-gcc.cmake"
2637
}
38+
},
39+
{
40+
"name": "ci-base",
41+
"hidden": true,
42+
"cacheVariables": {
43+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
44+
"BUILD_TESTING": true,
45+
"GNU_FORCE_COLORED_OUTPUT": false,
46+
"USE_UPDATER": true,
47+
"WARNINGS_ARE_ERRORS": true
48+
}
49+
},
50+
{
51+
"name": "ci-windows",
52+
"inherits": ["vcpkg-windows", "ci-base"]
53+
},
54+
{
55+
"name": "ci-linux",
56+
"inherits": ["vcpkg-linux", "ci-base"]
57+
}
58+
],
59+
"buildPresets": [
60+
{
61+
"name": "ci-base",
62+
"hidden": true,
63+
"inheritConfigureEnvironment": true
64+
},
65+
{
66+
"name": "ci-windows",
67+
"inherits": ["ci-base"],
68+
"configurePreset": "ci-windows"
69+
},
70+
{
71+
"name": "ci-linux",
72+
"inherits": ["ci-base"],
73+
"configurePreset": "ci-linux"
74+
}
75+
],
76+
"testPresets": [
77+
{
78+
"name": "ci-base",
79+
"hidden": true,
80+
"output": {
81+
"outputOnFailure": true
82+
}
83+
},
84+
{
85+
"name": "ci-windows",
86+
"inherits": ["ci-base"],
87+
"configurePreset": "ci-windows"
88+
},
89+
{
90+
"name": "ci-linux",
91+
"inherits": ["ci-base"],
92+
"configurePreset": "ci-linux"
2793
}
2894
]
2995
}

0 commit comments

Comments
 (0)