Skip to content

Commit

Permalink
OPSEXP-2333 Refactor imagemagick package tests (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
slohe1 authored Oct 13, 2023
1 parent d7d8325 commit 79fc007
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 43 deletions.
180 changes: 156 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@ on:
- README.md

jobs:
build_rpm:
configure:
runs-on: ubuntu-latest
outputs:
matrix_rpms: ${{ steps.set-matrix.outputs.matrix_rpms }}
matrix_test: ${{ steps.set-matrix.outputs.matrix_test }}
matrix_debs: ${{ steps.set-matrix.outputs.matrix_debs }}
steps:
- name: Checkout to repository
uses: actions/checkout@v4
- name: Set matrix data
id: set-matrix
run: |
echo "matrix_rpms=$(jq -c . < ./rpms/config.json)" >> $GITHUB_OUTPUT
echo "matrix_debs=$(jq -c . < ./debs/config.json)" >> $GITHUB_OUTPUT
echo "matrix_test=$(jq -c 'del(.include[] | select(.target_arch == "aarch64"))' < rpms/config.json)" >> $GITHUB_OUTPUT
build_rpms:
name: Build on ${{ matrix.base_image }} for ${{ matrix.target_arch }}
runs-on: ubuntu-latest
needs:
- configure
strategy:
matrix:
include:
- base_image: rockylinux:9
target_arch: x86_64
nexus_classifier: el9
- base_image: rockylinux:8
target_arch: x86_64
nexus_classifier: el8
- base_image: rockylinux:8
target_arch: aarch64
nexus_classifier: el8-aarch64
- base_image: centos:7
target_arch: x86_64
nexus_classifier: el7
matrix: ${{ fromJson(needs.configure.outputs.matrix_rpms) }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -52,6 +57,70 @@ jobs:
with:
name: ${{ matrix.nexus_classifier }}-rpm
path: RPMS/${{ matrix.target_arch }}/*.rpm

test_rpms:
name: Test on ${{ matrix.base_image }} for ${{ matrix.target_arch }}
runs-on: ubuntu-latest
needs:
- configure
- build_rpms
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix_test) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set build variables
id: variables
run: |
echo "imagemagick_version=$(cat ./imagemagick-version)" >> $GITHUB_OUTPUT
echo "imagemagick_release=$(cat ./release-version)" >> $GITHUB_OUTPUT
- name: Download RPMs
uses: actions/download-artifact@v3
with:
name: ${{ matrix.nexus_classifier }}-rpm
path: rpms/tests/

- name: List RPMs
run: ls -R rpms/tests/*.rpm

- name: Prepare image
run: docker build . -t testenv --build-arg BASE_IMAGE=${{ matrix.base_image }}
working-directory: rpms/tests/

- name: Install & Test Packages
run: docker run --name buildtest testenv ${{ steps.variables.outputs.imagemagick_version }} ${{ matrix.target_arch }}

deploy_rpms:
name: Deploy ${{ matrix.base_image }} for ${{ matrix.target_arch }}
runs-on: ubuntu-latest
needs:
- configure
- build_rpms
- test_rpms
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix_test) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set build variables
id: variables
run: |
echo "imagemagick_version=$(cat ./imagemagick-version)" >> $GITHUB_OUTPUT
echo "imagemagick_release=$(cat ./release-version)" >> $GITHUB_OUTPUT
- name: Download RPMs
uses: actions/download-artifact@v3
with:
name: ${{ matrix.nexus_classifier }}-rpm

- name: List RPMs
run: ls -R *.rpm

- name: Deploy to nexus
uses: Alfresco/alfresco-build-tools/.github/actions/maven-deploy-file@9fd78f71c1ccbad03b79b81db541693cd9cfc89b
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -61,9 +130,9 @@ jobs:
repository-url: https://nexus.alfresco.com/nexus/content/repositories/thirdparty/
version: ${{ steps.variables.outputs.imagemagick_version }}-ci-${{ steps.variables.outputs.imagemagick_release }}
generate-pom: false
file: RPMS/${{ matrix.target_arch }}/ImageMagick-${{ steps.variables.outputs.imagemagick_version }}.${{ matrix.target_arch }}.rpm
file: ImageMagick-${{ steps.variables.outputs.imagemagick_version }}.${{ matrix.target_arch }}.rpm
classifier: ${{ matrix.nexus_classifier }}
files: RPMS/${{ matrix.target_arch }}/ImageMagick-libs-${{ steps.variables.outputs.imagemagick_version }}.${{ matrix.target_arch }}.rpm
files: ImageMagick-libs-${{ steps.variables.outputs.imagemagick_version }}.${{ matrix.target_arch }}.rpm
classifiers: ${{ matrix.nexus_classifier }}-libs
types: rpm
maven-username: ${{ secrets.NEXUS_USERNAME }}
Expand All @@ -72,12 +141,11 @@ jobs:
build_ubuntu:
name: Build on ubuntu:${{ matrix.image_tag }} for x86_64
runs-on: ubuntu-latest
needs:
- configure
strategy:
matrix:
image_tag:
- 22.04
- 20.04
- 18.04
matrix: ${{ fromJson(needs.configure.outputs.matrix_debs) }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -106,6 +174,70 @@ jobs:
with:
name: ubuntu${{ matrix.image_tag }}-deb
path: "*.deb"

test_ubuntu:
name: Test on ubuntu:${{ matrix.image_tag }} for x86_64
runs-on: ubuntu-latest
needs:
- configure
- build_ubuntu
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix_debs) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set build variables
id: variables
run: |
echo "imagemagick_version=$(cat ./imagemagick-version)" >> $GITHUB_OUTPUT
echo "imagemagick_release=$(cat ./release-version)" >> $GITHUB_OUTPUT
- name: Download DEBs
uses: actions/download-artifact@v3
with:
name: ubuntu${{ matrix.image_tag }}-deb
path: debs/tests/

- name: List Debs
run: ls -R debs/tests/*.deb

- name: Prepare test image
run: docker build . -t testenv --build-arg IMAGE_TAG=${{ matrix.image_tag }}
working-directory: debs/tests/

- name: Install & Test Packages
run: docker run --name buildtest testenv ${{ steps.variables.outputs.imagemagick_version }}

deploy_ubuntu:
name: Deploy on ubuntu:${{ matrix.image_tag }} for x86_64
runs-on: ubuntu-latest
needs:
- configure
- build_ubuntu
- test_ubuntu
strategy:
matrix: ${{ fromJson(needs.configure.outputs.matrix_debs) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set build variables
id: variables
run: |
echo "imagemagick_version=$(cat ./imagemagick-version)" >> $GITHUB_OUTPUT
echo "imagemagick_release=$(cat ./release-version)" >> $GITHUB_OUTPUT
- name: Download DEBs
uses: actions/download-artifact@v3
with:
name: ubuntu${{ matrix.image_tag }}-deb

- name: List Debs
run: ls -R *.deb

- name: Deploy to nexus
uses: Alfresco/alfresco-build-tools/.github/actions/maven-deploy-file@9fd78f71c1ccbad03b79b81db541693cd9cfc89b
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -115,9 +247,9 @@ jobs:
repository-url: https://nexus.alfresco.com/nexus/content/repositories/thirdparty/
version: ${{ steps.variables.outputs.imagemagick_version }}-ci-${{ steps.variables.outputs.imagemagick_release }}
generate-pom: false
file: ${{ github.workspace }}/imagemagick-alfresco_${{ steps.variables.outputs.imagemagick_version }}_amd64.deb
file: imagemagick-alfresco_${{ steps.variables.outputs.imagemagick_version }}_amd64.deb
classifier: ubuntu-${{ matrix.image_tag }}
files: ${{ github.workspace }}/imagemagick-alfresco-dev_${{ steps.variables.outputs.imagemagick_version }}_amd64.deb
files: imagemagick-alfresco-dev_${{ steps.variables.outputs.imagemagick_version }}_amd64.deb
classifiers: ubuntu-${{ matrix.image_tag }}-dev
types: deb
maven-username: ${{ secrets.NEXUS_USERNAME }}
Expand Down
13 changes: 13 additions & 0 deletions debs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"include": [
{
"image_tag": "22.04"
},
{
"image_tag": "20.04"
},
{
"image_tag": "18.04"
}
]
}
18 changes: 0 additions & 18 deletions debs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,4 @@ dpkg-buildpackage -b -uc
echo "Imagemagick $IMAGEMAGICK_VERSION built successfully."
ls -l ../*.deb

echo "Testing package expected dependencies"
dpkg-deb -f ../imagemagick-alfresco_${IMAGEMAGICK_VERSION}_amd64.deb Depends | grep -qEv 'libcdt|libcgraph|libgvc|libgs9'

echo "Installing package"
dpkg -i ../imagemagick-alfresco_${IMAGEMAGICK_VERSION}_amd64.deb

echo "Exporting the path of the package"
export PATH="/opt/imagemagick-7/bin:$PATH"

echo "Testing convert command"
convert -version

echo "Creating test image file"
convert -size 32x32 xc:transparent test.png

echo "Converting png to jpg"
convert test.png test1.jpg

exit 0
13 changes: 13 additions & 0 deletions debs/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG IMAGE_TAG
FROM ubuntu:$IMAGE_TAG

ARG IMAGE_TAG
ENV IMAGE_TAG=$IMAGE_TAG

RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/99yes
RUN apt-get update

ADD *.deb /

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
35 changes: 35 additions & 0 deletions debs/tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e -o pipefail -x

if [ -z "$IMAGE_TAG" ]; then
echo "IMAGE_TAG env needs to be set"
exit 1
fi

if [ -z "$1" ]; then
echo "first argument needs to be set - IMAGEMAGICK_VERSION"
exit 1
fi

IMAGEMAGICK_VERSION=$1

echo "Installing package"
dpkg -i --force-depends imagemagick-alfresco_${IMAGEMAGICK_VERSION}_amd64.deb
apt-get -f install

echo "Exporting the path of the package"
export PATH="/opt/imagemagick-7/bin:$PATH"

echo "ldd output of convert command"
ldd /opt/imagemagick-7/bin/convert

echo "Testing convert command"
convert -version

echo "Creating test image file"
convert -size 32x32 xc:transparent test.png

echo "Converting png to jpg"
convert test.png test1.jpg

exit 0
2 changes: 1 addition & 1 deletion release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
Empty file modified rpms/after-checkout-rockylinux9-7.1.0-16.sh
100644 → 100755
Empty file.
24 changes: 24 additions & 0 deletions rpms/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"include": [
{
"base_image": "rockylinux:9",
"target_arch": "x86_64",
"nexus_classifier": "el9"
},
{
"base_image": "rockylinux:8",
"target_arch": "x86_64",
"nexus_classifier": "el8"
},
{
"base_image": "rockylinux:8",
"target_arch": "aarch64",
"nexus_classifier": "el8-aarch64"
},
{
"base_image": "centos:7",
"target_arch": "x86_64",
"nexus_classifier": "el7"
}
]
}
13 changes: 13 additions & 0 deletions rpms/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG BASE_IMAGE

FROM ${BASE_IMAGE}

RUN yum install -y epel-release

ADD *.rpm /

ARG BASE_IMAGE
ENV BASE_IMAGE=${BASE_IMAGE}

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
38 changes: 38 additions & 0 deletions rpms/tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e -o pipefail -x

if [ -z "$BASE_IMAGE" ]; then
echo "BASE_IMAGE env needs to be set"
exit 1
fi

if [ -z "$1" ]; then
echo "first argument needs to be set - IMAGEMAGICK_VERSION"
exit 1
fi

if [ -z "$2" ]; then
echo "second argument needs to be set - TARGET_ARCH"
exit 1
fi

IMAGEMAGICK_VERSION=$1
TARGET_ARCH=$2

echo "Test install imagemagick packages"
yum install -y ImageMagick-libs-$IMAGEMAGICK_VERSION.$TARGET_ARCH.rpm
yum install -y ImageMagick-$IMAGEMAGICK_VERSION.$TARGET_ARCH.rpm

echo "ldd output of convert command"
ldd /usr/bin/convert

echo "Testing convert command"
convert -version

echo "Creating test image file"
convert -size 32x32 xc:transparent test.png

echo "Converting png to jpg"
convert test.png test1.jpg

exit 0

0 comments on commit 79fc007

Please sign in to comment.