Skip to content

Commit

Permalink
CE 8.0 Milestone 03.
Browse files Browse the repository at this point in the history
Update CE 8.0 M03 Casks (#3)

* Test CE 8.0 M03
* Update packages url
* Update SHAs
  • Loading branch information
adamiBs committed Jan 21, 2025
1 parent 9e33ad7 commit 6553b50
Show file tree
Hide file tree
Showing 9 changed files with 2,884 additions and 2 deletions.
153 changes: 153 additions & 0 deletions .github/workflows/build-binary-dists.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Build Redis CE MacOS Binary Distributions

on:
push:
branches: [ main ]
paths:
- '.github/workflows/build-binary-dists.yml'
- 'configs/**'
- 'scripts/**'

pull_request_target:
branches: [ main ]
types: [ labeled ]
paths:
- '.github/workflows/build-binary-dists.yml'
- 'configs/**'
- 'scripts/**'

env:
REDIS_VERSION: "8.0-m03"

permissions:
id-token: write
contents: read

jobs:
build:
if: ${{ (github.event.label.name == 'build-binary-dists') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
name: Build Redis CE MacOS Binary Distributions
strategy:
matrix:
os_version: # See: https://github.com/actions/runner-images/blob/main/README.md#available-images
- macos-13 # macOS 13 x86_64
- macos-13-xlarge # macOS 13 arm64

runs-on: ${{ matrix.os_version }}

steps:
- uses: actions/checkout@v4

- name: Install build dependencies
run: |
export HOMEBREW_NO_AUTO_UPDATE=1
brew update
brew install coreutils
brew install make
brew install openssl
brew install llvm@18
brew install cmake
brew install gnu-sed
brew install make
brew install automake
brew install libtool
RUST_INSTALLER=rust-1.80.1-$(if [ "$(uname -m)" = "arm64" ]; then echo "aarch64"; else echo "x86_64"; fi)-apple-darwin
echo "Downloading and installing Rust standalone installer: ${RUST_INSTALLER}"
wget --quiet -O ${RUST_INSTALLER}.tar.xz https://static.rust-lang.org/dist/${RUST_INSTALLER}.tar.xz
tar -xf ${RUST_INSTALLER}.tar.xz
(cd ${RUST_INSTALLER} && sudo ./install.sh)
rm -rf ${RUST_INSTALLER}
- name: Build Redis CE
id: build
run: |
export HOMEBREW_PREFIX="$(brew --prefix)"
export BUILD_WITH_MODULES=yes
export BUILD_TLS=yes
export DISABLE_WERRORS=yes
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.
export LDFLAGS="-L$HOMEBREW_PREFIX/opt/llvm@18/lib"
export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/llvm@18/include"
curl -L "https://github.com/redis/redis/archive/refs/tags/${{ vars.BINARY_VERSION_TO_BUILD }}.tar.gz" -o redis.tar.gz
tar xzf redis.tar.gz
mkdir -p build_dir/etc
make -C redis-${{ vars.BINARY_VERSION_TO_BUILD }} -j "$(nproc)" all OS=macos
make -C redis-${{ vars.BINARY_VERSION_TO_BUILD }} install PREFIX=$(pwd)/build_dir OS=macos
cp ./configs/redis.conf build_dir/etc/redis.conf
(cd build_dir && zip -r ../redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip .)
echo "UNSIGNED_REDIS_BINARY=unsigned-redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip" >> $GITHUB_OUTPUT
- name: Upload Redis CE Binary Distribution
uses: actions/upload-artifact@v4
with:
path: ./${{ steps.build.outputs.UNSIGNED_REDIS_BINARY }}
name: ${{ steps.build.outputs.UNSIGNED_REDIS_BINARY }}

- name: Setup Keychain and Certificate
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
# Decode and save certificate
echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12
# Create and configure keychain
security create-keychain -p "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
security unlock-keychain -p "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
security set-keychain-settings -t 3600 -l build.keychain
# Add to search list and set as default
security list-keychains -d user -s build.keychain login.keychain
security default-keychain -s build.keychain
# Import and trust certificate
security import certificate.p12 -k build.keychain -P "${{ secrets.MACOS_CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.MACOS_KEYCHAIN_PASSWORD }}" build.keychain
# Debug certificate presence
security find-identity -v -p codesigning build.keychain
- name: Sign Binaries
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
id: sign
run: |
# Get identity from specific keychain
CODESIGN_IDENTITY=$(security find-identity -v -p codesigning build.keychain | grep -o '[0-9A-F]\{40\}' | head -n 1)
echo "Using identity: ${CODESIGN_IDENTITY}"
# Check if entitlements file exists
if [ ! -f configs/entitlements.xml ]; then
echo "Entitlements file not found!"
exit 1
fi
# Sign binaries with explicit keychain
for i in $(ls build_dir/bin); do
/usr/bin/codesign --keychain build.keychain --options=runtime --timestamp -v --sign "${CODESIGN_IDENTITY}" --entitlements configs/entitlements.xml -f build_dir/bin/$i
done
# Sign libraries with explicit keychain
for i in $(ls build_dir/lib/redis/modules); do
/usr/bin/codesign --keychain build.keychain --options=runtime --timestamp -v --sign "${CODESIGN_IDENTITY}" --entitlements configs/entitlements.xml -f build_dir/lib/redis/modules/$i
done
# Create distribution archive
(cd build_dir && zip -r ../redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip .)
echo "REDIS_BINARY=redis-ce-${{ vars.BINARY_VERSION_TO_BUILD }}-$(uname -m).zip" >> $GITHUB_OUTPUT
- name: Notarize Redis CE Binary Distribution
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
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 }}
- uses: aws-actions/configure-aws-credentials@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
aws-region: ${{ secrets.S3_REGION }}
role-to-assume: ${{ secrets.S3_IAM_ARN }}

- name: Upload Redis CE Binary Distribution to S3
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
aws s3 cp ${{ steps.sign.outputs.REDIS_BINARY }} s3://${{ secrets.S3_BUCKET }}/homebrew/ --acl public-read
125 changes: 125 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Test Redis CE

on:
pull_request:
types: [ labeled ]
branches: [ main ]
paths:
- '.github/workflows/test.yml'
- 'Casks/**'

jobs:
test:
if: github.event.label.name == 'run-tests'
name: Test Redis CE
strategy:
fail-fast: false
matrix:
os_version: # See: https://github.com/actions/runner-images/blob/main/README.md#available-images
- macos-15-large # macOS 15 x86_64
- macos-15 # macOS 15 arm64
- macos-14-large # macOS 14 x86_64
- macos-14 # macOS 14 arm64
- macos-13 # macOS 13 x86_64
- macos-13-xlarge # macOS 13 arm64
cask:
- redis
- redis-rc

runs-on: ${{ matrix.os_version }}

steps:
- uses: actions/checkout@v4

- name: Set up Homebrew
run: |
export HOMEBREW_GITHUB_API_TOKEN=$GITHUB_TOKEN
brew update
brew tap ${{ vars.REDIS_TAP }} .
- name: Install Redis CE
run: |
brew install --cask ${{ matrix.cask }} --debug --verbose
ls -al $(brew --prefix)/etc/redis.conf
ls -al $(brew --prefix)/lib/redis/modules
ls -al $(brew --prefix)/bin/redis*
- name: Test Redis Installation
run: |
redis-server --version
redis-server $(brew --prefix)/etc/redis.conf
for i in {1..30}; do redis-cli ping && break || echo "Waiting for Redis... $i" && sleep 1; done
redis-cli info server || { echo "Cannot get server info"; exit 1; }
redis-cli module list
- name: Verify Installed Modules
run: |
modules=$(redis-cli module list)
echo "Installed modules:"
echo "$modules"
missing_modules=()
for module in "bf" "search" "timeseries" "ReJSON"; do
if ! echo "$modules" | grep -q "$module"; then
missing_modules+=("$module")
fi
done
if [ ${#missing_modules[@]} -eq 0 ]; then
echo "All required modules are installed"
else
echo "The following modules are missing: ${missing_modules[*]}"
exit 1
fi
- name: Test RedisBloom
run: |
redis-cli BF.ADD popular_keys "redis:hash"
redis-cli BF.ADD popular_keys "redis:set"
[ "$(redis-cli BF.EXISTS popular_keys "redis:hash")" = "1" ] || \
{ echo "RedisBloom test failed: 'redis:hash' not found"; exit 1; }
[ "$(redis-cli BF.EXISTS popular_keys "redis:list")" = "0" ] || \
{ echo "RedisBloom test failed: 'redis:list' found unexpectedly"; exit 1; }
echo "RedisBloom test passed successfully"
- name: Test RediSearch
run: |
redis-cli FT.CREATE redis_commands ON HASH PREFIX 1 cmd: SCHEMA name TEXT SORTABLE description TEXT
redis-cli HSET cmd:set name "SET" description "Set the string value of a key"
redis-cli HSET cmd:get name "GET" description "Get the value of a key"
result=$(redis-cli FT.SEARCH redis_commands "value")
if echo "$result" | grep -q "Set the string value of a key" && \
echo "$result" | grep -q "Get the value of a key"; then
echo "RediSearch test passed successfully"
else
echo "RediSearch test failed: expected commands not found in search results"
exit 1
fi
- name: Test RedisTimeSeries
run: |
redis-cli TS.CREATE redis:cpu:usage RETENTION 86400
redis-cli TS.ADD redis:cpu:usage "*" 80
redis-cli TS.ADD redis:cpu:usage "*" 65
redis-cli TS.ADD redis:cpu:usage "*" 70
result=$(redis-cli TS.RANGE redis:cpu:usage - + COUNT 3)
if echo "$result" | grep -q "80" && \
echo "$result" | grep -q "65" && \
echo "$result" | grep -q "70"; then
echo "RedisTimeSeries test passed successfully"
else
echo "RedisTimeSeries test failed: expected values not found in time series"
exit 1
fi
- name: Test ReJSON
run: |
redis-cli JSON.SET redis:config $ '{"maxmemory":"2gb","maxmemory-policy":"allkeys-lru"}'
result=$(redis-cli JSON.GET redis:config $.maxmemory-policy)
cleaned_result=$(echo $result | tr -d '[]"')
if [ "$cleaned_result" = "allkeys-lru" ]; then
echo "ReJSON test passed successfully"
else
echo "ReJSON test failed: expected 'allkeys-lru', got $result"
exit 1
fi
- name: Test uninstall
run: |
brew uninstall ${{ matrix.cask }}
brew untap ${{ vars.REDIS_TAP }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
99 changes: 99 additions & 0 deletions Casks/redis-rc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
cask "redis-rc" do
arch arm: "arm64", intel: "x86_64"

version "8.0-m03"
sha256 arm: "b8c4432ca2f8609165db676898944a61635dc9a38a94149309d66387e851d38d",
intel: "fdc3ef3e197ffb95b60bf54233fb19304b225a816477e8bd17dccbb66509b88a"

url "https://packages.redis.io/homebrew/redis-ce-#{version}-#{arch}.zip"
name "Redis Community Edition - Pre-Release"
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."
homepage "https://redis.io/"

depends_on macos: ">= :ventura"

depends_on formula: "openssl@3"
depends_on formula: "libomp"
depends_on formula: "llvm@18"

conflicts_with formula: "redis"

binaries = %w[
redis-cli
redis-benchmark
redis-check-aof
redis-check-rdb
redis-sentinel
redis-server
]

postflight do
basepath = HOMEBREW_PREFIX.to_s
caskbase = "#{caskroom_path}/#{version}"
confdir = "#{basepath}/etc"
moduledir = "#{basepath}/lib/redis/modules"

FileUtils.mkdir_p(confdir)
FileUtils.mkdir_p(moduledir)

# Replace <HOMEBREW_PREFIX> with the actual value
src = "#{caskbase}/etc/redis.conf"
conffile = "#{confdir}/redis.conf"
FileUtils.cp(src, conffile) unless File.exist?(conffile)
text = File.read(conffile)
new_contents = text.gsub("<HOMEBREW_PREFIX>", basepath)
File.open(conffile, "w") { |file| file.puts new_contents }

# link binaries
binaries.each do |item|
src = "#{caskbase}/bin/#{item}"
dest = "#{basepath}/bin/#{item}"
FileUtils.ln_sf(src, dest)
end

# link modules
Dir["#{caskbase}/lib/redis/modules/*.so"].each do |item|
module_name = File.basename(item)
dest = "#{moduledir}/#{module_name}"
File.symlink(item, dest) unless File.exist?(dest)
end
end

uninstall_postflight do
basepath = HOMEBREW_PREFIX.to_s

# Remove binary symlinks
binaries.each do |item|
dest = "#{basepath}/bin/#{item}"
File.delete(dest) if File.symlink?(dest) && File.exist?(dest)
end

# Remove module symlinks
moduledir = "#{basepath}/lib/redis/modules"
Dir["#{moduledir}/*.so"].each do |item|
module_name = File.basename(item)
dest = "#{moduledir}/#{module_name}"
File.delete(dest)
end

# Clean up empty directories
FileUtils.rm_rf(moduledir) if Dir.empty?(moduledir)
FileUtils.rm_rf("#{basepath}/lib/redis") if Dir.empty?("#{basepath}/lib/redis")
end

caveats <<~EOS
🚨THIS IS A PRE-RELEASE VERSION!! BREAKING CHANGES MAY OCCUR WITHOUT NOTICE!!🚨
Redis Community Edition has been successfully installed!
The default configuration file has been copied to:
#{HOMEBREW_PREFIX}/etc/redis.conf
To customize Redis, edit this file as needed and restart Redis to apply changes.
If you want to run Redis as a service, use:
redis-server #{HOMEBREW_PREFIX}/etc/redis.conf
To stop the service:
redis-cli shutdown
EOS
end
Loading

0 comments on commit 6553b50

Please sign in to comment.