Skip to content

Commit ddf2e4c

Browse files
committed
feat(ci): Add multi-architecture RPM builds and local GitHub Actions testing
- Add act configuration for local GitHub Actions workflow testing - Implement multi-architecture RPM builds (x86_64, aarch64) - Improve RPM build scripts with architecture-specific support - Add comprehensive RPM build documentation - Fix clang-tidy warnings and improve code formatting checks - Enhance test infrastructure with proper discovery timeouts - Add missing cstdint include in error.h
1 parent 3d32db4 commit ddf2e4c

File tree

24 files changed

+738
-89
lines changed

24 files changed

+738
-89
lines changed

.actrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# act configuration file
2+
# See: https://nektosact.com/usage/index.html
3+
4+
# Use medium-sized Docker images (balance between size and features)
5+
-P ubuntu-latest=catthehacker/ubuntu:act-latest
6+
7+
# For Apple Silicon, use amd64 architecture
8+
--container-architecture linux/amd64
9+
10+
# Enable verbose output
11+
-v
12+
13+
# Reuse containers to speed up subsequent runs
14+
--reuse
15+
16+
# Bind Docker socket for Docker-in-Docker operations
17+
--container-daemon-socket -

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Checks: >
33
clang-diagnostic-*,
44
clang-analyzer-*,
55
-clang-analyzer-cplusplus.NewDeleteLeaks,
6+
-clang-analyzer-core.uninitialized.Assign,
67
cppcoreguidelines-*,
78
modernize-*,
89
performance-*,

.github/workflows/release.yml

Lines changed: 142 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@ permissions:
1010

1111
jobs:
1212
build-rpm:
13-
name: Build RPM Package
13+
name: Build RPM Package (${{ matrix.arch }})
1414
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
arch: [x86_64, aarch64]
18+
fail-fast: false
1519

1620
steps:
1721
- name: Checkout code
1822
uses: actions/checkout@v4
1923
with:
2024
fetch-depth: 0 # Fetch all history for git describe
2125

26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
with:
29+
platforms: arm64,amd64
30+
2231
- name: Set up Docker Buildx
2332
uses: docker/setup-buildx-action@v3
2433

