Skip to content

Commit

Permalink
Smoke testing build distro in CI. Merging common steps between CI and…
Browse files Browse the repository at this point in the history
… release actions.
  • Loading branch information
filipecosta90 committed Feb 10, 2025
1 parent ed30f3c commit 6a585d0
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 173 deletions.
37 changes: 6 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,12 @@ on: [push, pull_request]

jobs:
smoketest-build-distros:
runs-on: ubuntu-latest
continue-on-error: true
env:
ARCH: amd64
# required by ubuntu:bionic
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
DEBIAN_FRONTEND: noninteractive
strategy:
matrix:
image: ${{ fromJSON(vars.SMOKE_TEST_IMAGES) }}
container: ${{ matrix.image }}
name: Build ${{ matrix.image }}
steps:
- name: Checkout Code for ubuntu:bionic
if: matrix.image == 'ubuntu:bionic'
uses: actions/checkout@v3

- name: Checkout Code for other versions
if: matrix.image != 'ubuntu:bionic'
uses: actions/checkout@v4

- name: Install dependencies
run: |
apt-get -qq update -y
apt-get install -y \
build-essential autoconf automake libpcre3-dev libevent-dev \
pkg-config zlib1g-dev libssl-dev libboost-all-dev cmake flex
- name: Build
run: autoreconf -ivf && ./configure && make -j
uses: ./.github/workflows/common-build.yml
with:
build_dists: ${{ vars.BUILD_DISTS }}
build_archs: ${{ vars.BUILD_ARCHS }}
build_exclude: ${{ vars.BUILD_EXCLUDE }}
smoke_test_images: ${{ vars.SMOKE_TEST_IMAGES }}

build-notls:
runs-on: ubuntu-latest
Expand Down
195 changes: 195 additions & 0 deletions .github/workflows/common-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
name: Common Build Workflow

on:
workflow_call:
inputs:
tag_name:
description: "Release tag name for testing (e.g., 2.1.2)"
required: false
default: ""
type: string
build_archs:
description: "Build arch to build for"
required: false
default: '["i386", "amd64", "arm64", "armhf"]'
type: string
build_dists:
description: "Distributions to build for (comma-separated, e.g., focal,jammy, noble)"
required: false
default: '["noble", "jammy", "focal", "bionic", "bookworm", "bullseye", "buster"]'
type: string
smoke_test_images:
description: "Docker images for smoke testing (comma-separated, e.g., ubuntu:20.04,ubuntu:22.04,ubuntu:24.04)"
required: false
default: '["ubuntu:noble", "ubuntu:jammy", "debian:bookworm", "debian:bullseye"]'
type: string
build_exclude:
description: "Distributions to exclude build"
required: false
default: '[{"dist": "focal", "arch": "i386"}, {"dist": "jammy", "arch": "i386"}, {"dist": "noble", "arch": "i386"}]'
type: string
build_runner:
description: "os in which build steps run on"
required: false
default: "ubuntu-22.04"
type: string

