-
Notifications
You must be signed in to change notification settings - Fork 21
183 lines (166 loc) · 5.7 KB
/
ci.yaml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 0 1 * *' # This line schedules the workflow to run at 00:00 on the first day of every month
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# - os: ubuntu-latest
# compiler: gcc
# - os: ubuntu-latest
# compiler: clang
# - os: windows-latest
# compiler: msvc
# - os: macos-latest
# compiler:
- os: ubuntu-latest
compiler: gcc
arch: x64
triplet: x64-linux
- os: ubuntu-latest
compiler: clang
arch: x64
triplet: x64-linux
- os: windows-latest
compiler: msvc
arch: x64
triplet: x64-windows
- os: macos-latest
compiler: clang
arch: x64
triplet: x64-osx
- os: macos-latest
compiler: clang
arch: arm64
triplet: arm64-osx
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Cache
uses: actions/cache@v4
with:
path: |
~/vcpkg
./build/vcpkg_installed
${{ env.HOME }}/.cache/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
${{ env.LOCALAPPDATA }}\vcpkg\archives
${{ env.APPDATA }}\vcpkg\archives
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ matrix.arch }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
restore-keys: |
${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ matrix.arch }}-
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
vcpkg: true
cppcheck: false
- name: Install compiler for Macos
if: startsWith(matrix.os, 'macos')
run: |
brew install llvm
brew install ninja
- name: Install Rosetta (for x64 compatibility)
if: runner.os == 'macOS' && matrix.arch == 'arm64'
run: |
softwareupdate --install-rosetta --agree-to-license || true
- name: Prepare the PATH
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "$env:USERPROFILE\vcpkg" >> $GITHUB_PATH
echo "$env:USERPROFILE\ninja" >> $GITHUB_PATH
else
echo "$HOME/vcpkg" >> $GITHUB_PATH
echo "$HOME/ninja" >> $GITHUB_PATH
fi
shell: bash
- name: Install dependencies
run: |
vcpkg install --triplet ${{ matrix.triplet }}
continue-on-error: true
- name: Upload vcpkg log on failure
if: failure() && steps.install_dependencies.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: boost-system-install-log-${{ matrix.os }}-${{ matrix.arch }}
path: /Users/runner/vcpkg/buildtrees/boost-system/install-${{ matrix.arch }}-dbg-out.log
retention-days: 3
- name: Build project
shell: bash
env:
VCPKG_TARGET_TRIPLET: ${{ matrix.triplet }}
run: |
echo "VCPKG_TARGET_TRIPLET: ${VCPKG_TARGET_TRIPLET}"
echo "PATH: ${PATH}"
ls -la ~/ninja
if [ -d build ]; then
echo "Build dir exists"
ls -la build
else
mkdir build
#rm -rf build/*
fi
pushd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
-DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
cmake --build .
popd
continue-on-error: true
- name: Dump vcpkg log on failure
run: |
echo "---------------------------------"
cat /Users/runner/vcpkg/buildtrees/boost-system/install-${{ matrix.arch }}-dbg-out.log
echo
echo "---------------------------------"
- name: Install curl
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
choco install curl
elif [[ "${{ runner.os }}" == "macOS" ]]; then
brew install curl
else
sudo apt-get install -y curl
fi
shell: bash
- name: Test shinysocks
run: |
# Start shinysocks in the background
./build/bin/shinysocks -c "" -l debug &
# Save its PID
SHINYSOCKS_PID=$!
# Give shinysocks some time to start
sleep 5
# Run curl command to verify that shinysocks works
curl -L --socks5-hostname socks5://localhost:1080 https://raw.githubusercontent.com/jgaa/shinysocks/master/ci/test.txt
# Check the exit code of the curl command
if [ $? -ne 0 ]; then
# If the curl command failed, fail the workflow
echo "Curl command failed"
exit 1
fi
# Kill the shinysocks program
kill $SHINYSOCKS_PID
shell: bash
- name: Prepare artifacts
run: |
mkdir -p artifacts
cp build/bin/* artifacts/
cp shinysocks.conf artifacts/
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: shinysocks-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.arch }}
path: artifacts/*
retention-days: 1