generated from CPP-KT/template-task
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (136 loc) · 4.47 KB
/
cpp.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
name: C++ CI
on:
pull_request
jobs:
formatting-check:
name: Formatting check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check line breaks
run: |
sudo apt-get install -y dos2unix
pushd $GITHUB_WORKSPACE
ci-extra/check-lines.sh
popd
- name: Run clang-format style check
# TODO use clang-format from a container
uses: jidicula/[email protected]
with:
clang-format-version: '18'
check-path: '.'
test:
needs: formatting-check
name: Test (${{ matrix.toolchain.name }}, ${{ matrix.build_type }})
timeout-minutes: 30
strategy:
matrix:
toolchain:
- { name: Linux/GCC, os: ubuntu-22.04, compiler: gcc-13 }
- { name: Linux/Clang, os: ubuntu-22.04, compiler: clang-18 }
build_type:
- Release
- Debug
- RelWithDebInfo
- Sanitized
- SanitizedDebug
include:
- toolchain: { name: macOS, os: macos-13, compiler: appleclang-18 }
build_type: SanitizedDebug
runs-on: ${{ matrix.toolchain.os }}
container:
image:
${{
contains(matrix.toolchain.os, 'ubuntu') &&
format('ghcr.io/cpp-kt/ubuntu:{0}', matrix.toolchain.compiler) ||
null
}}
options:
--security-opt seccomp=unconfined
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Cpp
if: ${{ !contains(matrix.toolchain.os, 'ubuntu') }}
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.toolchain.compiler }}
vcvarsall: ${{ contains(matrix.toolchain.os, 'windows') }}
ninja: true
cmake: true
vcpkg: true
env:
VCPKG_DISABLE_METRICS: 1
- name: Update tests
run: |
chown $(id -u):$(id -g) .
git config --global user.name "John Doe"
git config --global user.email [email protected]
source ci-extra/set-upstream.sh
git remote add upstream "https://github.com/$UPSTREAM_REPO.git"
git fetch upstream master
if git merge-base --is-ancestor upstream/master @; then
echo 'Tests are already up-to-date.'
echo 'TESTS_UPDATED=0' >> $GITHUB_ENV
else
echo 'Updating tests...'
git rebase upstream/master
echo 'Tests updated.'
echo 'TESTS_UPDATED=1' >> $GITHUB_ENV
fi
- name: Build
run: |
ci-extra/build.sh ${{ matrix.build_type }}
env:
CMAKE_TOOLCHAIN_FILE:
"${{ contains(matrix.toolchain.os, 'ubuntu') && '/opt' || '~' }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
- name: Run tests
run: |
if [[ $TESTS_UPDATED -eq 1 ]]; then
echo -e '\e[0;33mWARNING: Running a newer version of the tests than you have pushed.\e[0m'
fi
ci-extra/test.sh ${{ matrix.build_type }}
- name: Run tests with valgrind
if: ${{ matrix.build_type == 'RelWithDebInfo' }}
run: ci-extra/test-valgrind.sh ${{ matrix.build_type }}
hidden-tests:
name: Hidden tests
needs: formatting-check
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Request test run
run: |
curl -sf "http://${{ secrets.RUNNER_SERVER_ADDR }}/request_run" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"gh_token": "${{ secrets.GITHUB_TOKEN }}",
"run_id": ${{ github.run_id }},
"pull_request": ${{ github.event.number }}
}'
- name: Awaiting results
run: |
while true; do
json=$(curl -sf "${{ secrets.RUNNER_SERVER_ADDR }}/poll_run" \
-X POST \
-H 'Content-Type: application/json' \
-d '{"gh_token": "${{ secrets.GITHUB_TOKEN }}"}')
if [[ $(jq '.done' <<<"$json") = true ]]; then
break
else
echo "$(jq -r '.status' <<<"$json")"
sleep 30
fi
done
echo "$(jq -r '.report' <<<"$json")"
echo "$(jq -r '.report' <<<"$json")" >> $GITHUB_STEP_SUMMARY
if [[ $(jq '.success' <<<"$json") = false ]]; then
exit 1
fi