Skip to content

Commit

Permalink
Merge pull request #63 from aerospike/ARM-SUPPORT
Browse files Browse the repository at this point in the history
Arm support & CI/CD pipeline
  • Loading branch information
pvinh-spike authored Nov 15, 2022
2 parents 4896665 + 3fd0bd6 commit bb9b87b
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 18 deletions.
26 changes: 26 additions & 0 deletions .build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: act

container:
- base:
- docker.qe.aerospike.com/build/aerospike-server:arm-centos-7
- docker.qe.aerospike.com/build/aerospike-server:arm-rhel-8
- docker.qe.aerospike.com/build/aerospike-server:arm-debian-10
- docker.qe.aerospike.com/build/aerospike-server:arm-debian-11
- docker.qe.aerospike.com/build/aerospike-server:arm-ubuntu-18.04
- docker.qe.aerospike.com/build/aerospike-server:arm-ubuntu-20.04

- docker.qe.aerospike.com/build/aerospike-server:x86-centos-7
- docker.qe.aerospike.com/build/aerospike-server:x86-rhel-8
- docker.qe.aerospike.com/build/aerospike-server:x86-debian-10
- docker.qe.aerospike.com/build/aerospike-server:x86-debian-11
- docker.qe.aerospike.com/build/aerospike-server:x86-ubuntu-18.04
- docker.qe.aerospike.com/build/aerospike-server:x86-ubuntu-20.04

