-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (140 loc) · 5.68 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
job:
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}
runs-on: ${{ matrix.run-on }}
strategy:
fail-fast: false
matrix:
run-on: [ubuntu-latest, windows-latest]
compiler: [any]
include:
- run-on: windows-latest
triplet: x64-windows-static-release
arch: x86_64
platform: windows
compiler: msvc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: gcc
- run-on: ubuntu-latest
triplet: x64-linux-release
arch: x86_64
platform: linux
compiler: clang
exclude:
- compiler: any
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_GIT_COMMIT_ID: "f6a5d4e8eb7476b8d7fc12a56dff300c1c986131"
steps:
- name: Install gcc-13
if: runner.os == 'Linux'
run: |
wget --no-verbose http://kayari.org/gcc-latest/gcc-latest_13.0.1-20230326git55bc61a75a68.deb
sudo dpkg -i gcc-latest_13.0.1-20230326git55bc61a75a68.deb
echo "/opt/gcc-latest/bin" >> $GITHUB_PATH
echo "LD_RUN_PATH=/opt/gcc-latest/lib64" >> $GITHUB_ENV
- name: Install clang-17(dev)
if: runner.os == 'Linux' && matrix.compiler == 'clang'
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main'
sudo apt update
sudo apt install clang-17 llvm-17-dev
echo "CC=clang-17" >> $GITHUB_ENV
echo "CXX=clang++-17" >> $GITHUB_ENV
echo "CFLAGS=--gcc-toolchain=/opt/gcc-latest" >> $GITHUB_ENV
echo "CXXFLAGS=--gcc-toolchain=/opt/gcc-latest" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- uses: TheMrMilchmann/setup-msvc-dev@v2
if: runner.os == 'Windows'
with:
arch: x64
- name: Setup vcpkg (windows)
if: runner.os == 'Windows'
run: |
cd "C:\"
if(Test-Path C:\vcpkg) { rm -r -Force "C:\vcpkg" }
git clone --depth 1 --branch "2023.06.20" https://github.com/microsoft/vcpkg.git
- name: Restore vcpkg-tool (windows)
if: runner.os == 'Windows'
id: restore-vcpkg-tool
uses: actions/cache/restore@v3
with:
path: C:\vcpkg\vcpkg.exe
key: windows-cache-vcpkg-tool
- name: Build vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
run: |
cd "C:\"
if(Test-Path C:\vcpkg-tool) { rm -r -Force "C:\vcpkg-tool" }
git clone --depth 1 --branch gha-upload-fixes https://github.com/albertziegenhagel/vcpkg-tool.git
cd "C:\vcpkg-tool"
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja
cp .\vcpkg.exe C:\vcpkg\
- name: Store vcpkg-tool (windows)
if: runner.os == 'Windows' && steps.restore-vcpkg-tool.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: C:\vcpkg\vcpkg.exe
key: ${{ steps.restore-vcpkg-tool.outputs.cache-primary-key }}
- name: Setup GHA cache
if: runner.os == 'Windows'
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup vcpkg (non-windows)
if: runner.os != 'Windows'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: "${{ env.VCPKG_GIT_COMMIT_ID }}"
- name: Build & Test project (Windows)
if: runner.os == 'Windows'
run: |
cd '${{ github.workspace }}'
$env:VCPKG_BINARY_SOURCES="clear;x-gha,readwrite"
cmake --preset ci . -G Ninja -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}" "-DVCPKG_INSTALL_OPTIONS=--debug"
cmake --build --preset ci .
ctest --preset ci
- name: Build & Test project (default)
uses: lukka/run-cmake@v10
if: runner.os == 'Linux' && matrix.compiler != 'clang'
with:
configurePreset: "ci"
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=Release', '-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}', '-DVCPKG_VERBOSE=ON', '-DVCPKG_INSTALL_OPTIONS=--debug']"
buildPreset: "ci"
testPreset: "ci"
- name: Build & Test project (system LLVM)
uses: lukka/run-cmake@v10
if: runner.os == 'Linux' && matrix.compiler == 'clang'
with:
configurePreset: "ci"
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=Release', '-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}', '-DLLVM_DIR=/usr/lib/llvm-17/lib/cmake/llvm/']"
buildPreset: "ci"
testPreset: "ci"
- name: Install
run: |
cmake --install ${{ github.workspace }}/build/ci --component server --prefix ${{ github.workspace }}/install
- name: Upload binaries
uses: actions/upload-artifact@v3
if: runner.os != 'Linux' || matrix.compiler == 'gcc'
with:
name: snail-server-${{ matrix.arch }}-${{ matrix.platform }}
path: ${{ github.workspace }}/install/bin/snail-server*