@@ -27,60 +36,167 @@ jobs:
2736
run: |
2837
VERSION="${GITHUB_REF#refs/tags/v}"
2938
echo "version=$VERSION" >> $GITHUB_OUTPUT
30-
echo "Building version: $VERSION"
39+
echo "Building version: $VERSION for architecture: ${{ matrix.arch }}"
3140
32-
- name: Build RPM package
41+
- name: Set architecture-specific variables
42+
id: arch
43+
run: |
44+
if [ "${{ matrix.arch }}" = "x86_64" ]; then
45+
echo "docker_platform=linux/amd64" >> $GITHUB_OUTPUT
46+
echo "docker_arch=amd64" >> $GITHUB_OUTPUT
47+
else
48+
echo "docker_platform=linux/arm64" >> $GITHUB_OUTPUT
49+
echo "docker_arch=arm64" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Build RPM builder Docker image
3353
run: |
34-
cd support/rpm
35-
./test-rpm-build.sh
54+
docker buildx build \
55+
--platform ${{ steps.arch.outputs.docker_platform }} \
56+
--load \
57+
--cache-from type=gha,scope=rpmbuild-${{ matrix.arch }} \
58+
--cache-to type=gha,mode=max,scope=rpmbuild-${{ matrix.arch }} \
59+
-f support/rpm/Dockerfile.rpmbuild \
60+
-t mygramdb-rpmbuild:${{ steps.version.outputs.version }}-${{ matrix.arch }} \
61+
.
62+
63+
- name: Build RPM packages
64+
run: |
65+
# Create output directory in workspace
66+
mkdir -p "$GITHUB_WORKSPACE/dist/rpm"
67+
68+
# Run RPM build with absolute paths
69+
docker run --rm \
70+
--platform ${{ steps.arch.outputs.docker_platform }} \
71+
-e MYGRAMDB_VERSION="${{ steps.version.outputs.version }}" \
72+
-v "$GITHUB_WORKSPACE/dist:/workspace/dist" \
73+
mygramdb-rpmbuild:${{ steps.version.outputs.version }}-${{ matrix.arch }}
3674
37-
- name: List generated RPMs
75+
- name: Verify RPM packages exist
3876
run: |
77+
if ! ls dist/rpm/*.rpm 1> /dev/null 2>&1; then
78+
echo "Error: No RPM packages found in dist/rpm/"
79+
ls -la dist/rpm/ || true
80+
exit 1
81+
fi
3982
echo "Generated RPM packages:"
4083
ls -lh dist/rpm/*.rpm
4184
4285
- name: Test RPM installation (AlmaLinux 9)
4386
run: |
44-
docker run --rm -v "$(pwd)/dist:/dist" almalinux:9 bash -c "
87+
# Find the main RPM package (not debuginfo/debugsource/devel)
88+
MAIN_RPM=$(find dist/rpm -name "mygramdb-${{ steps.version.outputs.version }}-*.el9.${{ matrix.arch }}.rpm" \
89+
! -name "*debuginfo*" ! -name "*debugsource*" ! -name "*devel*" -print -quit)
90+
91+
if [ -z "$MAIN_RPM" ]; then
92+
echo "Error: Main RPM package not found for architecture ${{ matrix.arch }}"
93+
echo "Looking for: mygramdb-${{ steps.version.outputs.version }}-*.el9.${{ matrix.arch }}.rpm"
94+
echo "Available files:"
95+
ls -la dist/rpm/
96+
exit 1
97+
fi
98+
99+
echo "Testing RPM: $MAIN_RPM"
100+
101+
docker run --rm \
102+
--platform ${{ steps.arch.outputs.docker_platform }} \
103+
-v "$GITHUB_WORKSPACE/dist:/dist" \
104+
almalinux:9 bash -c "
105+
set -e
45106
echo '=== Installing Oracle MySQL 8.0 repository ==='
46-
dnf install -y https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm > /dev/null 2>&1
47-
dnf module disable -y mysql > /dev/null 2>&1
107+
dnf install -y https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
108+
dnf module disable -y mysql
48109
49110
echo '=== Installing MygramDB RPM ==='
50-
dnf install -y /dist/rpm/mygramdb-${{ steps.version.outputs.version }}-*.el9.*.rpm
111+
dnf install -y /dist/rpm/$(basename $MAIN_RPM)
51112
52113
echo '=== Verifying installation ==='
114+
echo 'Checking binaries exist...'
115+
test -x /usr/bin/mygramdb || (echo 'Error: mygramdb binary not found'; exit 1)
116+
test -x /usr/bin/mygram-cli || (echo 'Error: mygram-cli binary not found'; exit 1)
117+
53118
echo 'Checking for missing library dependencies...'
54-
ldd /usr/bin/mygramdb | grep 'not found' && exit 1 || echo 'mygramdb: OK'
55-
ldd /usr/bin/mygram-cli | grep 'not found' && exit 1 || echo 'mygram-cli: OK'
119+
if ldd /usr/bin/mygramdb | grep 'not found'; then
120+
echo 'Error: mygramdb has missing dependencies'
121+
exit 1
122+
fi
123+
echo 'mygramdb: OK'
124+
125+
if ldd /usr/bin/mygram-cli | grep 'not found'; then
126+
echo 'Error: mygram-cli has missing dependencies'
127+
exit 1
128+
fi
129+
echo 'mygram-cli: OK'
56130
57131
echo '=== Installation test passed! ==='
58132
"
59133
60134
- name: Upload RPM artifacts
61135
uses: actions/upload-artifact@v4
62136
with:
63-
name: rpm-packages
64-
path: |
65-
dist/rpm/*.rpm
137+
name: rpm-packages-${{ matrix.arch }}
138+
path: dist/rpm/*.rpm
66139
retention-days: 30
140+
if-no-files-found: error
141+
142+
create-release:
143+
name: Create GitHub Release
144+
needs: build-rpm
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Extract version from tag
152+
id: version
153+
run: |
154+
VERSION="${GITHUB_REF#refs/tags/v}"
155+
echo "version=$VERSION" >> $GITHUB_OUTPUT
156+
157+
- name: Download all artifacts
158+
uses: actions/download-artifact@v4
159+
with:
160+
path: dist/rpm
161+
pattern: rpm-packages-*
162+
merge-multiple: true
163+
164+
- name: List downloaded artifacts
165+
run: |
166+
echo "Downloaded RPM packages:"
167+
ls -lh dist/rpm/
67168
68169
- name: Create GitHub Release
69-
uses: softprops/action-gh-release@v1
170+
uses: softprops/action-gh-release@v2
70171
with:
71172
name: Release ${{ steps.version.outputs.version }}
72173
draft: false
73174
prerelease: false
74175
generate_release_notes: true
75-
files: |
76-
dist/rpm/mygramdb-${{ steps.version.outputs.version }}-*.el9.*.rpm
77-
dist/rpm/mygramdb-debuginfo-${{ steps.version.outputs.version }}-*.el9.*.rpm
78-
dist/rpm/mygramdb-debugsource-${{ steps.version.outputs.version }}-*.el9.*.rpm
176+
files: dist/rpm/*.rpm
177+
fail_on_unmatched_files: true
79178
body: |
80179
## MygramDB ${{ steps.version.outputs.version }}
81180
82181
### Installation (RHEL/AlmaLinux/Rocky Linux 9)
83182
183+
#### For x86_64 (Intel/AMD):
184+
```bash
185+
# Install Oracle MySQL 8.0 repository
186+
sudo dnf install -y https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
187+
sudo dnf module disable -y mysql
188+
189+
# Download and install MygramDB RPM
190+
wget https://github.com/${{ github.repository }}/releases/download/v${{ steps.version.outputs.version }}/mygramdb-${{ steps.version.outputs.version }}-1.el9.x86_64.rpm
191+
sudo dnf install -y ./mygramdb-${{ steps.version.outputs.version }}-1.el9.x86_64.rpm
192+
193+
# Configure and start service
194+
sudo cp /etc/mygramdb/config.yaml.example /etc/mygramdb/config.yaml
195+
sudo vi /etc/mygramdb/config.yaml # Edit configuration
196+
sudo systemctl enable --now mygramdb
197+
```
198+
199+
#### For aarch64 (ARM64):
84200
```bash
85201
# Install Oracle MySQL 8.0 repository
86202
sudo dnf install -y https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
@@ -98,7 +214,7 @@ jobs:
98214
99215
### Package Details
100216
- **Platform**: RHEL 9 / AlmaLinux 9 / Rocky Linux 9
101-
- **Architecture**: aarch64 (ARM64)
217+
- **Architectures**: x86_64 (Intel/AMD), aarch64 (ARM64)
102218
- **Build Type**: Static linking (minimal dependencies)
103219
- **Dependencies**: libicu, MySQL client libraries (auto-installed)
104220
@@ -108,3 +224,8 @@ jobs:
108224
- Systemd service: `/usr/lib/systemd/system/mygramdb.service`
109225
- Config example: `/etc/mygramdb/config.yaml.example`
110226
- Data directory: `/var/lib/mygramdb`
227+
228+
### Available Packages
229+
- `mygramdb-${{ steps.version.outputs.version }}-1.el9.x86_64.rpm` - Main package (x86_64)
230+
- `mygramdb-${{ steps.version.outputs.version }}-1.el9.aarch64.rpm` - Main package (aarch64)
231+
- Debug packages available for both architectures

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ _deps/
2828
.claude/
2929
CLAUDE.md
3030

31+
# act (GitHub Actions local runner)
32+
.secrets
33+
.act/
34+
3135
# Cache
3236
.cache/
3337

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ uninstall:
148148
# Format code with clang-format
149149
format:
150150
@echo "Formatting code..."
151-
@find src tests -name "*.cpp" -o -name "*.h" | xargs $(CLANG_FORMAT) -i
151+
@find src tests -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "*/build/*" | xargs $(CLANG_FORMAT) -i
152152
@echo "Format complete!"
153153

154154
# Check code formatting (CI mode - fails on formatting issues)
155155
format-check:
156156
@echo "Checking code formatting..."
157-
@find src tests -name "*.cpp" -o -name "*.h" | xargs $(CLANG_FORMAT) --dry-run --Werror
157+
@find src tests -type f \( -name "*.cpp" -o -name "*.h" \) ! -path "*/build/*" | xargs $(CLANG_FORMAT) --dry-run --Werror
158158
@echo "Format check passed!"
159159

160160
# Check code with clang-tidy
@@ -270,7 +270,7 @@ docker-lint-linux: docker-build-linux
270270
docker-format-check-linux: docker-dev-build
271271
@echo "Checking code formatting in Linux container..."
272272
docker run --rm -v $$(pwd):/workspace -w /workspace $(DOCKER_DEV_IMAGE) \
273-
bash -c "find src tests -name '*.cpp' -o -name '*.h' | xargs clang-format --dry-run --Werror"
273+
bash -c "find src tests -type f \( -name '*.cpp' -o -name '*.h' \) ! -path '*/build/*' | xargs clang-format --dry-run --Werror"
274274
@echo "Format check passed!"
275275

276276
# Clean build directory in Linux container

src/utils/error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#pragma once
1111

12+
#include <cstdint>
1213
#include <sstream>
1314
#include <string>
1415
#include <utility>

support/dev/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ RUN ccache --set-config=max_size=500M
4747
WORKDIR /workspace
4848

4949
# Default compiler (matching CI)
50-
ENV CC=ccache gcc
51-
ENV CXX=ccache g++
50+
ENV CC="ccache gcc"
51+
ENV CXX="ccache g++"
5252

5353
# Default command: show help
5454
CMD ["bash", "-c", "echo 'MygramDB Linux Development Environment'; \

support/rpm/Dockerfile.rpmbuild

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Dockerfile for building RPM packages
22
FROM rockylinux:9
33

4+
# Accept build arguments for multi-arch support
5+
ARG TARGETARCH
6+
ARG TARGETPLATFORM
7+
8+
# Log build information
9+
RUN echo "Building for platform: ${TARGETPLATFORM:-unknown}" && \
10+
echo "Target architecture: ${TARGETARCH:-unknown}" && \
11+
echo "System architecture: $(uname -m)"
12+
413
# Install Oracle MySQL 8.0 repository
514
RUN dnf -y install \
615
https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm && \
@@ -51,6 +60,7 @@ VERSION="${MYGRAMDB_VERSION:-0.0.0}"
5160
NAME="mygramdb"
5261

5362
echo -e "${YELLOW}Building ${NAME}-${VERSION}${NC}"
63+
echo -e "${YELLOW}Architecture: $(uname -m)${NC}"
5464

5565
# Create source tarball
5666
echo -e "${YELLOW}Creating source tarball...${NC}"

0 commit comments

Comments
 (0)