Skip to content

Commit 6e0d05b

Browse files
committed
ci: add caching to speed up CI builds
1 parent bb9ffea commit 6e0d05b

1 file changed

Lines changed: 81 additions & 74 deletions

File tree

.github/workflows/ci.yml

Lines changed: 81 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,73 @@ jobs:
1515
matrix:
1616
redis-version: [ "2.8", "3.0", "4.0", "5.0", "6.0", "7.0", "8.0" ]
1717
fail-fast: false
18-
container: ubuntu:latest
1918
steps:
2019
- name: Git checkout
21-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2221

2322
- name: Setup Golang with cache
24-
uses: magnetikonline/action-golang-cache@v3
23+
uses: magnetikonline/action-golang-cache@v5
2524
with:
2625
go-version-file: go.mod
2726

28-
- name: clone and make redis
27+
- name: Cache Redis binary
28+
id: cache-redis
29+
uses: actions/cache@v4
30+
with:
31+
path: redis/bin
32+
key: redis-${{ matrix.redis-version }}-${{ runner.os }}-v1
33+
34+
- name: Build Redis
35+
if: steps.cache-redis.outputs.cache-hit != 'true'
2936
run: |
30-
apt-get update
31-
apt-get install -y --no-install-recommends git build-essential ca-certificates
32-
git clone https://github.com/redis/redis
37+
git clone --depth 1 --branch ${{ matrix.redis-version }} https://github.com/redis/redis
3338
cd redis
34-
git checkout ${{ matrix.redis-version }}
35-
make -j
36-
mkdir bin
37-
cp src/redis-server bin/redis-server
38-
echo "$GITHUB_WORKSPACE/redis/bin" >> $GITHUB_PATH
39-
40-
- name: clone and make TairString Module
41-
if: contains( '5.0, 6.0, 7.0, 8.0', matrix.redis-version)
42-
run: |
43-
cd $GITHUB_WORKSPACE
44-
apt-get install -y cmake
45-
git clone https://github.com/tair-opensource/TairString.git
46-
cd TairString
47-
mkdir build
48-
cd build
49-
cmake ../ && make -j
50-
cp $GITHUB_WORKSPACE/TairString/lib/tairstring_module.so /lib
51-
52-
- name: clone and make TairHash Module
53-
if: contains( '5.0, 6.0, 7.0, 8.0', matrix.redis-version)
54-
run: |
55-
cd $GITHUB_WORKSPACE
56-
git clone https://github.com/tair-opensource/TairHash.git
57-
cd TairHash
58-
mkdir build
59-
cd build
60-
cmake ../ && make -j
61-
cp $GITHUB_WORKSPACE/TairHash/lib/tairhash_module.so /lib
62-
63-
- name: clone and make TairZset Module
64-
if: contains( '5.0, 6.0, 7.0, 8.0', matrix.redis-version)
39+
make -j$(nproc)
40+
mkdir -p bin
41+
cp src/redis-server bin/
42+
43+
- name: Add Redis to PATH
44+
run: echo "$GITHUB_WORKSPACE/redis/bin" >> $GITHUB_PATH
45+
46+
- name: Cache Tair Modules
47+
id: cache-tair
48+
if: contains('5.0, 6.0, 7.0, 8.0', matrix.redis-version)
49+
uses: actions/cache@v4
50+
with:
51+
path: tair-modules
52+
key: tair-modules-${{ runner.os }}-v1
53+
54+
- name: Build Tair Modules
55+
if: contains('5.0, 6.0, 7.0, 8.0', matrix.redis-version) && steps.cache-tair.outputs.cache-hit != 'true'
6556
run: |
66-
cd $GITHUB_WORKSPACE
67-
git clone https://github.com/tair-opensource/TairZset.git
68-
cd TairZset
69-
mkdir build
70-
cd build
71-
cmake ../ && make -j
72-
cp $GITHUB_WORKSPACE/TairZset/lib/tairzset_module.so /lib
73-
74-
- name: Setup Python
75-
uses: actions/setup-python@v4
57+
mkdir -p tair-modules
58+
for repo in TairString TairHash TairZset; do
59+
git clone --depth 1 https://github.com/tair-opensource/${repo}.git
60+
cd ${repo} && mkdir build && cd build
61+
cmake .. && make -j$(nproc)
62+
cp ../lib/*.so $GITHUB_WORKSPACE/tair-modules/
63+
cd $GITHUB_WORKSPACE
64+
done
65+
66+
- name: Install Tair Modules
67+
if: contains('5.0, 6.0, 7.0, 8.0', matrix.redis-version)
68+
run: sudo cp tair-modules/*.so /lib/
69+
70+
- name: Setup Python with cache
71+
uses: actions/setup-python@v5
7672
with:
7773
python-version: '3.11'
74+
cache: 'pip'
75+
cache-dependency-path: tests/requirements.txt
7876

79-
- name: make redis-shake
80-
run: |
81-
sh build.sh
77+
- name: Install Python dependencies
78+
run: pip install -r tests/requirements.txt
8279

83-
- name: test
84-
run: |
85-
python -m pip install -r tests/requirements.txt
86-
sh test.sh
80+
- name: Build redis-shake
81+
run: sh build.sh
82+
83+
- name: Run tests
84+
run: sh test.sh
8785

8886
valkey-test:
8987
runs-on: ubuntu-latest
@@ -92,39 +90,48 @@ jobs:
9290
matrix:
9391
valkey-version: [ "8.0", "9.0" ]
9492
fail-fast: false
95-
container: ubuntu:latest
9693
steps:
9794
- name: Git checkout
98-
uses: actions/checkout@v2
95+
uses: actions/checkout@v4
9996

10097
- name: Setup Golang with cache
101-
uses: magnetikonline/action-golang-cache@v3
98+
uses: magnetikonline/action-golang-cache@v5
10299
with:
103100
go-version-file: go.mod
104101

105-
- name: clone and make valkey
102+
- name: Cache Valkey binary
103+
id: cache-valkey
104+
uses: actions/cache@v4
105+
with:
106+
path: valkey/bin
107+
key: valkey-${{ matrix.valkey-version }}-${{ runner.os }}-v1
108+
109+
- name: Build Valkey
110+
if: steps.cache-valkey.outputs.cache-hit != 'true'
106111
run: |
107-
apt-get update
108-
apt-get install -y --no-install-recommends git build-essential ca-certificates
109-
git clone https://github.com/valkey-io/valkey
112+
git clone --depth 1 --branch ${{ matrix.valkey-version }} https://github.com/valkey-io/valkey
110113
cd valkey
111-
git checkout ${{ matrix.valkey-version }}
112-
make -j
113-
mkdir bin
114+
make -j$(nproc)
115+
mkdir -p bin
114116
cp src/valkey-server bin/redis-server
115-
echo "$GITHUB_WORKSPACE/valkey/bin" >> $GITHUB_PATH
116117
117-
- name: Setup Python
118-
uses: actions/setup-python@v4
118+
- name: Add Valkey to PATH
119+
run: echo "$GITHUB_WORKSPACE/valkey/bin" >> $GITHUB_PATH
120+
121+
- name: Setup Python with cache
122+
uses: actions/setup-python@v5
119123
with:
120124
python-version: '3.11'
125+
cache: 'pip'
126+
cache-dependency-path: tests/requirements.txt
121127

122-
- name: make redis-shake
123-
run: |
124-
sh build.sh
128+
- name: Install Python dependencies
129+
run: pip install -r tests/requirements.txt
130+
131+
- name: Build redis-shake
132+
run: sh build.sh
125133

126-
- name: test
134+
- name: Run tests
127135
run: |
128-
python -m pip install -r tests/requirements.txt
129136
go test ./... -v
130-
cd tests/ && pybbt cases --verbose
137+
cd tests/ && pybbt cases --verbose

0 commit comments

Comments
 (0)