Skip to content

Commit bb9b87b

Browse files
authored
Merge pull request #63 from aerospike/ARM-SUPPORT
Arm support & CI/CD pipeline
2 parents 4896665 + 3fd0bd6 commit bb9b87b

File tree

11 files changed

+470
-18
lines changed

11 files changed

+470
-18
lines changed

.build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: act
2+
3+
container:
4+
- base:
5+
- docker.qe.aerospike.com/build/aerospike-server:arm-centos-7
6+
- docker.qe.aerospike.com/build/aerospike-server:arm-rhel-8
7+
- docker.qe.aerospike.com/build/aerospike-server:arm-debian-10
8+
- docker.qe.aerospike.com/build/aerospike-server:arm-debian-11
9+
- docker.qe.aerospike.com/build/aerospike-server:arm-ubuntu-18.04
10+
- docker.qe.aerospike.com/build/aerospike-server:arm-ubuntu-20.04
11+
12+
- docker.qe.aerospike.com/build/aerospike-server:x86-centos-7
13+
- docker.qe.aerospike.com/build/aerospike-server:x86-rhel-8
14+
- docker.qe.aerospike.com/build/aerospike-server:x86-debian-10
15+
- docker.qe.aerospike.com/build/aerospike-server:x86-debian-11
16+
- docker.qe.aerospike.com/build/aerospike-server:x86-ubuntu-18.04
17+
- docker.qe.aerospike.com/build/aerospike-server:x86-ubuntu-20.04
18+
19+
build:
20+
- name: default
21+
script:
22+
- make all
23+
- make $PKG
24+
artifact:
25+
- target/bin/*
26+
- target/packages/*

.github/workflows/build.yml

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,72 @@ name: Build ACT
33
on:
44
push:
55
branches: [ master ]
6+
tags:
7+
- '*'
68
pull_request:
79
branches: [ master ]
8-
10+
911
jobs:
10-
build:
12+
buils_debian_x86_64:
13+
runs-on: ubuntu-latest
1114
strategy:
1215
matrix:
13-
os: ['ubuntu-latest']
14-
runs-on: ${{ matrix.os }}
16+
container: [ 'debian:10', 'debian:11' ]
17+
container:
18+
image: ${{ matrix.container }}
19+
options: "--entrypoint /bin/bash"
20+
steps:
21+
- name: Install Dependencies (Debian)
22+
run: |
23+
apt-get -y update
24+
apt-get -y install make gcc libc6-dev git build-essential
25+
26+
- name: Clone Source
27+
run: git clone https://github.com/aerospike/act.git
28+
29+
- name: build act (debian)
30+
working-directory: ./act
31+
run: |
32+
echo "REV=$(make -f pkg/Makefile.deb print-REV)" >> $GITHUB_ENV
33+
echo "OS=$(make -f pkg/Makefile.deb print-OS)" >> $GITHUB_ENV
34+
echo "ARCH=$(make -f pkg/Makefile.deb print-ARCH)" >> $GITHUB_ENV
35+
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
36+
make all deb
1537
16-
steps:
17-
- name: Install Dependencies (Ubuntu)
38+
- name: Upload Artifacts
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: act_${{ env.REV }}-1${{ env.OS }}_${{ env.ARCH }}.deb
42+
path: /__w/act/act/act/target/packages/act_*
43+
if-no-files-found: error
44+
45+
build_ubuntu_x86_64:
46+
strategy:
47+
matrix:
48+
os: [ 'ubuntu-20.04', 'ubuntu-18.04' ]
49+
runs-on: ${{ matrix.os }}
50+
steps:
51+
- name: Install Dependencies
1852
run: sudo apt-get install make gcc libc6-dev
19-
if: matrix.os == 'ubuntu-latest'
53+
2054
- name: Get Sources
21-
uses: actions/checkout@v2
55+
uses: actions/checkout@v3
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Set env
60+
run: |
61+
echo "REV=$(make -f pkg/Makefile.deb print-REV)" >> $GITHUB_ENV
62+
echo "OS=$(make -f pkg/Makefile.deb print-OS)" >> $GITHUB_ENV
63+
echo "ARCH=$(make -f pkg/Makefile.deb print-ARCH)" >> $GITHUB_ENV
64+
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
65+
2266
- name: build
23-
run: make
24-
- name: Upload Artifact
25-
uses: actions/[email protected]
67+
run: make all deb
68+
69+
- name: Upload Artifact
70+
uses: actions/upload-artifact@v3
2671
with:
27-
name: act-linux-$GITHUB_REF
28-
path: target/bin/
72+
name: act_${{ env.REV }}-1${{ env.OS }}_${{ env.ARCH }}.deb
73+
path: target/packages
2974
if-no-files-found: error

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ DIR_TARGET = target
1414
DIR_OBJ = $(DIR_TARGET)/obj
1515
DIR_BIN = $(DIR_TARGET)/bin
1616

17+
DIR_PKG = $(DIR_TARGET)/packages
18+
DIR_RPM = pkg/rpm/RPMS
19+
DIR_DEB = pkg/deb/DEBS
20+
1721
SRC_DIRS = common index prep storage
1822
OBJ_DIRS = $(SRC_DIRS:%=$(DIR_OBJ)/src/%)
1923

@@ -47,7 +51,7 @@ default: all
4751
all: act_index act_prep act_storage
4852

4953
target_dir:
50-
/bin/mkdir -p $(DIR_BIN) $(OBJ_DIRS)
54+
/bin/mkdir -p $(DIR_BIN) $(OBJ_DIRS) $(DIR_PKG)
5155

5256
act_index: target_dir $(INDEX_OBJECTS)
5357
echo "Linking $@"
@@ -61,12 +65,24 @@ act_storage: target_dir $(STORAGE_OBJECTS)
6165
echo "Linking $@"
6266
$(CC) $(LDFLAGS) -o $(STORAGE_BINARY) $(STORAGE_OBJECTS) $(LIBRARIES)
6367

64-
# For now we only clean everything.
65-
clean:
66-
/bin/rm -rf $(DIR_TARGET)
67-
6868
-include $(ALL_DEPENDENCIES)
6969

7070
$(DIR_OBJ)/%.o: %.c
7171
echo "Building $@"
7272
$(CC) $(CFLAGS) -o $@ -c $(INCLUDES) $<
73+
74+
.PHONY: rpm
75+
rpm:
76+
$(MAKE) -f pkg/Makefile.rpm
77+
78+
.PHONY: deb
79+
deb:
80+
$(MAKE) -f pkg/Makefile.deb
81+
82+
# For now we only clean everything.
83+
.PHONY: clean
84+
clean:
85+
/bin/rm -rf $(DIR_TARGET)
86+
/bin/rm -rf $(DIR_RPM)
87+
/bin/rm -rf $(DIR_DEB)
88+
/bin/rm -rf dist

build/os_version

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------------------------------
3+
# Copyright 2012-2015 Aerospike, Inc.
4+
#
5+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
6+
# license agreements.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
9+
# use this file except in compliance with the License. You may obtain a copy of
10+
# the License at http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations under
16+
# the License.
17+
# ------------------------------------------------------------------------------
18+
19+
OPT_LONG=0
20+
21+
if [ "$1" = "-long" ]
22+
then
23+
OPT_LONG=1
24+
fi
25+
26+
error() {
27+
echo 'error:' $* >&2
28+
}
29+
30+
main() {
31+
32+
local kernel=''
33+
local distro_id=''
34+
local distro_version=''
35+
local distro_long=''
36+
local distro_short=''
37+
38+
# Make sure this script is running on Linux
39+
# The script is not designed to work on non-Linux
40+
# operating systems.
41+
kernel=$(uname -s | tr '[:upper:]' '[:lower:]')
42+
if [ "$kernel" != 'linux' ]
43+
then
44+
error "$kernel is not supported."
45+
exit 1
46+
fi
47+
48+
if [ -f /etc/os-release ]
49+
then
50+
. /etc/os-release
51+
distro_id=${ID,,}
52+
distro_version=${VERSION_ID}
53+
elif [ -f /etc/issue ]
54+
then
55+
issue=$(cat /etc/issue | tr '[:upper:]' '[:lower:]')
56+
case "$issue" in
57+
*'centos'* )
58+
distro_id='centos'
59+
;;
60+
*'redhat'* | *'rhel'* )
61+
distro_id='rhel'
62+
;;
63+
*'debian'* )
64+
distro_id='debian'
65+
;;
66+
* )
67+
error "/etc/issue contained an unsupported linux distibution: $issue"
68+
exit 1
69+
;;
70+
esac
71+
72+
case "$distro_id" in
73+
'centos' | 'rhel' )
74+
local release=''
75+
if [ -f /etc/centos-release ]; then
76+
release=$(cat /etc/centos-release | tr '[:upper:]' '[:lower:]')
77+
elif [ -f /etc/redhat-release ]; then
78+
release=$(cat /etc/redhat-release | tr '[:upper:]' '[:lower:]')
79+
fi
80+
release_version=${release##*release}
81+
distro_version=${release_version%.*}
82+
;;
83+
'debian' )
84+
debian_version=$(cat /etc/debian_version | tr '[:upper:]' '[:lower:]')
85+
distro_version=${debian_version%%.*}
86+
;;
87+
* )
88+
error "/etc/issue contained an unsupported linux distibution: $issue"
89+
exit 1
90+
;;
91+
esac
92+
fi
93+
94+
distro_id=${distro_id//[[:space:]]/}
95+
distro_version=${distro_version//[[:space:]]/}
96+
97+
case "$distro_id" in
98+
'centos' )
99+
distro_long="${distro_id}${distro_version%%.*}"
100+
distro_short="el${distro_version%%.*}"
101+
;;
102+
'rhel' | 'redhat' | 'red hat' )
103+
distro_long="${distro_id}${distro_version%%.*}"
104+
distro_short="el${distro_version%%.*}"
105+
;;
106+
'fedora' )
107+
if [ "$distro_version" -gt "15" ]
108+
then
109+
distro_version=7
110+
elif [ "$distro_version" -gt "10" ]
111+
then
112+
distro_version=6
113+
else
114+
error "Unsupported linux distibution: $distro_id $distro_version"
115+
exit 1
116+
fi
117+
distro_long="centos${distro_version}"
118+
distro_short="el${distro_version}"
119+
;;
120+
'amzn' )
121+
distro_long="ami"
122+
distro_short="ami"
123+
;;
124+
* )
125+
distro_long="${distro_id}${distro_version}"
126+
distro_short="${distro_id}${distro_version}"
127+
;;
128+
esac
129+
130+
if [ "$OPT_LONG" = "1" ]
131+
then
132+
echo "${distro_long}"
133+
else
134+
echo "${distro_short}"
135+
fi
136+
exit 0
137+
}
138+
139+
main

build/version

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
rev=`git describe --always`
4+
subbuild=`echo $rev | awk -F'-' '{print $2}'`
5+
if [ "$subbuild" != "" ]
6+
then
7+
# rev=`echo $rev | awk -F'-' '{printf("%s-%s\n",$1,$2)}'`
8+
rev=`echo $rev | awk -F'-' '{printf("%s\n",$1)}'`
9+
fi
10+
echo $rev

pkg/Makefile.deb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Build act distribution.
2+
3+
export DEB_SOURCE_ROOT = $(shell echo `pwd`/dist)
4+
export DEB_BUILD_ROOT = $(DEB_SOURCE_ROOT)/BUILD
5+
export CL_BASE = $(DEB_BUILD_ROOT)/opt/aerospike
6+
export ETC_BASE = $(DEB_BUILD_ROOT)/etc/aerospike
7+
8+
9+
#REV = $(shell git describe 2>/dev/null; if [ $${?} != 0 ]; then echo 'unknown'; fi)
10+
DIR_PKG = target/packages
11+
REV = $(shell build/version)
12+
OS = $(shell build/os_version)
13+
ARCH=$(shell uname -m)
14+
MANIFEST_DIR = manifest/TEMP
15+
16+
ifeq ($(ARCH), x86_64)
17+
ARCH=amd64
18+
endif
19+
20+
ifeq ($(ARCH), aarch64)
21+
ARCH=arm64
22+
endif
23+
24+
.PHONY: default
25+
default: dist
26+
27+
.PHONY: dist
28+
dist:
29+
30+
# Build act package.
31+
@echo $(REV)
32+
@echo $(OS)
33+
rm -rf $(DEB_BUILD_ROOT)/*
34+
mkdir -p $(DEB_BUILD_ROOT)/DEBIAN
35+
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
36+
mkdir -p $(DIR_PKG)
37+
install -m 755 pkg/deb/postinst $(DEB_BUILD_ROOT)/DEBIAN/postinst
38+
install -m 755 pkg/deb/prerm $(DEB_BUILD_ROOT)/DEBIAN/prerm
39+
install -m 644 pkg/deb/control $(DEB_BUILD_ROOT)/DEBIAN/control
40+
41+
mkdir -p $(CL_BASE)
42+
mkdir -p $(ETC_BASE)
43+
mkdir -p $(CL_BASE)/bin
44+
45+
# act
46+
install -m 755 target/bin/act_* $(CL_BASE)/bin/
47+
install -m 755 analysis/act_latency.py $(CL_BASE)/bin/
48+
install -m 755 config/act_index.conf $(ETC_BASE)/
49+
install -m 755 config/act_storage.conf $(ETC_BASE)/
50+
51+
# Create symlinks to /usr/bin
52+
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
53+
ln -sf /opt/aerospike/bin/act_index $(DEB_BUILD_ROOT)/usr/bin/act_index
54+
ln -sf /opt/aerospike/bin/act_prep $(DEB_BUILD_ROOT)/usr/bin/act_prep
55+
ln -sf /opt/aerospike/bin/act_storage $(DEB_BUILD_ROOT)/usr/bin/act_storage
56+
ln -sf /opt/aerospike/bin/act_latency.py $(DEB_BUILD_ROOT)/usr/bin/act_latency.py
57+
58+
59+
sed 's/@VERSION@/'$(REV)'/g' <pkg/deb/control >$(DEB_BUILD_ROOT)/DEBIAN/control
60+
sed -i 's/@ARCH@/'$(ARCH)'/g' $(DEB_BUILD_ROOT)/DEBIAN/control
61+
fakeroot dpkg-deb --build $(DEB_BUILD_ROOT) $(DIR_PKG)/act_$(REV)-1$(OS)_$(ARCH).deb
62+
rm -rf dist
63+
64+
distclean:
65+
rm -rf $(DEB_SOURCE_ROOT)
66+
rm -rf target/packages
67+
68+
print-% : ; @echo $($*)

0 commit comments

Comments
 (0)