-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
244 changed files
with
345 additions
and
45,005 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ updates: | |
day: "saturday" | ||
commit-message: | ||
prefix: "gh" | ||
target-branch: main | ||
target-branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,18 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.pull_request.head.ref || github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
fail_if_pull_request_is_draft: | ||
if: github.event.pull_request.draft == true | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass. | ||
run: exit 1 | ||
build: | ||
timeout-minutes: 15 | ||
if: ${{ (github.event_name == 'push' || !github.event.pull_request.draft) }} | ||
runs-on: ubuntu-22.04 | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
heroku_stack_version: [24] | ||
steps: | ||
- name: 🏠 Checkout source code from repository | ||
uses: actions/checkout@master | ||
- name: 🗂️ Cache Docker | ||
uses: satackey/action-docker-layer-caching@master | ||
continue-on-error: true | ||
- name: 🧪 Testing | ||
run: | | ||
docker build heroku/heroku:22-build --tag local-heroku22:$(date +%s) | ||
docker run --rm local-heroku22:$(date +%s) convert -list configure | ||
# docker run --rm heroku-imagemagick -list configure | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.jpg /container-test-images/test-resize.jpg | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.jpg webp:/container-test-images/test-jpg.webp | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.jpg avif:/container-test-images/test-jpg.avif | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.png /container-test-images/test-resize.png | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.png webp:/container-test-images/test-png.webp | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.png avif:/container-test-images/test-png.avif | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.png jxl:/container-test-images/test-png.jxl | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.tiff /container-test-images/test-resize.tiff | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.tiff webp:/container-test-images/test-tiff.webp | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.tiff avif:/container-test-images/test-tiff.avif | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -resize 100 /container-test-images/test.tiff jxl:/container-test-images/test-tiff.jxl | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick /container-test-images/test.pdf /container-test-images/test-pdf.png | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick /container-test-images/jpg-with-metadata.jpg /container-test-images/jpg-with-metadata.webp | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick -coalesce /container-test-images/test.gif /container-test-images/test-gif.webp | ||
# docker run --rm -v $(pwd)/local-test-images:/container-test-images heroku-imagemagick /container-test-images/test.jpg -antialias -font DejaVu-Sans -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /container-test-images/test-text.jpg | ||
# docker run --rm heroku-imagemagick -list configure | grep DELEGATES | grep "fontconfig freetype heic jbig jng jpeg jxl lcms lzma png ps tiff webp x xml zlib" | ||
# - name: 🌅 Upload Test Results | ||
# uses: actions/upload-artifact@master | ||
# with: | ||
# name: ubuntu-tests | ||
# path: local-test-images | ||
uses: actions/checkout@v4 | ||
with: | ||
path: app | ||
- name: Buildpack CI | ||
uses: buildpack-ci/run-tests@v1 | ||
env: | ||
APP_SUBDIR: app | ||
STACK: heroku-24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
test-buildpack: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
heroku_stack_version: [22, 24] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build Docker image for stack version ${{ matrix.heroku_stack_version }} | ||
run: | | ||
docker build \ | ||
--build-arg STACK_VERSION=${{ matrix.heroku_stack_version }} \ | ||
--tag heroku-imagemagick-stack-${{ matrix.heroku_stack_version }} \ | ||
--progress=plain \ | ||
--pull \ | ||
--file container/Dockerfile \ | ||
container | ||
- name: Run tests for stack version ${{ matrix.heroku_stack_version }} | ||
run: | | ||
mkdir -p build | ||
docker run --rm -t \ | ||
-v $PWD/build:/build \ | ||
heroku-imagemagick-stack-${{ matrix.heroku_stack_version }} \ | ||
sh -c 'cp -f /usr/local/build/imagemagick-heroku-*.tar.bz2 /build/ && cp -f /usr/local/build/*.config.log /build/configurations' | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Install dependencies | ||
run: pip install pytest | ||
|
||
- name: Run tests on fixture images | ||
run: | | ||
tar -xjf build/imagemagick-heroku-${{ matrix.heroku_stack_version }}.tar.bz2 -C /tmp/imagemagick | ||
pytest test_fixtures.py --stack-version ${{ matrix.heroku_stack_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
.DS_Store | ||
### Linux ### | ||
*~ | ||
|
||
### macOS ### | ||
.DS_Store | ||
|
||
# Build artifacts | ||
/build | ||
!/build/configurations/heroku-*.config.log | ||
!/build/heroku-*.tar.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export PATH="$PATH:$HOME/vendor/imagemagick/bin" | ||
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/vendor/imagemagick/lib/pkgconfig" | ||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/vendor/imagemagick/lib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,95 @@ | ||
#!/usr/bin/env bash | ||
# bin/compile <build-dir> <cache-dir> | ||
|
||
set -e | ||
# bin/compile <build-dir> <cache-dir> <env-dir> | ||
|
||
# fail hard | ||
set -o pipefail | ||
|
||
# fail harder | ||
set -eu | ||
|
||
# move hidden files too, just in case | ||
shopt -s dotglob | ||
|
||
BUILD_DIR=$1 | ||
CACHE_DIR=$2 | ||
ENV_DIR=$3 | ||
|
||
BUILDPACK_NAME=imagemagick | ||
BINARY_NAME=imagemagick-heroku-${STACK}.tar.gz | ||
|
||
BIN_DIR=$(cd "$(dirname "$0")"; pwd) | ||
ROOT_DIR=$(dirname "$BIN_DIR") | ||
|
||
function indent() { | ||
c='s/^/ /' | ||
case $(uname) in | ||
Darwin) sed -l "$c";; | ||
*) sed -u "$c";; | ||
esac | ||
} | ||
|
||
arrow() { | ||
sed -u 's/^/-----> /' | ||
} | ||
|
||
ADD_PATH="" | ||
|
||
function vendor() { | ||
local binary="$1" | ||
local path="$2" | ||
|
||
if [ ! -f "$binary" ]; then | ||
echo "Binary file '${binary}' not found for stack ${STACK}" | indent | ||
exit 1 | ||
fi | ||
|
||
echo "Fetching $binary" | indent | ||
mkdir -p $path | ||
tar -xj -f $binary -C $path | ||
|
||
if [ -d "$path/bin" ]; then | ||
export PATH="$path/bin:$PATH" | ||
ADD_PATH="$path/bin" | ||
else | ||
ADD_PATH="" | ||
fi | ||
|
||
if [ -d "$path/lib/pkgconfig" ]; then | ||
export PKG_CONFIG_PATH="$path/lib/pkgconfig:$PKG_CONFIG_PATH" | ||
ADD_PKG_CONFIG_PATH="$path/lib/pkgconfig" | ||
else | ||
ADD_PKG_CONFIG_PATH="" | ||
fi | ||
|
||
export CPPPATH="$path/include:$CPPPATH" | ||
export CPATH="$path/include:$CPATH" | ||
export LIBRARY_PATH="$path/lib:$LIBRARY_PATH" | ||
export LD_LIBRARY_PATH="$path/lib:$LD_LIBRARY_PATH" | ||
ADD_CPPPATH="$path/include" | ||
ADD_CPATH="$path/include" | ||
ADD_LIBRARY_PATH="$path/lib" | ||
ADD_LD_LIBRARY_PATH="$path/lib" | ||
} | ||
|
||
vendor "$ROOT_DIR/build/imagemagick.tar.bz2" "$BUILD_DIR/vendor/imagemagick" | ||
echo "Vendoring binaries" | arrow | ||
vendor "$ROOT_DIR/build/$BINARY_NAME" "$BUILD_DIR/vendor/imagemagick" | ||
|
||
echo "Configuring build environment" | arrow | ||
cat <<EOF > export | ||
export MAGICK_HOME="$BUILD_DIR/vendor/imagemagick" | ||
export MAGICK_CONFIGURE_PATH="/app/.magick" | ||
export PATH="/app/bin:$PATH:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$LD_LIBRARY_PATH" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:$LIBRARY_PATH" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:$PKG_CONFIG_PATH" | ||
export CPPPATH="\$CPPPATH:$CPPPATH" | ||
export CPATH="\$CPATH:$CPATH" | ||
export PATH="/app/bin:$ADD_PATH:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$ADD_LD_LIBRARY_PATH" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:$ADD_LIBRARY_PATH" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:$ADD_PKG_CONFIG_PATH" | ||
export CPPPATH="\$CPPPATH:$ADD_CPPPATH" | ||
export CPATH="\$CPATH:$ADD_CPATH" | ||
EOF | ||
|
||
echo "Building runtime environment" | arrow | ||
mkdir -p $BUILD_DIR/.profile.d | ||
cat <<EOF > $BUILD_DIR/.profile.d/imagemagick.sh | ||
|
||
cat <<EOF > $BUILD_DIR/.profile.d/$BUILDPACK_NAME.sh | ||
export MAGICK_HOME="$BUILD_DIR/vendor/imagemagick" | ||
export MAGICK_CONFIGURE_PATH="/app/.magick" | ||
export PATH="/app/bin:${PATH//$BUILD_DIR//app}:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${LD_LIBRARY_PATH//$BUILD_DIR//app}" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:${LIBRARY_PATH//$BUILD_DIR//app}" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:${PKG_CONFIG_PATH//$BUILD_DIR//app}" | ||
export CPPPATH="\$CPPPATH:${CPPPATH//$BUILD_DIR//app}" | ||
export CPATH="\$CPATH:${CPATH//$BUILD_DIR//app}" | ||
export PATH="/app/bin:${ADD_PATH//$BUILD_DIR//app}:\$PATH" | ||
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${ADD_LD_LIBRARY_PATH//$BUILD_DIR//app}" | ||
export LIBRARY_PATH="\$LIBRARY_PATH:${ADD_LIBRARY_PATH//$BUILD_DIR//app}" | ||
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:${ADD_PKG_CONFIG_PATH//$BUILD_DIR//app}" | ||
export CPPPATH="\$CPPPATH:${ADD_CPPPATH//$BUILD_DIR//app}" | ||
export CPATH="\$CPATH:${ADD_CPATH//$BUILD_DIR//app}" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
#!/usr/bin/env bash | ||
echo "ImageMagick" && exit 0 | ||
|
||
SUPPORTED_STACKS=(heroku-22 heroku-24) | ||
|
||
for stack_option in "${SUPPORTED_STACKS[@]}"; do | ||
if [[ $STACK = $stack_option ]]; then | ||
echo "imagemagick ($stack_option stack)" | ||
exit 0 | ||
fi | ||
done | ||
|
||
echo "imagemagick buildpack doesn't support the $STACK stack" && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
# bin/test <build-dir> <env-dir> | ||
# env vars are passed in already, so we can ignore the dir | ||
|
||
# fail hard | ||
set -o pipefail | ||
|
||
# fail harder | ||
set -eu | ||
|
||
# Setup Path variables, for later use in the Buildpack. | ||
BIN_DIR=$(cd "$(dirname "$0")"; pwd) | ||
export PATH=/app/.heroku/vendor/bin:$PATH | ||
|
||
# unlike a regular app.json "test" script, this one isn't run with the app dir as the CWD | ||
# we `cd` with a default value, so that the script can also be called from inside the app dir (`cd ""` does not change cwd) | ||
cd "${1-}" | ||
|
||
echo "Trying to run imagemagick with differents images from fixtures folder." >&2 | ||
|
||
echo $PATH | indent | ||
magick -list configure | indent | ||
magick -resize 100 /fixtures/test.avif /fixtures/test-resize.avif | indent | ||
magick -resize 100 /fixtures/test.heic /fixtures/test-resize.heic | indent | ||
magick -resize 100 /fixtures/test.jpg /fixtures/test-resize.jpg | indent | ||
magick -resize 100 /fixtures/test.jpg webp:/fixtures/test-jpg.webp | indent | ||
magick -resize 100 /fixtures/test.jpg avif:/fixtures/test-jpg.avif | indent | ||
magick -resize 100 /fixtures/test.png /fixtures/test-resize.png | indent | ||
magick -resize 100 /fixtures/test.png webp:/fixtures/test-png.webp | indent | ||
magick -resize 100 /fixtures/test.png avif:/fixtures/test-png.avif | indent | ||
magick -resize 100 /fixtures/test.png jxl:/fixtures/test-png.jxl | indent | ||
magick -resize 100 /fixtures/test.tiff /fixtures/test-resize.tiff | indent | ||
magick -resize 100 /fixtures/test.tiff webp:/fixtures/test-tiff.webp | indent | ||
magick -resize 100 /fixtures/test.tiff avif:/fixtures/test-tiff.avif | indent | ||
magick -resize 100 /fixtures/test.tiff jxl:/fixtures/test-tiff.jxl | indent | ||
magick /fixtures/test.pdf /fixtures/test-pdf.png | indent | ||
magick /fixtures/jpg-with-metadata.jpg /fixtures/jpg-with-metadata.webp | indent | ||
magick -coalesce /fixtures/test.gif /fixtures/test-gif.webp | indent | ||
magick /fixtures/test.jpg -antialias -font DejaVu-Sans -pointsize 20 -gravity Southeast -annotate +15+15 'TEST' /fixtures/test-text.jpg | indent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# bin/test-compile <build-dir> <cache-dir> <env-dir> | ||
|
||
# fail hard | ||
set -o pipefail | ||
|
||
# fail harder | ||
set -eu | ||
|
||
bp_dir=$(cd $(dirname $0); cd ..; pwd) | ||
source $bp_dir/bin/compile |
Oops, something went wrong.