jobs:
build-source-package:
runs-on: ${{ inputs.build_runner }}
continue-on-error: true
strategy:
matrix:
dist: ${{ fromJSON(inputs.build_dists) }}
steps:
- uses: actions/checkout@v4
with:
path: sources
- name: Validate configure.ac version matches GitHub Release (only on release)
if: github.event.release.tag_name != ''
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
# Extract the current version from configure.ac
CURRENT_VERSION=$(awk -F'[(),]' '/AC_INIT/ {print $3}' sources/configure.ac | tr -d ' ')
echo "Current configure.ac version: $CURRENT_VERSION"
echo "GitHub Release version: $VERSION"
# Check if versions match
if [ "$CURRENT_VERSION" != "$VERSION" ]; then
echo "❌ Version mismatch! configure.ac: $CURRENT_VERSION, GitHub Release: $VERSION"
exit 1 # Fail the build
else
echo "Version match. Proceeding with the build."
fi
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install \
build-essential autoconf automake libpcre3-dev libevent-dev \
pkg-config zlib1g-dev libssl-dev libboost-all-dev cmake flex \
debhelper dput
- name: Create changelog
env:
VERSION: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}
DIST: ${{ matrix.dist }}
run: |
# for testing purposes if the version is empty (CI) we use 0.0.1
if [ -z "$VERSION" ]; then
VERSION="0.0.1~test"
fi
mkdir -p sources/debian
if [ "${{ github.event_name }}" = "release" ]; then
RELEASE_URL=": ${{ github.event.release.html_url }}"
else
RELEASE_URL=""
fi
(echo "memtier-benchmark ($VERSION~$DIST) $DIST; urgency=medium"
echo ""
echo " * Release $VERSION$RELEASE_URL"
echo ""
echo " -- Redis Team <[email protected]> $(date -R)") > sources/debian/changelog
- name: Build source package
run: |
cd sources && dpkg-buildpackage -S
- name: Upload source package artifact
uses: actions/upload-artifact@v4
with:
name: source-${{ matrix.dist }}
path: |
*.debian.tar.*
*.dsc
memtier-benchmark_*.tar.*
build-binary-package:
runs-on: ${{ inputs.build_runner }}
environment: build
continue-on-error: true
strategy:
matrix:
dist: ${{ fromJSON(inputs.build_dists) }}
arch: ${{ fromJSON(inputs.build_archs) }}
exclude: ${{ fromJSON(inputs.build_exclude) }}
needs: build-source-package
steps:
- uses: actions/checkout@v4
- name: Determine build architecture
run: |
if [ ${{ matrix.arch }} = "i386" ]; then
BUILD_ARCH=i386
else
BUILD_ARCH=amd64
fi
echo "BUILD_ARCH=${BUILD_ARCH}" >> $GITHUB_ENV
# Only setup APT signing key for releases, not for CI testing
- name: Setup APT Signing key
if: github.event_name == 'release'
run: |
mkdir -m 0700 -p ~/.gnupg
echo "$APT_SIGNING_KEY" | gpg --import
env:
APT_SIGNING_KEY: ${{ secrets.APT_SIGNING_KEY }}

- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -y \
sbuild schroot debootstrap
sudo sbuild-adduser $USER
- name: Prepare sbuild environment
run: sudo ./debian/setup_sbuild.sh ${{ matrix.dist }} ${{ env.BUILD_ARCH }}
- name: Get source package
uses: actions/download-artifact@v4
with:
name: source-${{ matrix.dist }}
- name: Build binary package
run: |
sudo sbuild \
--nolog \
--host ${{ matrix.arch }} \
--build ${{ env.BUILD_ARCH }} \
--dist ${{ matrix.dist }} *.dsc
- name: Upload binary package artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.dist }}-${{ matrix.arch }}
path: |
*.deb
- name: Upload as release assets
# we don't upload on workflow dispatch and on forks
if: github.event_name == 'release' && github.repository == 'redislabs/memtier_benchmark'
uses: softprops/action-gh-release@v1
with:
files: |
*.deb
smoke-test-packages:
runs-on: ${{ inputs.build_runner }}
needs: build-binary-package
env:
ARCH: amd64
strategy:
matrix:
image: ${{ fromJSON(inputs.smoke_test_images) }}
container: ${{ matrix.image }}
steps:
- name: Extract BUILD_ARCH from matrix.image
run: |
BUILD_ARCH=$(echo ${{ matrix.image }} | cut -d: -f2)
if [ -z "$BUILD_ARCH" ]; then
echo "Error: Failed to extract BUILD_ARCH from matrix.image" >&2
exit 1
fi
echo "BUILD_ARCH=$BUILD_ARCH" >> $GITHUB_ENV
- name: Get binary packages for other versions
if: matrix.image != 'ubuntu:bionic'
uses: actions/download-artifact@v4
with:
name: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}
path: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}
- name: Install packages
run: |
apt-get update
cd binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }} && apt install --yes ./*.deb
147 changes: 7 additions & 140 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,146 +18,13 @@ on:
required: false
default: "ubuntu:20.04,ubuntu:22.04,ubuntu:24.04"
jobs:
build-source-package:
runs-on: ubuntu-latest
strategy:
matrix:
dist: ${{ fromJSON(vars.BUILD_DISTS) }}
steps:
- uses: actions/checkout@v4
with:
path: sources
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install \
build-essential autoconf automake libpcre3-dev libevent-dev \
pkg-config zlib1g-dev libssl-dev libboost-all-dev cmake flex \
debhelper dput
- name: Create changelog
env:
VERSION: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}
DIST: ${{ matrix.dist }}
run: |
mkdir -p sources/debian
if [ "${{ github.event_name }}" = "release" ]; then
RELEASE_URL=": ${{ github.event.release.html_url }}"
else
RELEASE_URL=""
fi
(echo "memtier-benchmark ($VERSION~$DIST) $DIST; urgency=medium"
echo ""
echo " * Release $VERSION$RELEASE_URL"
echo ""
echo " -- Redis Team <[email protected]> $(date -R)") > sources/debian/changelog
- name: Build source package
run: |
cd sources && dpkg-buildpackage -S
- name: Upload source package artifact
uses: actions/upload-artifact@v4
with:
name: source-${{ matrix.dist }}
path: |
*.debian.tar.*
*.dsc
memtier-benchmark_*.tar.*
build-binary-package:
runs-on: ubuntu-latest
environment: build
strategy:
matrix:
dist: ${{ fromJSON(vars.BUILD_DISTS) }}
arch: ${{ fromJSON(vars.BUILD_ARCHS) }}
exclude: ${{ fromJSON(vars.BUILD_EXCLUDE) }}
needs: build-source-package
steps:
- uses: actions/checkout@v4
- name: Determine build architecture
run: |
if [ ${{ matrix.arch }} = "i386" ]; then
BUILD_ARCH=i386
else
BUILD_ARCH=amd64
fi
echo "BUILD_ARCH=${BUILD_ARCH}" >> $GITHUB_ENV
- name: Setup APT Signing key
run: |
mkdir -m 0700 -p ~/.gnupg
echo "$APT_SIGNING_KEY" | gpg --import
env:
APT_SIGNING_KEY: ${{ secrets.APT_SIGNING_KEY }}
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install \
sbuild debhelper
sudo sbuild-adduser $USER
- name: Prepare sbuild environment
run: sudo ./debian/setup_sbuild.sh ${{ matrix.dist }} ${{ env.BUILD_ARCH }}
- name: Get source package
uses: actions/download-artifact@v4
with:
name: source-${{ matrix.dist }}
- name: Build binary package
run: |
sudo sbuild \
--nolog \
--host ${{ matrix.arch }} \
--build ${{ env.BUILD_ARCH }} \
--dist ${{ matrix.dist }} *.dsc
- name: Upload binary package artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.dist }}-${{ matrix.arch }}
path: |
*.deb
- name: Upload as release assets
# we don't upload on workflow dispatch
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
*.deb
smoke-test-packages:
runs-on: ubuntu-latest
needs: build-binary-package
env:
ARCH: amd64
# required by ubuntu:bionic
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
strategy:
matrix:
image: ${{ fromJSON(vars.SMOKE_TEST_IMAGES) }}
container: ${{ matrix.image }}
steps:
- name: Extract BUILD_ARCH from matrix.image
run: |
BUILD_ARCH=$(echo ${{ matrix.image }} | cut -d: -f2)
if [ -z "$BUILD_ARCH" ]; then
echo "Error: Failed to extract BUILD_ARCH from matrix.image" >&2
exit 1
fi
echo "BUILD_ARCH=$BUILD_ARCH" >> $GITHUB_ENV
- name: Get binary packages for ubuntu:bionic
if: matrix.image == 'ubuntu:bionic'
uses: actions/download-artifact@v3
with:
name: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}
path: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}

- name: Get binary packages for other versions
if: matrix.image != 'ubuntu:bionic'
uses: actions/download-artifact@v4
with:
name: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}
path: binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }}
- name: Install packages
run: |
apt-get update
cd binary-${{ env.BUILD_ARCH }}-${{ env.ARCH }} && apt install --yes ./*.deb
common-build:
uses: ./.github/workflows/common-build.yml
with:
build_dists: ${{ fromJSON(vars.BUILD_DISTS) }}
build_archs: ${{ fromJSON(vars.BUILD_ARCHS) }}
build_exclude: ${{ fromJSON(vars.BUILD_EXCLUDE) }}
smoke_test_images: ${{ fromJSON(vars.SMOKE_TEST_IMAGES) }}

publish-to-apt:
env:
Expand Down
Loading

0 comments on commit 6a585d0

Please sign in to comment.