Skip to content

Commit b530b7f

Browse files
authored
Merge pull request #831 from ygj6/master
use cache in github actions
2 parents 7918c19 + ed49ea3 commit b530b7f

File tree

2 files changed

+117
-47
lines changed

2 files changed

+117
-47
lines changed

.github/depends/boost.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
3+
usage()
4+
{
5+
cat <<EOL
6+
-b - 32-bit or 64-bit library, maybe 32, 64 or both
7+
-t - the toolset, maybe gcc, clang or both
8+
EOL
9+
}
10+
11+
build_boost()
12+
{
13+
BASE=`pwd`/..
14+
./b2 -j4 --toolset=$1 --prefix=${BASE}/usr --libdir="${BASE}/usr/$1/lib$2" --with-chrono --with-context --with-filesystem --with-system --with-timer address-model=$2 install
15+
}
16+
17+
bit="64"
18+
toolset="gcc"
19+
20+
while getopts "b:t:" c; do
21+
case "$c" in
22+
b)
23+
bit="$OPTARG"
24+
[ "$bit" != "32" ] && [ "$bit" != "64" ] && [ "$bit" != "both" ] && usage && exit 1
25+
;;
26+
t)
27+
toolset="$OPTARG"
28+
[ "$toolset" != "gcc" ] && [ "$toolset" != "clang" ] && [ "$toolset" != "both" ] && usage && exit 1
29+
;;
30+
?*)
31+
echo "invalid arguments." && exit 1
32+
;;
33+
esac
34+
done
35+
36+
wget https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2
37+
tar xf boost_1_71_0.tar.bz2
38+
cd boost_1_71_0
39+
./bootstrap.sh
40+
41+
build()
42+
{
43+
if [ "$bit" = "both" ]; then
44+
build_boost $1 32
45+
build_boost $1 64
46+
else
47+
build_boost $1 $bit
48+
fi
49+
}
50+
51+
if [ "$toolset" = "both" ]; then
52+
build gcc
53+
build clang
54+
else
55+
build $toolset
56+
fi

