build: debian trixie, CI/CD refactor (#107)
* debian trixie * run tests in docker * cleanup * test: reset golden * test: update golden files --------- Co-authored-by: cshum <293790+cshum@users.noreply.github.com>
9
.github/workflows/docker.yml
vendored
|
|
@ -5,9 +5,6 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
tags: [ 'v*.*.*' ]
|
tags: [ 'v*.*.*' ]
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -30,7 +27,6 @@ jobs:
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
|
@ -38,7 +34,7 @@ jobs:
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: github.repository == 'cshum/imagorvideo' && github.event_name != 'pull_request'
|
if: github.repository == 'cshum/imagorvideo'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
|
@ -53,7 +49,6 @@ jobs:
|
||||||
name=shumc/imagorvideo,enable=${{ github.repository == 'cshum/imagorvideo' }}
|
name=shumc/imagorvideo,enable=${{ github.repository == 'cshum/imagorvideo' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
|
||||||
|
|
@ -62,6 +57,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
platforms: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
|
||||||
133
.github/workflows/test.yml
vendored
|
|
@ -5,130 +5,47 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
name: Test
|
name: Docker Test
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
env:
|
|
||||||
CGO_CFLAGS_ALLOW: -Xpreprocessor
|
|
||||||
VIPS_VERSION: 8.17.1
|
|
||||||
FFMPEG_VERSION: 7.1.1
|
|
||||||
V: 5
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.x
|
|
||||||
uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: ^1.25
|
|
||||||
|
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install linux dependencies
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build test image
|
||||||
run: |
|
run: |
|
||||||
# Add backports for updated libheif
|
docker build --target builder -t imagorvideo-test .
|
||||||
echo "deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/backports.list
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y \
|
|
||||||
meson ninja-build \
|
|
||||||
libglib2.0-dev libexpat-dev librsvg2-dev libpng-dev \
|
|
||||||
libjpeg-turbo8-dev libimagequant-dev libfftw3-dev \
|
|
||||||
libpoppler-glib-dev libxml2-dev \
|
|
||||||
libopenslide-dev libcfitsio-dev liborc-0.4-dev libpango1.0-dev \
|
|
||||||
libtiff5-dev libgsf-1-dev giflib-tools libwebp-dev \
|
|
||||||
yasm libx264-dev libx265-dev libnuma-dev libvpx-dev libtheora-dev \
|
|
||||||
librtmp-dev libvorbis-dev libdav1d-dev libaom-dev \
|
|
||||||
libopenjp2-7-dev libcgif-dev
|
|
||||||
# Install newer libheif from backports
|
|
||||||
sudo apt-get install -y -t jammy-backports libheif-dev || sudo apt-get install -y libheif-dev
|
|
||||||
|
|
||||||
- name: Cache libvips
|
- name: Run tests in Docker
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: vips-${{ env.VIPS_VERSION }}
|
|
||||||
key: ${{ runner.os }}-vips-${{ env.V }}-${{ env.VIPS_VERSION }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-vips-${{ env.V }}-
|
|
||||||
|
|
||||||
- name: Build libvips from source
|
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d "vips-${{ env.VIPS_VERSION }}" ]
|
docker run --rm \
|
||||||
then
|
-v ${{ github.workspace }}:/workspace \
|
||||||
wget https://github.com/libvips/libvips/releases/download/v${{ env.VIPS_VERSION }}/vips-${{ env.VIPS_VERSION }}.tar.xz
|
-w /workspace \
|
||||||
tar xf vips-${{ env.VIPS_VERSION }}.tar.xz
|
imagorvideo-test \
|
||||||
fi
|
go test ./... -v
|
||||||
cd vips-${{ env.VIPS_VERSION }}
|
|
||||||
meson setup _build \
|
|
||||||
--buildtype=release \
|
|
||||||
--strip \
|
|
||||||
--prefix=/usr/local \
|
|
||||||
--libdir=lib \
|
|
||||||
-Dmagick=disabled \
|
|
||||||
-Dintrospection=disabled
|
|
||||||
ninja -C _build
|
|
||||||
sudo ninja -C _build install
|
|
||||||
sudo ldconfig
|
|
||||||
|
|
||||||
- name: Cache ffmpeg
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: ffmpeg-${{ env.FFMPEG_VERSION }}
|
|
||||||
key: ${{ runner.os }}-ffmpeg-${{ env.V }}-${{ env.FFMPEG_VERSION }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-ffmpeg-${{ env.V }}-
|
|
||||||
|
|
||||||
- name: Build ffmpeg from source
|
|
||||||
run: |
|
|
||||||
if [ ! -d "ffmpeg-${{ env.FFMPEG_VERSION }}" ]
|
|
||||||
then
|
|
||||||
wget https://ffmpeg.org/releases/ffmpeg-${{ env.FFMPEG_VERSION }}.tar.xz
|
|
||||||
tar xf ffmpeg-${{ env.FFMPEG_VERSION }}.tar.xz
|
|
||||||
fi
|
|
||||||
cd ffmpeg-${{ env.FFMPEG_VERSION }}
|
|
||||||
./configure --prefix=/usr/local \
|
|
||||||
--disable-debug \
|
|
||||||
--disable-doc \
|
|
||||||
--disable-ffplay \
|
|
||||||
--disable-static \
|
|
||||||
--enable-shared \
|
|
||||||
--enable-version3 \
|
|
||||||
--enable-gpl \
|
|
||||||
--enable-libtheora \
|
|
||||||
--enable-libvorbis \
|
|
||||||
--enable-librtmp \
|
|
||||||
--enable-libwebp \
|
|
||||||
--enable-libvpx \
|
|
||||||
--enable-libx265 \
|
|
||||||
--enable-libx264 \
|
|
||||||
--enable-libdav1d \
|
|
||||||
--enable-libaom
|
|
||||||
make && sudo make install
|
|
||||||
sudo ldconfig
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cache/go-build
|
|
||||||
~/go/pkg/mod
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
|
|
||||||
- name: Get dependencies
|
|
||||||
run: make get
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: make test
|
|
||||||
|
|
||||||
- name: Commit golden files
|
- name: Commit golden files
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
with:
|
with:
|
||||||
commit_message: "test: update golden files"
|
commit_message: "test: update golden files"
|
||||||
file_pattern: "testdata/golden"
|
file_pattern: "testdata/golden"
|
||||||
|
|
||||||
|
- name: Run coverage in Docker
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v ${{ github.workspace }}:/workspace \
|
||||||
|
-w /workspace \
|
||||||
|
imagorvideo-test \
|
||||||
|
sh -c "rm -rf examples cmd && go test -coverprofile=profile.cov ./..."
|
||||||
|
|
||||||
- name: Coveralls
|
- name: Coveralls
|
||||||
uses: shogo82148/actions-goveralls@v1
|
uses: shogo82148/actions-goveralls@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
29
Dockerfile
|
|
@ -1,5 +1,5 @@
|
||||||
ARG GOLANG_VERSION=1.25.0
|
ARG GOLANG_VERSION=1.25.0
|
||||||
FROM golang:${GOLANG_VERSION}-bookworm as builder
|
FROM golang:${GOLANG_VERSION}-trixie as builder
|
||||||
|
|
||||||
ARG FFMPEG_VERSION=7.1.1
|
ARG FFMPEG_VERSION=7.1.1
|
||||||
ARG VIPS_VERSION=8.17.1
|
ARG VIPS_VERSION=8.17.1
|
||||||
|
|
@ -8,9 +8,8 @@ ARG TARGETARCH
|
||||||
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||||
ENV MAKEFLAGS="-j8"
|
ENV MAKEFLAGS="-j8"
|
||||||
|
|
||||||
# Installs libvips + FFmpeg + required libraries including modern image formats
|
# Installs libvips + FFmpeg + required libraries including modern image formats + ImageMagick
|
||||||
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
|
RUN DEBIAN_FRONTEND=noninteractive \
|
||||||
DEBIAN_FRONTEND=noninteractive \
|
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
|
@ -20,10 +19,10 @@ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/s
|
||||||
libwebp-dev libtiff-dev libexif-dev libxml2-dev libpoppler-glib-dev \
|
libwebp-dev libtiff-dev libexif-dev libxml2-dev libpoppler-glib-dev \
|
||||||
swig libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev libopenjp2-7-dev liblcms2-dev \
|
swig libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev libopenjp2-7-dev liblcms2-dev \
|
||||||
libgsf-1-dev libfftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libaom-dev \
|
libgsf-1-dev libfftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libaom-dev \
|
||||||
libspng-dev libcgif-dev libmagickwand-dev \
|
libspng-dev libcgif-dev libheif-dev libheif-plugin-x265 libheif-plugin-aomenc libjxl-dev libavif-dev \
|
||||||
|
libmagickwand-dev \
|
||||||
yasm libx264-dev libx265-dev libnuma-dev libvpx-dev libtheora-dev \
|
yasm libx264-dev libx265-dev libnuma-dev libvpx-dev libtheora-dev \
|
||||||
librtmp-dev libvorbis-dev libdav1d-dev && \
|
librtmp-dev libvorbis-dev libdav1d-dev && \
|
||||||
apt-get install --no-install-recommends -y -t bookworm-backports libheif-dev libheif-plugin-x265 libheif-plugin-aomenc libjxl-dev && \
|
|
||||||
cd /tmp && \
|
cd /tmp && \
|
||||||
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \
|
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \
|
||||||
tar xf vips-${VIPS_VERSION}.tar.xz && \
|
tar xf vips-${VIPS_VERSION}.tar.xz && \
|
||||||
|
|
@ -75,27 +74,25 @@ RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN if [ "$TARGETARCH" = "amd64" ]; then go test ./...; fi
|
|
||||||
RUN go build -o ${GOPATH}/bin/imagorvideo ./cmd/imagorvideo/main.go
|
RUN go build -o ${GOPATH}/bin/imagorvideo ./cmd/imagorvideo/main.go
|
||||||
|
|
||||||
FROM debian:bookworm-slim as runtime
|
FROM debian:trixie-slim as runtime
|
||||||
LABEL maintainer="adrian@cshum.com"
|
LABEL maintainer="adrian@cshum.com"
|
||||||
|
|
||||||
COPY --from=builder /usr/local/lib /usr/local/lib
|
COPY --from=builder /usr/local/lib /usr/local/lib
|
||||||
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
||||||
|
|
||||||
# Install runtime dependencies including modern image formats and ImageMagick
|
# Install runtime dependencies including modern image formats and ImageMagick
|
||||||
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
|
RUN DEBIAN_FRONTEND=noninteractive \
|
||||||
DEBIAN_FRONTEND=noninteractive \
|
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
procps curl libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr-3-1-30 \
|
procps curl libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr-3-1-30 \
|
||||||
libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8 \
|
libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8t64 \
|
||||||
libpango1.0-0 libmatio11 libopenslide0 libopenjp2-7 libjemalloc2 \
|
libpango-1.0-0 libmatio13 libopenslide0 libopenjp2-7 libjemalloc2 \
|
||||||
libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10 libimagequant0 libaom3 \
|
libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10t64 libimagequant0 libaom3 \
|
||||||
libspng0 libcgif0 libdav1d6 libmagickwand-6.q16-6 \
|
libspng0 libcgif0 libheif1 libheif-plugin-x265 libheif-plugin-aomenc libjxl0.11 libavif-dev \
|
||||||
libx264-dev libx265-dev libnuma-dev libvpx7 libtheora0 libvorbis-dev && \
|
libmagickwand-7.q16-10 \
|
||||||
apt-get install --no-install-recommends -y -t bookworm-backports libheif1 libheif-plugin-x265 libheif-plugin-aomenc libjxl0.7 && \
|
libdav1d7 libx264-dev libx265-dev libnuma-dev libvpx9 libtheora0 libvorbis-dev && \
|
||||||
ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
|
ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
|
||||||
apt-get autoremove -y && \
|
apt-get autoremove -y && \
|
||||||
apt-get autoclean && \
|
apt-get autoclean && \
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |
|
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 312 KiB |
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 330 KiB After Width: | Height: | Size: 330 KiB |
BIN
testdata/golden/result/fit-in/100x100/demo.png
vendored
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 559 KiB After Width: | Height: | Size: 559 KiB |