diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23861bb..d9e8e6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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') @@ -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 }} @@ -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 @@ -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') @@ -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 }} diff --git a/debs/config.json b/debs/config.json new file mode 100755 index 0000000..f07cc5b --- /dev/null +++ b/debs/config.json @@ -0,0 +1,13 @@ +{ + "include": [ + { + "image_tag": "22.04" + }, + { + "image_tag": "20.04" + }, + { + "image_tag": "18.04" + } + ] +} diff --git a/debs/entrypoint.sh b/debs/entrypoint.sh index 5e0a193..ab82011 100755 --- a/debs/entrypoint.sh +++ b/debs/entrypoint.sh @@ -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 diff --git a/debs/tests/Dockerfile b/debs/tests/Dockerfile new file mode 100644 index 0000000..ddede7c --- /dev/null +++ b/debs/tests/Dockerfile @@ -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"] diff --git a/debs/tests/entrypoint.sh b/debs/tests/entrypoint.sh new file mode 100755 index 0000000..75674ac --- /dev/null +++ b/debs/tests/entrypoint.sh @@ -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 diff --git a/release-version b/release-version index 7813681..62f9457 100644 --- a/release-version +++ b/release-version @@ -1 +1 @@ -5 \ No newline at end of file +6 \ No newline at end of file diff --git a/rpms/after-checkout-rockylinux9-7.1.0-16.sh b/rpms/after-checkout-rockylinux9-7.1.0-16.sh old mode 100644 new mode 100755 diff --git a/rpms/config.json b/rpms/config.json new file mode 100755 index 0000000..f464049 --- /dev/null +++ b/rpms/config.json @@ -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" + } + ] +} diff --git a/rpms/tests/Dockerfile b/rpms/tests/Dockerfile new file mode 100644 index 0000000..5e44a08 --- /dev/null +++ b/rpms/tests/Dockerfile @@ -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"] diff --git a/rpms/tests/entrypoint.sh b/rpms/tests/entrypoint.sh new file mode 100755 index 0000000..084abbc --- /dev/null +++ b/rpms/tests/entrypoint.sh @@ -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