.github/workflows/gha.yml

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ jobs:
1717
pattern: [0, 1, 2, 3]
1818
steps:
1919
- uses: actions/checkout@v1
20-
- name: install boost
21-
run: |
22-
brew install boost
20+
- name: Cache boost
21+
id: cache-boost
22+
uses: actions/cache@v1
23+
with:
24+
path: usr
25+
key: ${{ runner.os }}-boost-20200107
26+
- name: Build boost
27+
if: steps.cache-boost.outputs.cache-hit != 'true'
28+
run: ./.github/depends/boost.sh -b 64 -t clang
2329
- name: build and test
2430
env:
2531
CC: clang
2632
CXX: clang++
2733
shell: bash
2834
run: |
2935
BASE=`pwd`;
30-
mkdir ${BASE}/usr;
3136
3237
# matrix config
3338
if [ ${{ matrix.pattern }} == 0 ]; then
@@ -79,7 +84,7 @@ jobs:
7984
cd ..
8085
8186
# build and test
82-
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" BOOST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" ${ACTION}
87+
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" CMAKE_PREFIX_PATH="${BASE}/usr/clang/lib${ARCH}/cmake" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" ${ACTION}
8388
cat Files.cmake| grep ".*\.[h|hpp]" | perl -pe 's/ //g' | sort > tmp1 && find include -name "*.h" -o -name "*.hpp" | sort > tmp2 && diff tmp1 tmp2
8489
8590
linux:
@@ -91,7 +96,6 @@ jobs:
9196
- uses: actions/checkout@v1
9297
- name: install g++-multilib
9398
run: |
94-
sudo apt-get update
9599
sudo apt-get install g++-multilib
96100
- name: install clang
97101
run: |
@@ -101,11 +105,19 @@ jobs:
101105
run: |
102106
sudo apt-get update
103107
sudo apt-get install valgrind
108+
- name: Cache boost
109+
id: cache-boost
110+
uses: actions/cache@v1
111+
with:
112+
path: usr
113+
key: ${{ runner.os }}-boost-20200107
114+
- name: Build boost
115+
if: steps.cache-boost.outputs.cache-hit != 'true'
116+
run: ./.github/depends/boost.sh -b both -t gcc
104117
- name: build and test
105118
shell: bash
106119
run: |
107120
BASE=`pwd`;
108-
mkdir ${BASE}/usr;
109121
110122
# matrix config
111123
if [ ${{ matrix.pattern }} == 0 ]; then
@@ -225,14 +237,6 @@ jobs:
225237
export ARCH="64"
226238
fi
227239
228-
# install boost
229-
wget https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2
230-
tar xf boost_1_71_0.tar.bz2
231-
cd boost_1_71_0
232-
./bootstrap.sh
233-
./b2 -j4 --prefix=${BASE}/usr --with-chrono --with-context --with-filesystem --with-system --with-timer address-model=${ARCH} install
234-
cd ..
235-
236240
# install gtest
237241
wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
238242
unzip -q googletest-release-1.7.0.zip
@@ -253,7 +257,7 @@ jobs:
253257
fi
254258
255259
# build and test
256-
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" BOOST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" MSGPACK_SAN="${SAN}" ${ACTION}
260+
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" CMAKE_PREFIX_PATH="${BASE}/usr/gcc/lib${ARCH}/cmake" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" MSGPACK_SAN="${SAN}" ${ACTION}
257261
cat Files.cmake| grep ".*\.[h|hpp]" | perl -pe 's/ //g' | sort > tmp1 && find include -name "*.h" -o -name "*.hpp" | sort > tmp2 && diff tmp1 tmp2
258262
windows:
259263
runs-on: windows-2016
@@ -262,14 +266,44 @@ jobs:
262266
pattern: [0, 1, 2, 3]
263267
steps:
264268
- uses: actions/checkout@v1
265-
- name: download
266-
shell: bash
269+
- name: Cache dependencies
270+
id: cache-depends
271+
uses: actions/cache@v1
272+
with:
273+
path: third_party
274+
key: ${{ runner.os }}-depends
275+
- name: Build dependencies
276+
if: steps.cache-depends.outputs.cache-hit != 'true'
277+
shell: powershell
267278
run: |
268-
curl -L -o googletest-release-1.7.0.zip https://github.com/google/googletest/archive/release-1.7.0.zip
269-
curl -L -O http://zlib.net/zlib-1.2.11.tar.gz
270-
pwd
271-
ls -l
272-
- name: build and test
279+
$CUR=(Get-Location).Path
280+
281+
Invoke-WebRequest -Uri https://github.com/google/googletest/archive/release-1.7.0.zip -OutFile googletest-release-1.7.0.zip
282+
7z x googletest-release-1.7.0.zip
283+
cd googletest-release-1.7.0
284+
md build
285+
cd build
286+
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
287+
cmake --build . --config Release
288+
New-Item -ItemType Directory -Path "$CUR\third_party\googletest\lib"
289+
Copy-Item "Release\*" -Destination "$CUR\third_party\googletest\lib"
290+
Copy-Item -Path "..\include" -Destination "$CUR\third_party\googletest" -Recurse
291+
cd ..
292+
cd ..
293+
294+
Invoke-WebRequest -Uri http://zlib.net/zlib-1.2.11.tar.gz -OutFile zlib-1.2.11.tar.gz
295+
7z x zlib-1.2.11.tar.gz
296+
7z x zlib-1.2.11.tar
297+
cd zlib-1.2.11
298+
md build
299+
cd build
300+
cmake -DCMAKE_INSTALL_PREFIX="$CUR\third_party\zlib" ..
301+
cmake --build . --config Release
302+
New-Item -ItemType Directory -Path "$CUR\third_party\zlib\lib"
303+
Copy-Item "Release\*" -Destination "$CUR\third_party\zlib\lib"
304+
Copy-Item "..\zlib.h" -Destination "$CUR\third_party\zlib"
305+
Copy-Item zconf.h -Destination "$CUR\third_party\zlib"
306+
- name: Build and test
273307
shell: powershell
274308
run: |
275309
if (${{ matrix.pattern }} -eq 0) {
@@ -290,31 +324,11 @@ jobs:
290324
}
291325
292326
$CUR=(Get-Location).Path
293-
7z x googletest-release-1.7.0.zip
294-
cd googletest-release-1.7.0
295-
md build
296-
cd build
297-
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
298-
cmake --build . --config Release
299-
cd ..
300-
cd ..
301-
302-
7z x zlib-1.2.11.tar.gz
303-
7z x zlib-1.2.11.tar
304-
cd zlib-1.2.11
305-
md build
306-
cd build
307-
cmake ..
308-
cmake --build . --config Release
309-
copy zconf.h ..
310-
cd ..
311-
cd ..
312-
313327
md build
314328
cd build
315329
echo $env:BOOST_ROOT
316-
$env:DBOOST_ROOT="$env:Boost_ROOT"
317-
Start-Process cmake -ArgumentList "-DBOOST_ROOT=""$env:BOOST_ROOT"" $CPP11 $BOOST $X3_PARSE -DGTEST_LIBRARY=""$CUR\googletest-release-1.7.0\build\Release\gtest.lib"" -DGTEST_MAIN_LIBRARY=""$CUR\googletest-release-1.7.0\build\Release\gtest_main.lib"" -DGTEST_INCLUDE_DIR=""$CUR\googletest-release-1.7.0\include"" -DZLIB_LIBRARY=""$CUR\zlib-1.2.11\build\Release\zlib.lib"" -DZLIB_INCLUDE_DIR=""$CUR\zlib-1.2.11"" -DCMAKE_CXX_FLAGS=""/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"" .." -NoNewWindow -Wait
318-
cmake --build . --config Release -v
319-
$env:PATH="$env:PATH;$CUR\googletest-release-1.7.0\build\Release;$CUR\zlib-1.2.11\build\Release;$CUR\build\release"
330+
$env:BOOST_ROOT="$env:Boost_ROOT"
331+
cmake -DBOOST_ROOT="$env:BOOST_ROOT" $CPP11 $BOOST $X3_PARSE -DGTEST_LIBRARY="$CUR\third_party\googletest\lib\gtest.lib" -DGTEST_MAIN_LIBRARY="$CUR\third_party\googletest\lib\gtest_main.lib" -DGTEST_INCLUDE_DIR="$CUR\third_party\googletest\include" -DZLIB_LIBRARY="$CUR\third_party\zlib\lib\zlib.lib" -DZLIB_INCLUDE_DIR="$CUR\third_party\zlib" -DCMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
332+
cmake --build . --config Release
333+
$env:PATH="$env:PATH;$CUR\third_party\googletest\lib;$CUR\third_party\zlib\lib;$CUR\build\Release"
320334
ctest -V

0 commit comments

Comments
 (0)