build:
- name: default
script:
- make all
- make $PKG
artifact:
- target/bin/*
- target/packages/*
71 changes: 58 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,72 @@ name: Build ACT
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]

jobs:
build:
buils_debian_x86_64:
runs-on: ubuntu-latest
strategy:
matrix:
os: ['ubuntu-latest']
runs-on: ${{ matrix.os }}
container: [ 'debian:10', 'debian:11' ]
container:
image: ${{ matrix.container }}
options: "--entrypoint /bin/bash"
steps:
- name: Install Dependencies (Debian)
run: |
apt-get -y update
apt-get -y install make gcc libc6-dev git build-essential
- name: Clone Source
run: git clone https://github.com/aerospike/act.git

- name: build act (debian)
working-directory: ./act
run: |
echo "REV=$(make -f pkg/Makefile.deb print-REV)" >> $GITHUB_ENV
echo "OS=$(make -f pkg/Makefile.deb print-OS)" >> $GITHUB_ENV
echo "ARCH=$(make -f pkg/Makefile.deb print-ARCH)" >> $GITHUB_ENV
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
make all deb
steps:
- name: Install Dependencies (Ubuntu)
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: act_${{ env.REV }}-1${{ env.OS }}_${{ env.ARCH }}.deb
path: /__w/act/act/act/target/packages/act_*
if-no-files-found: error

build_ubuntu_x86_64:
strategy:
matrix:
os: [ 'ubuntu-20.04', 'ubuntu-18.04' ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Dependencies
run: sudo apt-get install make gcc libc6-dev
if: matrix.os == 'ubuntu-latest'

- name: Get Sources
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set env
run: |
echo "REV=$(make -f pkg/Makefile.deb print-REV)" >> $GITHUB_ENV
echo "OS=$(make -f pkg/Makefile.deb print-OS)" >> $GITHUB_ENV
echo "ARCH=$(make -f pkg/Makefile.deb print-ARCH)" >> $GITHUB_ENV
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
- name: build
run: make
- name: Upload Artifact
uses: actions/[email protected]
run: make all deb

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: act-linux-$GITHUB_REF
path: target/bin/
name: act_${{ env.REV }}-1${{ env.OS }}_${{ env.ARCH }}.deb
path: target/packages
if-no-files-found: error
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ DIR_TARGET = target
DIR_OBJ = $(DIR_TARGET)/obj
DIR_BIN = $(DIR_TARGET)/bin

DIR_PKG = $(DIR_TARGET)/packages
DIR_RPM = pkg/rpm/RPMS
DIR_DEB = pkg/deb/DEBS

SRC_DIRS = common index prep storage
OBJ_DIRS = $(SRC_DIRS:%=$(DIR_OBJ)/src/%)

Expand Down Expand Up @@ -47,7 +51,7 @@ default: all
all: act_index act_prep act_storage

target_dir:
/bin/mkdir -p $(DIR_BIN) $(OBJ_DIRS)
/bin/mkdir -p $(DIR_BIN) $(OBJ_DIRS) $(DIR_PKG)

act_index: target_dir $(INDEX_OBJECTS)
echo "Linking $@"
Expand All @@ -61,12 +65,24 @@ act_storage: target_dir $(STORAGE_OBJECTS)
echo "Linking $@"
$(CC) $(LDFLAGS) -o $(STORAGE_BINARY) $(STORAGE_OBJECTS) $(LIBRARIES)

# For now we only clean everything.
clean:
/bin/rm -rf $(DIR_TARGET)

-include $(ALL_DEPENDENCIES)

$(DIR_OBJ)/%.o: %.c
echo "Building $@"
$(CC) $(CFLAGS) -o $@ -c $(INCLUDES) $<

.PHONY: rpm
rpm:
$(MAKE) -f pkg/Makefile.rpm

.PHONY: deb
deb:
$(MAKE) -f pkg/Makefile.deb

# For now we only clean everything.
.PHONY: clean
clean:
/bin/rm -rf $(DIR_TARGET)
/bin/rm -rf $(DIR_RPM)
/bin/rm -rf $(DIR_DEB)
/bin/rm -rf dist
139 changes: 139 additions & 0 deletions build/os_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# Copyright 2012-2015 Aerospike, Inc.
#
# Portions may be licensed to Aerospike, Inc. under one or more contributor
# license agreements.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# ------------------------------------------------------------------------------

OPT_LONG=0

if [ "$1" = "-long" ]
then
OPT_LONG=1
fi

error() {
echo 'error:' $* >&2
}

main() {

local kernel=''
local distro_id=''
local distro_version=''
local distro_long=''
local distro_short=''

# Make sure this script is running on Linux
# The script is not designed to work on non-Linux
# operating systems.
kernel=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ "$kernel" != 'linux' ]
then
error "$kernel is not supported."
exit 1
fi

if [ -f /etc/os-release ]
then
. /etc/os-release
distro_id=${ID,,}
distro_version=${VERSION_ID}
elif [ -f /etc/issue ]
then
issue=$(cat /etc/issue | tr '[:upper:]' '[:lower:]')
case "$issue" in
*'centos'* )
distro_id='centos'
;;
*'redhat'* | *'rhel'* )
distro_id='rhel'
;;
*'debian'* )
distro_id='debian'
;;
* )
error "/etc/issue contained an unsupported linux distibution: $issue"
exit 1
;;
esac

case "$distro_id" in
'centos' | 'rhel' )
local release=''
if [ -f /etc/centos-release ]; then
release=$(cat /etc/centos-release | tr '[:upper:]' '[:lower:]')
elif [ -f /etc/redhat-release ]; then
release=$(cat /etc/redhat-release | tr '[:upper:]' '[:lower:]')
fi
release_version=${release##*release}
distro_version=${release_version%.*}
;;
'debian' )
debian_version=$(cat /etc/debian_version | tr '[:upper:]' '[:lower:]')
distro_version=${debian_version%%.*}
;;
* )
error "/etc/issue contained an unsupported linux distibution: $issue"
exit 1
;;
esac
fi

distro_id=${distro_id//[[:space:]]/}
distro_version=${distro_version//[[:space:]]/}

case "$distro_id" in
'centos' )
distro_long="${distro_id}${distro_version%%.*}"
distro_short="el${distro_version%%.*}"
;;
'rhel' | 'redhat' | 'red hat' )
distro_long="${distro_id}${distro_version%%.*}"
distro_short="el${distro_version%%.*}"
;;
'fedora' )
if [ "$distro_version" -gt "15" ]
then
distro_version=7
elif [ "$distro_version" -gt "10" ]
then
distro_version=6
else
error "Unsupported linux distibution: $distro_id $distro_version"
exit 1
fi
distro_long="centos${distro_version}"
distro_short="el${distro_version}"
;;
'amzn' )
distro_long="ami"
distro_short="ami"
;;
* )
distro_long="${distro_id}${distro_version}"
distro_short="${distro_id}${distro_version}"
;;
esac

if [ "$OPT_LONG" = "1" ]
then
echo "${distro_long}"
else
echo "${distro_short}"
fi
exit 0
}

main
10 changes: 10 additions & 0 deletions build/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

rev=`git describe --always`
subbuild=`echo $rev | awk -F'-' '{print $2}'`
if [ "$subbuild" != "" ]
then
# rev=`echo $rev | awk -F'-' '{printf("%s-%s\n",$1,$2)}'`
rev=`echo $rev | awk -F'-' '{printf("%s\n",$1)}'`
fi
echo $rev
68 changes: 68 additions & 0 deletions pkg/Makefile.deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Build act distribution.

export DEB_SOURCE_ROOT = $(shell echo `pwd`/dist)
export DEB_BUILD_ROOT = $(DEB_SOURCE_ROOT)/BUILD
export CL_BASE = $(DEB_BUILD_ROOT)/opt/aerospike
export ETC_BASE = $(DEB_BUILD_ROOT)/etc/aerospike


#REV = $(shell git describe 2>/dev/null; if [ $${?} != 0 ]; then echo 'unknown'; fi)
DIR_PKG = target/packages
REV = $(shell build/version)
OS = $(shell build/os_version)
ARCH=$(shell uname -m)
MANIFEST_DIR = manifest/TEMP

ifeq ($(ARCH), x86_64)
ARCH=amd64
endif

ifeq ($(ARCH), aarch64)
ARCH=arm64
endif

.PHONY: default
default: dist

.PHONY: dist
dist:

# Build act package.
@echo $(REV)
@echo $(OS)
rm -rf $(DEB_BUILD_ROOT)/*
mkdir -p $(DEB_BUILD_ROOT)/DEBIAN
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
mkdir -p $(DIR_PKG)
install -m 755 pkg/deb/postinst $(DEB_BUILD_ROOT)/DEBIAN/postinst
install -m 755 pkg/deb/prerm $(DEB_BUILD_ROOT)/DEBIAN/prerm
install -m 644 pkg/deb/control $(DEB_BUILD_ROOT)/DEBIAN/control

mkdir -p $(CL_BASE)
mkdir -p $(ETC_BASE)
mkdir -p $(CL_BASE)/bin

# act
install -m 755 target/bin/act_* $(CL_BASE)/bin/
install -m 755 analysis/act_latency.py $(CL_BASE)/bin/
install -m 755 config/act_index.conf $(ETC_BASE)/
install -m 755 config/act_storage.conf $(ETC_BASE)/

# Create symlinks to /usr/bin
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
ln -sf /opt/aerospike/bin/act_index $(DEB_BUILD_ROOT)/usr/bin/act_index
ln -sf /opt/aerospike/bin/act_prep $(DEB_BUILD_ROOT)/usr/bin/act_prep
ln -sf /opt/aerospike/bin/act_storage $(DEB_BUILD_ROOT)/usr/bin/act_storage
ln -sf /opt/aerospike/bin/act_latency.py $(DEB_BUILD_ROOT)/usr/bin/act_latency.py


sed 's/@VERSION@/'$(REV)'/g' <pkg/deb/control >$(DEB_BUILD_ROOT)/DEBIAN/control
sed -i 's/@ARCH@/'$(ARCH)'/g' $(DEB_BUILD_ROOT)/DEBIAN/control
fakeroot dpkg-deb --build $(DEB_BUILD_ROOT) $(DIR_PKG)/act_$(REV)-1$(OS)_$(ARCH).deb
rm -rf dist

distclean:
rm -rf $(DEB_SOURCE_ROOT)
rm -rf target/packages

print-% : ; @echo $($*)
Loading

0 comments on commit bb9b87b

Please sign in to comment.