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:
|
||||
- master
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -30,7 +27,6 @@ jobs:
|
|||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
|
|
@ -38,7 +34,7 @@ jobs:
|
|||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- 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
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
|
|
@ -53,7 +49,6 @@ jobs:
|
|||
name=shumc/imagorvideo,enable=${{ github.repository == 'cshum/imagorvideo' }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
|
||||
|
|
@ -62,6 +57,6 @@ jobs:
|
|||
with:
|
||||
context: .
|
||||
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 }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
|
|
|||
133
.github/workflows/test.yml
vendored
|
|
@ -5,130 +5,47 @@ on:
|
|||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
CGO_CFLAGS_ALLOW: -Xpreprocessor
|
||||
VIPS_VERSION: 8.17.1
|
||||
FFMPEG_VERSION: 7.1.1
|
||||
V: 5
|
||||
|
||||
test:
|
||||
name: Docker Test
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ^1.25
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install linux dependencies
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build test image
|
||||
run: |
|
||||
# Add backports for updated libheif
|
||||
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
|
||||
docker build --target builder -t imagorvideo-test .
|
||||
|
||||
- name: Cache libvips
|
||||
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
|
||||
- name: Run tests in Docker
|
||||
run: |
|
||||
if [ ! -d "vips-${{ env.VIPS_VERSION }}" ]
|
||||
then
|
||||
wget https://github.com/libvips/libvips/releases/download/v${{ env.VIPS_VERSION }}/vips-${{ env.VIPS_VERSION }}.tar.xz
|
||||
tar xf vips-${{ env.VIPS_VERSION }}.tar.xz
|
||||
fi
|
||||
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
|
||||
docker run --rm \
|
||||
-v ${{ github.workspace }}:/workspace \
|
||||
-w /workspace \
|
||||
imagorvideo-test \
|
||||
go test ./... -v
|
||||
|
||||
- name: Commit golden files
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "test: update golden files"
|
||||
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
|
||||
uses: shogo82148/actions-goveralls@v1
|
||||
with:
|
||||
|
|
|
|||
29
Dockerfile
|
|
@ -1,5 +1,5 @@
|
|||
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 VIPS_VERSION=8.17.1
|
||||
|
|
@ -8,9 +8,8 @@ ARG TARGETARCH
|
|||
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
ENV MAKEFLAGS="-j8"
|
||||
|
||||
# Installs libvips + FFmpeg + required libraries including modern image formats
|
||||
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
# Installs libvips + FFmpeg + required libraries including modern image formats + ImageMagick
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
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 \
|
||||
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 \
|
||||
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 \
|
||||
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 && \
|
||||
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \
|
||||
tar xf vips-${VIPS_VERSION}.tar.xz && \
|
||||
|
|
@ -75,27 +74,25 @@ RUN go mod download
|
|||
|
||||
COPY . .
|
||||
|
||||
RUN if [ "$TARGETARCH" = "amd64" ]; then go test ./...; fi
|
||||
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"
|
||||
|
||||
COPY --from=builder /usr/local/lib /usr/local/lib
|
||||
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
||||
|
||||
# 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 && \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
procps curl libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr-3-1-30 \
|
||||
libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8 \
|
||||
libpango1.0-0 libmatio11 libopenslide0 libopenjp2-7 libjemalloc2 \
|
||||
libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10 libimagequant0 libaom3 \
|
||||
libspng0 libcgif0 libdav1d6 libmagickwand-6.q16-6 \
|
||||
libx264-dev libx265-dev libnuma-dev libvpx7 libtheora0 libvorbis-dev && \
|
||||
apt-get install --no-install-recommends -y -t bookworm-backports libheif1 libheif-plugin-x265 libheif-plugin-aomenc libjxl0.7 && \
|
||||
libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8t64 \
|
||||
libpango-1.0-0 libmatio13 libopenslide0 libopenjp2-7 libjemalloc2 \
|
||||
libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10t64 libimagequant0 libaom3 \
|
||||
libspng0 libcgif0 libheif1 libheif-plugin-x265 libheif-plugin-aomenc libjxl0.11 libavif-dev \
|
||||
libmagickwand-7.q16-10 \
|
||||
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 && \
|
||||
apt-get autoremove -y && \
|
||||
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 |