Skip to content

Commit f4ff013

Browse files
authored
build and load modules (redis#1)
* implemented matrix for build arch, updated licence description, switched to installing rust according to redis/redis flow * added test job as a placeholder for smoke test
1 parent 412815f commit f4ff013

File tree

3 files changed

+156
-19
lines changed

3 files changed

+156
-19
lines changed

.github/workflows/tags.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-20.04
11-
if: github.repository == 'redis/redis-snap'
11+
# if: github.repository == 'redis/redis-snap'
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Determine version

.github/workflows/unstable.yml

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
name: Unstable
22

33
on:
4+
# TBD when this workflow should run
5+
pull_request:
46
workflow_dispatch:
5-
schedule:
6-
- cron: '0 0 * * *'
7+
#schedule:
8+
# - cron: '0 0 * * *'
79

810
jobs:
911
build:
10-
runs-on: ubuntu-20.04
11-
if: github.repository == 'redis/redis-snap'
12+
runs-on: ubuntu-22.04
13+
#Next line is in comment for testing with forked repository
14+
#if: github.repository == 'redis/redis-snap'
15+
strategy:
16+
matrix:
17+
target-arch: [amd64, arm64]
1218
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v4
1521
with:
1622
repository: redis/redis
1723
path: redis
@@ -26,18 +32,68 @@ jobs:
2632
- name: Setup Snapcraft
2733
run: |
2834
sudo snap install snapcraft --classic
29-
- name: Build amd64
35+
- name: Build Snap
3036
env:
3137
SNAPCRAFT_BUILD_ENVIRONMENT: host
3238
SNAPCRAFT_BUILD_INFO: 1
33-
run: snapcraft --target-arch amd64 --destructive-mode --enable-experimental-target-arch
34-
- name: Build arm64
35-
env:
36-
SNAPCRAFT_BUILD_ENVIRONMENT: host
37-
SNAPCRAFT_BUILD_INFO: 1
38-
run: snapcraft --target-arch arm64 --destructive-mode --enable-experimental-target-arch
39+
run: |
40+
echo "the architecture is ${{ matrix.target-arch }}"
41+
sudo snapcraft --verbose --target-arch ${{ matrix.target-arch }} --destructive-mode --enable-experimental-target-arch
42+
# continue-on-error: true #Consider removing this line after finishing testing
43+
44+
- name: Archive Snapcraft logs on failure
45+
# Can be removed when pushing to the real repository
46+
if: failure() # This step runs only if a previous step fails
47+
run: |
48+
LOG_DIR="${HOME}/.local/state/snapcraft"
49+
echo "Searching for logs in $LOG_DIR..."
50+
ls -R $LOG_DIR || echo "No logs found."
51+
continue-on-error: true # Ensure this step does not block execution
52+
53+
- name: Upload Snapcraft logs as artifact
54+
# Can be removed when pushing to the real repository
55+
if: failure() # Runs only on failure
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: snapcraft-logs
59+
path: ~/.local/state/snapcraft/log
60+
3961
- name: Upload
4062
run: |
41-
for f in *.snap; do snapcraft upload --release=edge $f; done
63+
echo "placeholder for snap package upload"
64+
# for f in *.snap; do snapcraft upload --release=edge $f; done
4265
env:
4366
SNAPCRAFT_STORE_CREDENTIALS: ${{secrets.SNAP_TOKEN}}
67+
- name: upload to artifacts
68+
# Can be removed when pushing to the real repository
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: redis-snap-${{ matrix.target-arch }}
72+
path: |
73+
*.snap
74+
75+
test:
76+
# This step is for basic testing of the snap package and is a placeholder for more comprehensive testing (e.g. using smoke tests)
77+
needs: build
78+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu24-arm64-4-16' || 'ubuntu-latest' }} # Not sure what version of Ubuntu should be used for testing
79+
strategy:
80+
matrix:
81+
target-arch: [ amd64, arm64 ]
82+
steps:
83+
- name: Download artifact
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: redis-snap-${{ matrix.target-arch }}
87+
path: ./snap-artifacts
88+
- name: Install the snap package
89+
run: |
90+
SNAP_FILE=$(ls snap-artifacts/*.snap)
91+
echo "Installing snap: $SNAP_FILE"
92+
sudo snap install --dangerous $SNAP_FILE
93+
- name: Verify snap installation
94+
run: |
95+
snap list | grep redis
96+
snap services | grep redis || echo "Redis service not found."
97+
- name: Check Redis snap status
98+
run: |
99+
snap info redis

snap/snapcraft.yaml

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: redis
22
adopt-info: redis
33
summary: Redis is used as a database, cache and message broker. # 79 char long summary
44
description: |
5-
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. |
5+
Redis is source-available software, available under both the Redis Source Available License v2 (RSALv2) and the Server Side Public License v1 (SSPLv1). In-memory data structure store, used as a database, cache and message broker. |
66
It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. |
77
Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. |
88
|
99
Check out https://redis.io/ for more information.
1010
1111
grade: stable # must be 'stable' to release into candidate/stable channels
1212
confinement: strict # use 'strict' once you have the right plugs and slots
13-
base: core20
13+
base: core22
1414

1515
apps:
1616
server:
17-
command: usr/bin/redis-server
17+
command: usr/bin/redis-server --loadmodule $SNAP/usr/lib/redis/modules/redisbloom.so --loadmodule $SNAP/usr/lib/redis/modules/rejson.so --loadmodule $SNAP/usr/lib/redis/modules/redistimeseries.so --loadmodule $SNAP/usr/lib/redis/modules/redisearch.so
1818
daemon: simple
1919
restart-condition: always
2020
environment:
@@ -65,8 +65,50 @@ apps:
6565
parts:
6666
redis:
6767
plugin: make
68-
source: redis/
68+
source: https://github.com/redis/redis.git
69+
# Switch to source: redis when not running from fork for testing
70+
# source: redis
71+
source-branch: 8.0-m01
72+
build-environment:
73+
- BUILD_WITH_MODULES: "yes"
6974
override-build: |
75+
echo "BUILD_WITH_MODULES = $BUILD_WITH_MODULES"
76+
77+
# Rust installation script
78+
RUST_VERSION=1.80.1; \
79+
ARCH="$(uname -m)"; \
80+
if ldd --version 2>&1 | grep -q musl; then LIBC_TYPE="musl"; else LIBC_TYPE="gnu"; fi; \
81+
echo "Detected architecture: ${ARCH} and libc: ${LIBC_TYPE}"; \
82+
case "${ARCH}" in \
83+
'x86_64') \
84+
if [ "${LIBC_TYPE}" = "musl" ]; then \
85+
RUST_INSTALLER="rust-${RUST_VERSION}-x86_64-unknown-linux-musl"; \
86+
RUST_SHA256="37bbec6a7b9f55fef79c451260766d281a7a5b9d2e65c348bbc241127cf34c8d"; \
87+
else \
88+
RUST_INSTALLER="rust-${RUST_VERSION}-x86_64-unknown-linux-gnu"; \
89+
RUST_SHA256="85e936d5d36970afb80756fa122edcc99bd72a88155f6bdd514f5d27e778e00a"; \
90+
fi ;; \
91+
'aarch64') \
92+
if [ "${LIBC_TYPE}" = "musl" ]; then \
93+
RUST_INSTALLER="rust-${RUST_VERSION}-aarch64-unknown-linux-musl"; \
94+
RUST_SHA256="dd668c2d82f77c5458deb023932600fae633fff8d7f876330e01bc47e9976d17"; \
95+
else \
96+
RUST_INSTALLER="rust-${RUST_VERSION}-aarch64-unknown-linux-gnu"; \
97+
RUST_SHA256="2e89bad7857711a1c11d017ea28fbfeec54076317763901194f8f5decbac1850"; \
98+
fi ;; \
99+
*) echo >&2 "Unsupported architecture: '${ARCH}'"; exit 1 ;; \
100+
esac; \
101+
echo "Downloading and installing Rust standalone installer: {RUST_INSTALLER}"; \
102+
wget --quiet -O ${RUST_INSTALLER}.tar.xz https://static.rust-lang.org/dist/${RUST_INSTALLER}.tar.xz; \
103+
echo "${RUST_SHA256} ${RUST_INSTALLER}.tar.xz" | sha256sum -c --quiet || { echo "Rust standalone installer checksum failed!"; exit 1; }; \
104+
tar -xf ${RUST_INSTALLER}.tar.xz; \
105+
(cd ${RUST_INSTALLER} && ./install.sh); \
106+
rm -rf ${RUST_INSTALLER}
107+
108+
echo "source $HOME/.cargo/env"
109+
mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr
110+
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
111+
export PYTHON=python3
70112
mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr
71113
export CC=${SNAPCRAFT_ARCH_TRIPLET}-gcc
72114
export DEB_HOST_GNU_TYPE=${SNAPCRAFT_ARCH_TRIPLET}
@@ -78,8 +120,47 @@ parts:
78120
VER="unstable-$GITSHA"
79121
fi
80122
snapcraftctl set-version $VER
123+
mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/lib/redis/modules
124+
125+
81126
build-packages:
82127
- to arm64:
128+
- gcc
129+
- g++
130+
- git
131+
- cmake
132+
- python3
133+
- python3-pip
134+
- python3-venv
135+
- python3-dev
136+
- unzip
137+
- rsync
138+
- clang
139+
- automake
140+
- autoconf
141+
- libtool
142+
- libssl-dev
143+
- curl
83144
- libssl-dev:arm64
145+
- jq
84146
- to amd64:
147+
- libboost-all-dev
148+
- gcc
149+
- g++
150+
- git
151+
- cmake
152+
- python3
153+
- python3-pip
154+
- python3-venv
155+
- python3-dev
156+
- unzip
157+
- rsync
158+
- clang
159+
- automake
160+
- autoconf
161+
- libtool
162+
- libssl-dev
163+
- curl
85164
- libssl-dev:amd64
165+
- jq
166+

0 commit comments

Comments
 (0)