Skip to content

Commit 2c96750

Browse files
authored
CE 8.0 Milestone 03.
1 parent 9e33ad7 commit 2c96750

File tree

9 files changed

+2884
-2
lines changed

9 files changed

+2884
-2
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Build Redis CE MacOS Binary Distributions
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '.github/workflows/build-binary-dists.yml'
8+
- 'configs/**'
9+
- 'scripts/**'
10+
11+
pull_request_target:
12+
branches: [ main ]
13+
types: [ labeled ]
14+
paths:
15+
- '.github/workflows/build-binary-dists.yml'
16+
- 'configs/**'
17+
- 'scripts/**'
18+
19+
env:
20+
REDIS_VERSION: "8.0-m03"
21+
22+
permissions:
23+
id-token: write
24+
contents: read
25+
26+
jobs:
27+
build:
28+
if: ${{ (github.event.label.name == 'build-binary-dists') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
29+
name: Build Redis CE MacOS Binary Distributions
30+
strategy:
31+
matrix:
32+
os_version: # See: https://github.com/actions/runner-images/blob/main/README.md#available-images
33+
- macos-13 # macOS 13 x86_64
34+
- macos-13-xlarge # macOS 13 arm64
35+
36+
runs-on: ${{ matrix.os_version }}
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Install build dependencies
42+
run: |
43+
export HOMEBREW_NO_AUTO_UPDATE=1
44+
brew update
45+
brew install coreutils
46+
brew install make
47+
brew install openssl
48+
brew install llvm@18
49+
brew install cmake
50+
brew install gnu-sed
51+
brew install make
52+
brew install automake
53+
brew install libtool
54+
55+
RUST_INSTALLER=rust-1.80.1-$(if [ "$(uname -m)" = "arm64" ]; then echo "aarch64"; else echo "x86_64"; fi)-apple-darwin
56+
echo "Downloading and installing Rust standalone installer: ${RUST_INSTALLER}"
57+
wget --quiet -O ${RUST_INSTALLER}.tar.xz https://static.rust-lang.org/dist/${RUST_INSTALLER}.tar.xz
58+
tar -xf ${RUST_INSTALLER}.tar.xz
59+
(cd ${RUST_INSTALLER} && sudo ./install.sh)
60+
rm -rf ${RUST_INSTALLER}
61+
62+
- name: Build Redis CE
63+
id: build
64+
run: |
65+
export HOMEBREW_PREFIX="$(brew --prefix)"
66+
export BUILD_WITH_MODULES=yes
67+
export BUILD_TLS=yes
68+
export DISABLE_WERRORS=yes
69+
PATH="$HOMEBREW_PREFIX/opt/libtool/libexec/gnubin:$HOMEBREW_PREFIX/opt/llvm@18/bin:$HOMEBREW_PREFIX/opt/make/libexec/gnubin:$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin:$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" # Override macOS defaults.
70+
export LDFLAGS="-L$HOMEBREW_PREFIX/opt/llvm@18/lib"
71+
export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/llvm@18/include"
72+
73+
curl -L "https://github.com/redis/redis/archive/refs/tags/${{ vars.BINARY_VERSION_TO_BUILD }}.tar.gz" -o redis.tar.gz
74+
tar xzf redis.tar.gz
75+
76+
mkdir -p build_dir/etc
77+
make -C redis-${{ vars.BINARY_VERSION_TO_BUILD }} -j "$(nproc)" all OS=macos
78+
make -C redis-${{ vars.BINARY_VERSION_TO_BUILD }} install PREFIX=$(pwd)/build_dir OS=macos
79+
cp ./configs/redis.conf build_dir/etc/redis.conf
80+
(cd build_dir && zip -r ../redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip .)
81+
echo "UNSIGNED_REDIS_BINARY=unsigned-redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip" >> $GITHUB_OUTPUT
82+
83+
- name: Upload Redis CE Binary Distribution
84+
uses: actions/upload-artifact@v4
85+
with:
86+
path: ./${{ steps.build.outputs.UNSIGNED_REDIS_BINARY }}
87+
name: ${{ steps.build.outputs.UNSIGNED_REDIS_BINARY }}
88+
89+
- name: Setup Keychain and Certificate
90+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
91+
run: |
92+
# Decode and save certificate
93+
echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12
94+
95+
# Create and configure keychain
96+
security create-keychain -p "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
97+
security unlock-keychain -p "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
98+
security set-keychain-settings -t 3600 -l build.keychain
99+
100+
# Add to search list and set as default
101+
security list-keychains -d user -s build.keychain login.keychain
102+
security default-keychain -s build.keychain
103+
104+
# Import and trust certificate
105+
security import certificate.p12 -k build.keychain -P "${{ secrets.MACOS_CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
106+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
107+
108+
# Debug certificate presence
109+
security find-identity -v -p codesigning build.keychain
110+
111+
- name: Sign Binaries
112+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
113+
id: sign
114+
run: |
115+
# Get identity from specific keychain
116+
CODESIGN_IDENTITY=$(security find-identity -v -p codesigning build.keychain | grep -o '[0-9A-F]\{40\}' | head -n 1)
117+
echo "Using identity: ${CODESIGN_IDENTITY}"
118+
119+
# Check if entitlements file exists
120+
if [ ! -f configs/entitlements.xml ]; then
121+
echo "Entitlements file not found!"
122+
exit 1
123+
fi
124+
125+
# Sign binaries with explicit keychain
126+
for i in $(ls build_dir/bin); do
127+
/usr/bin/codesign --keychain build.keychain --options=runtime --timestamp -v --sign "${CODESIGN_IDENTITY}" --entitlements configs/entitlements.xml -f build_dir/bin/$i
128+
done
129+
130+
# Sign libraries with explicit keychain
131+
for i in $(ls build_dir/lib/redis/modules); do
132+
/usr/bin/codesign --keychain build.keychain --options=runtime --timestamp -v --sign "${CODESIGN_IDENTITY}" --entitlements configs/entitlements.xml -f build_dir/lib/redis/modules/$i
133+
done
134+
135+
# Create distribution archive
136+
(cd build_dir && zip -r ../redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip .)
137+
echo "REDIS_BINARY=redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip" >> $GITHUB_OUTPUT
138+
139+
- name: Notarize Redis CE Binary Distribution
140+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
141+
run: |
142+
sh scripts/notarize.sh ${{ steps.sign.outputs.REDIS_BINARY }} com.redis.redis ${{ secrets.MAC_NOTARIZE_USERNAME }} ${{ secrets.MAC_NOTARIZE_PASSWORD }} ${{ secrets.MAC_NOTARIZE_TEAM_ID }}
143+
144+
- uses: aws-actions/configure-aws-credentials@v4
145+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
146+
with:
147+
aws-region: ${{ secrets.S3_REGION }}
148+
role-to-assume: ${{ secrets.S3_IAM_ARN }}
149+
150+
- name: Upload Redis CE Binary Distribution to S3
151+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
152+
run: |
153+
aws s3 cp ${{ steps.sign.outputs.REDIS_BINARY }} s3://${{ secrets.S3_BUCKET }}/homebrew/ --acl public-read

.github/workflows/test.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Test Redis CE
2+
3+
on:
4+
pull_request:
5+
types: [ labeled ]
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/test.yml'
9+
- 'Casks/**'
10+
11+
jobs:
12+
test:
13+
if: github.event.label.name == 'run-tests'
14+
name: Test Redis CE
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os_version: # See: https://github.com/actions/runner-images/blob/main/README.md#available-images
19+
- macos-15-large # macOS 15 x86_64
20+
- macos-15 # macOS 15 arm64
21+
- macos-14-large # macOS 14 x86_64
22+
- macos-14 # macOS 14 arm64
23+
- macos-13 # macOS 13 x86_64
24+
- macos-13-xlarge # macOS 13 arm64
25+
cask:
26+
- redis
27+
- redis-rc
28+
29+
runs-on: ${{ matrix.os_version }}
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Set up Homebrew
35+
run: |
36+
export HOMEBREW_GITHUB_API_TOKEN=$GITHUB_TOKEN
37+
brew update
38+
brew tap ${{ vars.REDIS_TAP }} .
39+
40+
- name: Install Redis CE
41+
run: |
42+
brew install --cask ${{ matrix.cask }} --debug --verbose
43+
ls -al $(brew --prefix)/etc/redis.conf
44+
ls -al $(brew --prefix)/lib/redis/modules
45+
ls -al $(brew --prefix)/bin/redis*
46+
47+
- name: Test Redis Installation
48+
run: |
49+
redis-server --version
50+
redis-server $(brew --prefix)/etc/redis.conf
51+
for i in {1..30}; do redis-cli ping && break || echo "Waiting for Redis... $i" && sleep 1; done
52+
redis-cli info server || { echo "Cannot get server info"; exit 1; }
53+
redis-cli module list
54+
55+
- name: Verify Installed Modules
56+
run: |
57+
modules=$(redis-cli module list)
58+
echo "Installed modules:"
59+
echo "$modules"
60+
missing_modules=()
61+
for module in "bf" "search" "timeseries" "ReJSON"; do
62+
if ! echo "$modules" | grep -q "$module"; then
63+
missing_modules+=("$module")
64+
fi
65+
done
66+
if [ ${#missing_modules[@]} -eq 0 ]; then
67+
echo "All required modules are installed"
68+
else
69+
echo "The following modules are missing: ${missing_modules[*]}"
70+
exit 1
71+
fi
72+
73+
- name: Test RedisBloom
74+
run: |
75+
redis-cli BF.ADD popular_keys "redis:hash"
76+
redis-cli BF.ADD popular_keys "redis:set"
77+
[ "$(redis-cli BF.EXISTS popular_keys "redis:hash")" = "1" ] || \
78+
{ echo "RedisBloom test failed: 'redis:hash' not found"; exit 1; }
79+
[ "$(redis-cli BF.EXISTS popular_keys "redis:list")" = "0" ] || \
80+
{ echo "RedisBloom test failed: 'redis:list' found unexpectedly"; exit 1; }
81+
echo "RedisBloom test passed successfully"
82+
- name: Test RediSearch
83+
run: |
84+
redis-cli FT.CREATE redis_commands ON HASH PREFIX 1 cmd: SCHEMA name TEXT SORTABLE description TEXT
85+
redis-cli HSET cmd:set name "SET" description "Set the string value of a key"
86+
redis-cli HSET cmd:get name "GET" description "Get the value of a key"
87+
result=$(redis-cli FT.SEARCH redis_commands "value")
88+
if echo "$result" | grep -q "Set the string value of a key" && \
89+
echo "$result" | grep -q "Get the value of a key"; then
90+
echo "RediSearch test passed successfully"
91+
else
92+
echo "RediSearch test failed: expected commands not found in search results"
93+
exit 1
94+
fi
95+
- name: Test RedisTimeSeries
96+
run: |
97+
redis-cli TS.CREATE redis:cpu:usage RETENTION 86400
98+
redis-cli TS.ADD redis:cpu:usage "*" 80
99+
redis-cli TS.ADD redis:cpu:usage "*" 65
100+
redis-cli TS.ADD redis:cpu:usage "*" 70
101+
result=$(redis-cli TS.RANGE redis:cpu:usage - + COUNT 3)
102+
if echo "$result" | grep -q "80" && \
103+
echo "$result" | grep -q "65" && \
104+
echo "$result" | grep -q "70"; then
105+
echo "RedisTimeSeries test passed successfully"
106+
else
107+
echo "RedisTimeSeries test failed: expected values not found in time series"
108+
exit 1
109+
fi
110+
- name: Test ReJSON
111+
run: |
112+
redis-cli JSON.SET redis:config $ '{"maxmemory":"2gb","maxmemory-policy":"allkeys-lru"}'
113+
result=$(redis-cli JSON.GET redis:config $.maxmemory-policy)
114+
cleaned_result=$(echo $result | tr -d '[]"')
115+
if [ "$cleaned_result" = "allkeys-lru" ]; then
116+
echo "ReJSON test passed successfully"
117+
else
118+
echo "ReJSON test failed: expected 'allkeys-lru', got $result"
119+
exit 1
120+
fi
121+
122+
- name: Test uninstall
123+
run: |
124+
brew uninstall ${{ matrix.cask }}
125+
brew untap ${{ vars.REDIS_TAP }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

Casks/redis-rc.rb

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
cask "redis-rc" do
2+
arch arm: "arm64", intel: "x86_64"
3+
4+
version "8.0-m03"
5+
sha256 arm: "1232be3617c93ea20516483c650cc8142dff54e10b5b6a4835cd8b6d1e293763",
6+
intel: "ce8f834a2993b70d73a85eac0bc7277d0f869b57055d75e1d3b90bb66bf4e8b3"
7+
8+
url "https://redis-test-package-repository.s3.us-east-2.amazonaws.com/homebrew/redis-ce-#{version}-#{arch}.zip"
9+
name "Redis Community Edition - Pre-Release"
10+
desc "THIS IS A PRE-RELEASE VERSION!! BREAKING CHANGES MAY OCCUR WITHOUT NOTICE!! Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps."
11+
homepage "https://redis.io/"
12+
13+
depends_on macos: ">= :ventura"
14+
15+
depends_on formula: "openssl@3"
16+
depends_on formula: "libomp"
17+
depends_on formula: "llvm@18"
18+
19+
conflicts_with formula: "redis"
20+
21+
binaries = %w[
22+
redis-cli
23+
redis-benchmark
24+
redis-check-aof
25+
redis-check-rdb
26+
redis-sentinel
27+
redis-server
28+
]
29+
30+
postflight do
31+
basepath = HOMEBREW_PREFIX.to_s
32+
caskbase = "#{caskroom_path}/#{version}"
33+
confdir = "#{basepath}/etc"
34+
moduledir = "#{basepath}/lib/redis/modules"
35+
36+
FileUtils.mkdir_p(confdir)
37+
FileUtils.mkdir_p(moduledir)
38+
39+
# Replace <HOMEBREW_PREFIX> with the actual value
40+
src = "#{caskbase}/etc/redis.conf"
41+
conffile = "#{confdir}/redis.conf"
42+
FileUtils.cp(src, conffile) unless File.exist?(conffile)
43+
text = File.read(conffile)
44+
new_contents = text.gsub("<HOMEBREW_PREFIX>", basepath)
45+
File.open(conffile, "w") { |file| file.puts new_contents }
46+
47+
# link binaries
48+
binaries.each do |item|
49+
src = "#{caskbase}/bin/#{item}"
50+
dest = "#{basepath}/bin/#{item}"
51+
FileUtils.ln_sf(src, dest)
52+
end
53+
54+
# link modules
55+
Dir["#{caskbase}/lib/redis/modules/*.so"].each do |item|
56+
module_name = File.basename(item)
57+
dest = "#{moduledir}/#{module_name}"
58+
File.symlink(item, dest) unless File.exist?(dest)
59+
end
60+
end
61+
62+
uninstall_postflight do
63+
basepath = HOMEBREW_PREFIX.to_s
64+
65+
# Remove binary symlinks
66+
binaries.each do |item|
67+
dest = "#{basepath}/bin/#{item}"
68+
File.delete(dest) if File.symlink?(dest) && File.exist?(dest)
69+
end
70+
71+
# Remove module symlinks
72+
moduledir = "#{basepath}/lib/redis/modules"
73+
Dir["#{moduledir}/*.so"].each do |item|
74+
module_name = File.basename(item)
75+
dest = "#{moduledir}/#{module_name}"
76+
File.delete(dest)
77+
end
78+
79+
# Clean up empty directories
80+
FileUtils.rm_rf(moduledir) if Dir.empty?(moduledir)
81+
FileUtils.rm_rf("#{basepath}/lib/redis") if Dir.empty?("#{basepath}/lib/redis")
82+
end
83+
84+
caveats <<~EOS
85+
🚨THIS IS A PRE-RELEASE VERSION!! BREAKING CHANGES MAY OCCUR WITHOUT NOTICE!!🚨
86+
Redis Community Edition has been successfully installed!
87+
88+
The default configuration file has been copied to:
89+
#{HOMEBREW_PREFIX}/etc/redis.conf
90+
91+
To customize Redis, edit this file as needed and restart Redis to apply changes.
92+
93+
If you want to run Redis as a service, use:
94+
redis-server #{HOMEBREW_PREFIX}/etc/redis.conf
95+
96+
To stop the service:
97+
redis-cli shutdown
98+
EOS
99+
end

0 commit comments

Comments
 (0)